Jean-Francois Leveque

Correction minimale du test avec l'ActionType.

...@@ -80,24 +80,27 @@ public class PublisherServiceSpringTest { ...@@ -80,24 +80,27 @@ public class PublisherServiceSpringTest {
80 80
81 @DisplayName("Test validation version éditeur") 81 @DisplayName("Test validation version éditeur")
82 @Test 82 @Test
83 - public void testValidateVersion(@Mock PublisherActionRepository publisherActionRepository) { 83 + public void testValidateVersion(@Mock PublisherActionRepository publisherActionRepository,
84 + @Mock ActionTypeRepository actionTypeRepository) {
84 Set<PublisherVersion> publisherVersions; 85 Set<PublisherVersion> publisherVersions;
86 + ActionType actionType = new ActionType();
85 87
86 publisher = new Publisher(); 88 publisher = new Publisher();
87 publisherVersion = new PublisherVersion(); 89 publisherVersion = new PublisherVersion();
88 90
91 +
89 publisherVersions = new HashSet<PublisherVersion>(); 92 publisherVersions = new HashSet<PublisherVersion>();
90 publisherVersions.add(publisherVersion); 93 publisherVersions.add(publisherVersion);
91 publisherVersions.add(publisherVersionMock); 94 publisherVersions.add(publisherVersionMock);
92 95
93 when(publisherVersionMock.getPublisher()).thenReturn(publisher); 96 when(publisherVersionMock.getPublisher()).thenReturn(publisher);
97 + when(actionTypeRepository.findByActionTypeName("Validate")).thenReturn(actionType);
94 PublisherAction publisherAction; 98 PublisherAction publisherAction;
95 publisherAction = publisherServiceSpring.validatePublisherVersion(publisherVersionMock); 99 publisherAction = publisherServiceSpring.validatePublisherVersion(publisherVersionMock);
96 verify(publisherActionRepository).save(publisherAction); 100 verify(publisherActionRepository).save(publisherAction);
97 assertThat(publisherAction.getPublisherVersion()).isEqualTo(publisherVersionMock); 101 assertThat(publisherAction.getPublisherVersion()).isEqualTo(publisherVersionMock);
98 assertThat(publisherAction.getPublisher()).isEqualTo(publisher); 102 assertThat(publisherAction.getPublisher()).isEqualTo(publisher);
99 assertThat(publisherAction.getPublisher().getValidatedVersion()).isEqualTo(publisherVersionMock); 103 assertThat(publisherAction.getPublisher().getValidatedVersion()).isEqualTo(publisherVersionMock);
100 -// TODO Régler ce problème de NPE 104 + assertThat(publisherAction.getActionType()).isEqualTo(actionType);
101 -// assertThat(publisherAction.getActionType()).isEqualTo(actionTypeRepository.findByActionTypeName("Validate"));
102 } 105 }
103 } 106 }
......