diff spring-boot-playground/src/test/java/de/comline/spring/service/MovieServiceTestWithMockRepo.java @ 14:4594ff529ab1

Noch ein Test ganz ohne Spring hinzugefuegt.
author Dirk Olmes <dirk.olmes@codedo.de>
date Mon, 17 Aug 2020 14:39:26 +0200
parents f3f9102ef7c0
children
line wrap: on
line diff
--- a/spring-boot-playground/src/test/java/de/comline/spring/service/MovieServiceTestWithMockRepo.java	Fri Aug 14 08:13:57 2020 +0200
+++ b/spring-boot-playground/src/test/java/de/comline/spring/service/MovieServiceTestWithMockRepo.java	Mon Aug 17 14:39:26 2020 +0200
@@ -2,9 +2,6 @@
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.is;
-import  static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD;
 
 import org.junit.jupiter.api.DisplayName;
@@ -41,11 +38,7 @@
 	static class TestConfig {
 		@Bean
 		MovieRepository createMockRepository() {
-			MovieRepository mockRepository = mock(MovieRepository.class);
-			when(mockRepository.save(any())).thenAnswer(invocation -> {
-				return invocation.getArgument(0);
-			});
-			return mockRepository;
+			return RepositoryMocker.createMockRepository();
 		}
 	}
 }