Skip to content

Commit dddfb48

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

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
@@ -61,6 +61,7 @@
6161
* @author Greg Turnquist
6262
* @author Yanming Zhou
6363
* @author Ariel Morelli Andres
64+
* @author Byungju Ju
6465
*/
6566
@ExtendWith(MockitoExtension.class)
6667
@MockitoSettings(strictness = Strictness.LENIENT)
@@ -183,7 +184,19 @@ void mergeGetsCalledWhenAttached() {
183184
verify(em).merge(attachedUser);
184185
}
185186

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

189202
User newUser = new User();

0 commit comments

Comments
 (0)