Showing
4 changed files
with
21 additions
and
24 deletions
... | @@ -19,7 +19,7 @@ import java.util.Set; | ... | @@ -19,7 +19,7 @@ import java.util.Set; |
19 | */ | 19 | */ |
20 | 20 | ||
21 | @Stateless | 21 | @Stateless |
22 | -public class PublisherServiceSpring implements PublisherService { | 22 | +public class PublisherServiceDefault implements PublisherService { |
23 | Logger logger = LoggerFactory.getLogger(getClass()); | 23 | Logger logger = LoggerFactory.getLogger(getClass()); |
24 | 24 | ||
25 | PublisherRepository publisherRepository; | 25 | PublisherRepository publisherRepository; |
... | @@ -29,11 +29,11 @@ public class PublisherServiceSpring implements PublisherService { | ... | @@ -29,11 +29,11 @@ public class PublisherServiceSpring implements PublisherService { |
29 | SharedService sharedService; | 29 | SharedService sharedService; |
30 | 30 | ||
31 | @Inject | 31 | @Inject |
32 | - public PublisherServiceSpring(PublisherRepository publisherRepository, | 32 | + public PublisherServiceDefault(PublisherRepository publisherRepository, |
33 | - PublisherVersionRepository publisherVersionRepository, | 33 | + PublisherVersionRepository publisherVersionRepository, |
34 | - PublisherActionRepository publisherActionRepository, | 34 | + PublisherActionRepository publisherActionRepository, |
35 | - PublisherSearchRepository publisherSearchRepository, | 35 | + PublisherSearchRepository publisherSearchRepository, |
36 | - SharedService sharedService) { | 36 | + SharedService sharedService) { |
37 | this.publisherRepository = publisherRepository; | 37 | this.publisherRepository = publisherRepository; |
38 | this.publisherVersionRepository = publisherVersionRepository; | 38 | this.publisherVersionRepository = publisherVersionRepository; |
39 | this.publisherActionRepository = publisherActionRepository; | 39 | this.publisherActionRepository = publisherActionRepository; |
... | @@ -42,7 +42,7 @@ public class PublisherServiceSpring implements PublisherService { | ... | @@ -42,7 +42,7 @@ public class PublisherServiceSpring implements PublisherService { |
42 | } | 42 | } |
43 | 43 | ||
44 | //no args constructor to make it proxyable | 44 | //no args constructor to make it proxyable |
45 | - PublisherServiceSpring() { | 45 | + PublisherServiceDefault() { |
46 | } | 46 | } |
47 | 47 | ||
48 | public PublisherVersion addNewPublisher(PublisherVersion publisherVersion) { | 48 | public PublisherVersion addNewPublisher(PublisherVersion publisherVersion) { | ... | ... |
... | @@ -8,7 +8,7 @@ import javax.inject.Inject; | ... | @@ -8,7 +8,7 @@ import javax.inject.Inject; |
8 | import java.util.List; | 8 | import java.util.List; |
9 | 9 | ||
10 | @Stateless | 10 | @Stateless |
11 | -public class UserServiceSpring implements UserService { | 11 | +public class UserServiceDefault implements UserService { |
12 | @Inject | 12 | @Inject |
13 | AccountRepository accountRepository; | 13 | AccountRepository accountRepository; |
14 | 14 | ... | ... |
... | @@ -12,7 +12,7 @@ import java.util.Random; | ... | @@ -12,7 +12,7 @@ import java.util.Random; |
12 | import java.util.Vector; | 12 | import java.util.Vector; |
13 | 13 | ||
14 | @Stateless | 14 | @Stateless |
15 | -public class SharedServiceSpring implements SharedService { | 15 | +public class SharedServiceDefault implements SharedService { |
16 | 16 | ||
17 | CountryRepository countryRepository; | 17 | CountryRepository countryRepository; |
18 | AccountRoleRepository accountRoleRepository; | 18 | AccountRoleRepository accountRoleRepository; |
... | @@ -20,8 +20,8 @@ public class SharedServiceSpring implements SharedService { | ... | @@ -20,8 +20,8 @@ public class SharedServiceSpring implements SharedService { |
20 | UserService userService; | 20 | UserService userService; |
21 | 21 | ||
22 | @Inject | 22 | @Inject |
23 | - public SharedServiceSpring(CountryRepository countryRepository, AccountRoleRepository accountRoleRepository, | 23 | + public SharedServiceDefault(CountryRepository countryRepository, AccountRoleRepository accountRoleRepository, |
24 | - AccountPropertyRepository accountPropertyRepository, UserService userService) { | 24 | + AccountPropertyRepository accountPropertyRepository, UserService userService) { |
25 | this.countryRepository = countryRepository; | 25 | this.countryRepository = countryRepository; |
26 | this.accountRoleRepository = accountRoleRepository; | 26 | this.accountRoleRepository = accountRoleRepository; |
27 | this.accountPropertyRepository = accountPropertyRepository; | 27 | this.accountPropertyRepository = accountPropertyRepository; | ... | ... |
... | @@ -14,24 +14,21 @@ import org.mockito.Captor; | ... | @@ -14,24 +14,21 @@ import org.mockito.Captor; |
14 | import org.mockito.Mock; | 14 | import org.mockito.Mock; |
15 | import org.mockito.Mockito; | 15 | import org.mockito.Mockito; |
16 | 16 | ||
17 | -import javax.inject.Inject; | ||
18 | -import java.util.ArrayList; | ||
19 | import java.util.HashSet; | 17 | import java.util.HashSet; |
20 | -import java.util.List; | ||
21 | import java.util.Set; | 18 | import java.util.Set; |
22 | 19 | ||
23 | import static org.assertj.core.api.Assertions.assertThat; | 20 | import static org.assertj.core.api.Assertions.assertThat; |
24 | import static org.mockito.Mockito.*; | 21 | import static org.mockito.Mockito.*; |
25 | 22 | ||
26 | /** | 23 | /** |
27 | - * Classe testant PublisherServiceSpring. | 24 | + * Classe testant PublisherServiceDefault. |
28 | */ | 25 | */ |
29 | @RunWith(JUnitPlatform.class) | 26 | @RunWith(JUnitPlatform.class) |
30 | @ExtendWith(MockitoExtension.class) | 27 | @ExtendWith(MockitoExtension.class) |
31 | @DisplayName("Service layer for all publisher-related data") | 28 | @DisplayName("Service layer for all publisher-related data") |
32 | -public class PublisherServiceSpringTest { | 29 | +public class PublisherServiceDefaultTest { |
33 | 30 | ||
34 | - PublisherServiceSpring publisherServiceSpring; | 31 | + PublisherServiceDefault publisherServiceDefault; |
35 | PublisherVersion publisherVersion; | 32 | PublisherVersion publisherVersion; |
36 | PublisherVersion publisherVersion1; | 33 | PublisherVersion publisherVersion1; |
37 | Publisher publisher; | 34 | Publisher publisher; |
... | @@ -50,7 +47,7 @@ public class PublisherServiceSpringTest { | ... | @@ -50,7 +47,7 @@ public class PublisherServiceSpringTest { |
50 | @Mock PublisherActionRepository publisherActionRepository, | 47 | @Mock PublisherActionRepository publisherActionRepository, |
51 | @Mock PublisherSearchRepository publisherSearchRepository, | 48 | @Mock PublisherSearchRepository publisherSearchRepository, |
52 | @Mock SharedService sharedService) throws Exception { | 49 | @Mock SharedService sharedService) throws Exception { |
53 | - publisherServiceSpring = new PublisherServiceSpring(publisherRepository, | 50 | + publisherServiceDefault = new PublisherServiceDefault(publisherRepository, |
54 | publisherVersionRepository, publisherActionRepository, publisherSearchRepository, sharedService); | 51 | publisherVersionRepository, publisherActionRepository, publisherSearchRepository, sharedService); |
55 | publisherVersion = new PublisherVersion(); | 52 | publisherVersion = new PublisherVersion(); |
56 | publisherVersion1 = new PublisherVersion(); | 53 | publisherVersion1 = new PublisherVersion(); |
... | @@ -60,7 +57,7 @@ public class PublisherServiceSpringTest { | ... | @@ -60,7 +57,7 @@ public class PublisherServiceSpringTest { |
60 | @DisplayName("When a new publisher is added, both Publisher and PublisherVersion should be saved in the right state") | 57 | @DisplayName("When a new publisher is added, both Publisher and PublisherVersion should be saved in the right state") |
61 | @Test | 58 | @Test |
62 | public void testAddNewPublisher(@Mock PublisherVersionRepository publisherVersionRepository) { | 59 | public void testAddNewPublisher(@Mock PublisherVersionRepository publisherVersionRepository) { |
63 | - publisherServiceSpring.addNewPublisher(publisherVersion); | 60 | + publisherServiceDefault.addNewPublisher(publisherVersion); |
64 | publisher = publisherVersion.getPublisher(); | 61 | publisher = publisherVersion.getPublisher(); |
65 | assertThat(publisher.getVersions()).containsExactly(publisherVersion); | 62 | assertThat(publisher.getVersions()).containsExactly(publisherVersion); |
66 | assertThat(publisherVersion.getPublisher()).isEqualTo(publisher); | 63 | assertThat(publisherVersion.getPublisher()).isEqualTo(publisher); |
... | @@ -72,9 +69,9 @@ public class PublisherServiceSpringTest { | ... | @@ -72,9 +69,9 @@ public class PublisherServiceSpringTest { |
72 | @Test | 69 | @Test |
73 | public void testAddVersionToPublisher(@Mock PublisherRepository publisherRepository, | 70 | public void testAddVersionToPublisher(@Mock PublisherRepository publisherRepository, |
74 | @Mock PublisherVersionRepository publisherVersionRepository) { | 71 | @Mock PublisherVersionRepository publisherVersionRepository) { |
75 | - publisherServiceSpring.addNewPublisher(publisherVersion); | 72 | + publisherServiceDefault.addNewPublisher(publisherVersion); |
76 | publisher = publisherVersion.getPublisher(); | 73 | publisher = publisherVersion.getPublisher(); |
77 | - publisherServiceSpring.addVersionToPublisher(publisher, publisherVersion1); | 74 | + publisherServiceDefault.addVersionToPublisher(publisher, publisherVersion1); |
78 | assertThat(publisherVersion1.getPublisher()).isEqualTo(publisher); | 75 | assertThat(publisherVersion1.getPublisher()).isEqualTo(publisher); |
79 | assertThat(publisher.getVersions()).contains(publisherVersion, publisherVersion1); | 76 | assertThat(publisher.getVersions()).contains(publisherVersion, publisherVersion1); |
80 | verify(publisherRepository, times(2)).save(publisher); | 77 | verify(publisherRepository, times(2)).save(publisher); |
... | @@ -94,7 +91,7 @@ public class PublisherServiceSpringTest { | ... | @@ -94,7 +91,7 @@ public class PublisherServiceSpringTest { |
94 | publisher.setVersions(publisherVersions); | 91 | publisher.setVersions(publisherVersions); |
95 | 92 | ||
96 | when(publisherVersionMock.getPublisher()).thenReturn(publisher); | 93 | when(publisherVersionMock.getPublisher()).thenReturn(publisher); |
97 | - publisherServiceSpring.validatePublisherVersion(publisherVersionMock); | 94 | + publisherServiceDefault.validatePublisherVersion(publisherVersionMock); |
98 | assertThat(publisher.getValidatedVersion()).isEqualTo(publisherVersionMock); | 95 | assertThat(publisher.getValidatedVersion()).isEqualTo(publisherVersionMock); |
99 | } | 96 | } |
100 | 97 | ||
... | @@ -108,7 +105,7 @@ public class PublisherServiceSpringTest { | ... | @@ -108,7 +105,7 @@ public class PublisherServiceSpringTest { |
108 | when(publisherVersionMock.getPublisher()).thenReturn(publisher); | 105 | when(publisherVersionMock.getPublisher()).thenReturn(publisher); |
109 | when(publisherVersionMock.getPublisherName()).thenReturn("nom"); | 106 | when(publisherVersionMock.getPublisherName()).thenReturn("nom"); |
110 | when(publisherVersionMock.getPublisherHistory()).thenReturn("histoire"); | 107 | when(publisherVersionMock.getPublisherHistory()).thenReturn("histoire"); |
111 | - publisherServiceSpring.validatePublisherVersion(publisherVersionMock); | 108 | + publisherServiceDefault.validatePublisherVersion(publisherVersionMock); |
112 | try { | 109 | try { |
113 | Mockito.verify(publisherSearchRepository).save(indexedPublisherArgumentCaptor.capture()); | 110 | Mockito.verify(publisherSearchRepository).save(indexedPublisherArgumentCaptor.capture()); |
114 | } catch (IndexingException e) { | 111 | } catch (IndexingException e) { |
... | @@ -129,7 +126,7 @@ public class PublisherServiceSpringTest { | ... | @@ -129,7 +126,7 @@ public class PublisherServiceSpringTest { |
129 | publisher = new Publisher(); | 126 | publisher = new Publisher(); |
130 | 127 | ||
131 | when(publisherVersionMock.getPublisher()).thenReturn(publisher); | 128 | when(publisherVersionMock.getPublisher()).thenReturn(publisher); |
132 | - publisherAction = publisherServiceSpring.validatePublisherVersion(publisherVersionMock); | 129 | + publisherAction = publisherServiceDefault.validatePublisherVersion(publisherVersionMock); |
133 | verify(publisherActionRepository).save(publisherAction); | 130 | verify(publisherActionRepository).save(publisherAction); |
134 | assertThat(publisherAction.getPublisherVersion()).isEqualTo(publisherVersionMock); | 131 | assertThat(publisherAction.getPublisherVersion()).isEqualTo(publisherVersionMock); |
135 | assertThat(publisherAction.getPublisher()).isEqualTo(publisher); | 132 | assertThat(publisherAction.getPublisher()).isEqualTo(publisher); | ... | ... |
-
Please register or login to post a comment