File tree Expand file tree Collapse file tree
src/test/java/org/baeldung/persistence/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 189189
190190 <properties >
191191 <!-- Spring -->
192- <org .springframework.version>4.2.5 .RELEASE</org .springframework.version>
192+ <org .springframework.version>4.3.2 .RELEASE</org .springframework.version>
193193 <javassist .version>3.20.0-GA</javassist .version>
194194
195195 <!-- persistence -->
196- <hibernate .version>4.3.11 .Final</hibernate .version>
196+ <hibernate .version>5.2.2 .Final</hibernate .version>
197197 <mysql-connector-java .version>5.1.38</mysql-connector-java .version>
198- <spring-data-jpa .version>1.8 .2.RELEASE</spring-data-jpa .version>
198+ <spring-data-jpa .version>1.10 .2.RELEASE</spring-data-jpa .version>
199199 <h2 .version>1.4.192</h2 .version>
200200
201201 <!-- logging -->
Original file line number Diff line number Diff line change 22
33import static org .junit .Assert .assertNotNull ;
44import static org .junit .Assert .assertNull ;
5+ import static org .junit .Assert .fail ;
56
67import org .baeldung .config .ProductConfig ;
78import org .baeldung .config .UserConfig ;
@@ -57,10 +58,13 @@ public void whenCreatingUsersWithSameEmail_thenRollback() {
5758 user2 .setAge (10 );
5859 try {
5960 user2 = userRepository .save (user2 );
61+ userRepository .flush ();
62+ fail ("DataIntegrityViolationException should be thrown!" );
6063 } catch (final DataIntegrityViolationException e ) {
64+ // Expected
65+ } catch (final Exception e ) {
66+ fail ("DataIntegrityViolationException should be thrown, instead got: " + e );
6167 }
62-
63- assertNull (userRepository .findOne (user2 .getId ()));
6468 }
6569
6670 @ Test
You can’t perform that action at this time.
0 commit comments