Jean-Francois Leveque

Augmentation couverture de ListPublisherVersionsView par les tests.

......@@ -5,6 +5,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.DisplayName;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherAction;
import org.legrog.entities.PublisherVersion;
import org.mockito.Answers;
import org.mockito.Mock;
......@@ -32,6 +33,9 @@ public class ListPublisherVersionsViewTest {
private PublisherVersion publisherVersion;
private PublisherVersion publisherVersion1;
private PublisherVersion publisherVersion2;
private Publisher publisher;
private Publisher publisher1;
PublisherAction publisherAction;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private PublisherService publisherService;
......@@ -39,7 +43,6 @@ public class ListPublisherVersionsViewTest {
@Before
public void setUp() {
// Données
publisherVersion = new PublisherVersion();
publisherVersion1 = new PublisherVersion();
......@@ -47,8 +50,8 @@ public class ListPublisherVersionsViewTest {
publisherVersion.setPublisherVersionId(0);
publisherVersion1.setPublisherVersionId(1);
publisherVersion2.setPublisherVersionId(2);
Publisher publisher = new Publisher();
Publisher publisher1 = new Publisher();
publisher = new Publisher();
publisher1 = new Publisher();
publisher.setPublisherId(0);
publisher1.setPublisherId(1);
publisherVersion.setPublisher(publisher);
......@@ -58,10 +61,13 @@ public class ListPublisherVersionsViewTest {
publisherVersions = new ArrayList<PublisherVersion>();
publisherVersions.add(publisherVersion);
publisherVersions.add(publisherVersion1);
publisherAction = new PublisherAction();
// Mock
when(publisherService.getAllPublisherVersions()).thenReturn(publisherVersions);
listPublisherVersionsView = new ListPublisherVersionsView(publisherService);
when(publisherService.getLastValidate(publisher)).thenReturn(publisherAction);
when(publisherService.getLastValidate(publisher1)).thenReturn(null);
}
......@@ -72,7 +78,7 @@ public class ListPublisherVersionsViewTest {
listPublisherVersionsView.setView();
Mockito.verify(publisherService).getAllPublisherVersions();
assertThat(listPublisherVersionsView.isViewAll()).isTrue();
assertThat(listPublisherVersionsView.getPublisherVersions()).isEqualTo(this.publisherVersions);
assertThat(listPublisherVersionsView.getPublisherVersions()).isEqualTo(publisherVersions);
}
@Test
......@@ -82,7 +88,7 @@ public class ListPublisherVersionsViewTest {
listPublisherVersionsView.setView();
Mockito.verify(publisherService).getAllPublisherVersions();
assertThat(listPublisherVersionsView.isViewAll()).isFalse();
assertThat(listPublisherVersionsView.getPublisherVersions()).containsExactly(this.publisherVersion1);
assertThat(listPublisherVersionsView.getPublisherVersions()).containsExactly(publisherVersion1);
}
@Test
......@@ -92,4 +98,16 @@ public class ListPublisherVersionsViewTest {
listPublisherVersionsView.validate(publisherVersion2);
Mockito.verify(publisherService).validatePublisherVersion(publisherVersion2);
}
@Test
@DisplayName("Récupération effective dernière validation d'un éditeur")
public void testGetLastValidate() {
assertThat(listPublisherVersionsView.getLastValidate(publisher)).isEqualTo(publisherAction);
}
@Test
@DisplayName("Échec de récupération de dernière validation d'un éditeur")
public void testGetLastValidateNull() {
assertThat(listPublisherVersionsView.getLastValidate(publisher1)).isNull();
}
}
\ No newline at end of file
......