Jean-Francois Leveque

sonarQube : Test de vouverture de l'Exception inattendue.

......@@ -20,6 +20,7 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.when;
......@@ -37,7 +38,8 @@ public class PublisherVersionViewTest {
private PublisherVersion publisherVersion;
// TODO tester add et update, mais je ne sais pas comment je suis censé faire
@Mock
PublisherVersion publisherVersionMock;
@BeforeEach
public void setUp(@Mock PublisherService publisherService, @Mock SharedService sharedService) throws Exception {
......@@ -179,6 +181,23 @@ public class PublisherVersionViewTest {
}
@Nested
@DisplayName("getImmutableValues method")
class getImmutableValuesTests{
@BeforeEach
@DisplayName("given a way to get a null")
public void given(@Mock PublisherService publisherService) {
when(publisherService.addNewPublisher(any())).thenReturn(publisherVersionMock);
when(publisherVersionMock.getPublisherVersionId()).thenReturn(2);
when(publisherService.getPublisherVersion(2)).thenReturn(null);
}
@Test
@DisplayName("throws an IllegalStateException")
public void testUnexcpetedNull() {
assertThrows(IllegalStateException.class, () -> publisherVersionView.add());
}
}
@Nested
@DisplayName("save method")
class saveTests{
PublisherVersionView publisherVersionViewForSave;
......