Skip to content

Commit f1fc404

Browse files
GoToBILLschauder
authored andcommitted
Add test coverage for persist() path in SimpleJpaRepository.save().
Closes #4125 Original pull request #4127 Signed-off-by: Byungju Ju <[email protected]>
1 parent 4adac22 commit f1fc404

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/support/SimpleJpaRepositoryUnitTests.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* @author Greg Turnquist
6161
* @author Yanming Zhou
6262
* @author Ariel Morelli Andres
63+
* @author Byungju Ju
6364
*/
6465
@ExtendWith(MockitoExtension.class)
6566
@MockitoSettings(strictness = Strictness.LENIENT)
@@ -182,7 +183,19 @@ void mergeGetsCalledWhenAttached() {
182183
verify(em).merge(attachedUser);
183184
}
184185

185-
@Test // DATAJPA-1535
186+
@Test // GH-4125
187+
void persistGetsCalledWhenEntityIsNew() {
188+
189+
User user = new User();
190+
191+
when(information.isNew(user)).thenReturn(true);
192+
193+
repo.save(user);
194+
195+
verify(em).persist(user);
196+
}
197+
198+
@Test // DATAJPA-1535
186199
void doNothingWhenNewInstanceGetsDeleted() {
187200

188201
User newUser = new User();

0 commit comments

Comments
 (0)