Jean-Francois Leveque

Augmentation couverture de ListPublisherVersionsView par les tests.

...@@ -5,6 +5,7 @@ import org.junit.Test; ...@@ -5,6 +5,7 @@ import org.junit.Test;
5 import org.junit.runner.RunWith; 5 import org.junit.runner.RunWith;
6 import org.junit.jupiter.api.DisplayName; 6 import org.junit.jupiter.api.DisplayName;
7 import org.legrog.entities.Publisher; 7 import org.legrog.entities.Publisher;
8 +import org.legrog.entities.PublisherAction;
8 import org.legrog.entities.PublisherVersion; 9 import org.legrog.entities.PublisherVersion;
9 import org.mockito.Answers; 10 import org.mockito.Answers;
10 import org.mockito.Mock; 11 import org.mockito.Mock;
...@@ -32,6 +33,9 @@ public class ListPublisherVersionsViewTest { ...@@ -32,6 +33,9 @@ public class ListPublisherVersionsViewTest {
32 private PublisherVersion publisherVersion; 33 private PublisherVersion publisherVersion;
33 private PublisherVersion publisherVersion1; 34 private PublisherVersion publisherVersion1;
34 private PublisherVersion publisherVersion2; 35 private PublisherVersion publisherVersion2;
36 + private Publisher publisher;
37 + private Publisher publisher1;
38 + PublisherAction publisherAction;
35 39
36 @Mock(answer = Answers.RETURNS_DEEP_STUBS) 40 @Mock(answer = Answers.RETURNS_DEEP_STUBS)
37 private PublisherService publisherService; 41 private PublisherService publisherService;
...@@ -39,7 +43,6 @@ public class ListPublisherVersionsViewTest { ...@@ -39,7 +43,6 @@ public class ListPublisherVersionsViewTest {
39 @Before 43 @Before
40 public void setUp() { 44 public void setUp() {
41 45
42 -
43 // Données 46 // Données
44 publisherVersion = new PublisherVersion(); 47 publisherVersion = new PublisherVersion();
45 publisherVersion1 = new PublisherVersion(); 48 publisherVersion1 = new PublisherVersion();
...@@ -47,8 +50,8 @@ public class ListPublisherVersionsViewTest { ...@@ -47,8 +50,8 @@ public class ListPublisherVersionsViewTest {
47 publisherVersion.setPublisherVersionId(0); 50 publisherVersion.setPublisherVersionId(0);
48 publisherVersion1.setPublisherVersionId(1); 51 publisherVersion1.setPublisherVersionId(1);
49 publisherVersion2.setPublisherVersionId(2); 52 publisherVersion2.setPublisherVersionId(2);
50 - Publisher publisher = new Publisher(); 53 + publisher = new Publisher();
51 - Publisher publisher1 = new Publisher(); 54 + publisher1 = new Publisher();
52 publisher.setPublisherId(0); 55 publisher.setPublisherId(0);
53 publisher1.setPublisherId(1); 56 publisher1.setPublisherId(1);
54 publisherVersion.setPublisher(publisher); 57 publisherVersion.setPublisher(publisher);
...@@ -58,10 +61,13 @@ public class ListPublisherVersionsViewTest { ...@@ -58,10 +61,13 @@ public class ListPublisherVersionsViewTest {
58 publisherVersions = new ArrayList<PublisherVersion>(); 61 publisherVersions = new ArrayList<PublisherVersion>();
59 publisherVersions.add(publisherVersion); 62 publisherVersions.add(publisherVersion);
60 publisherVersions.add(publisherVersion1); 63 publisherVersions.add(publisherVersion1);
64 + publisherAction = new PublisherAction();
61 65
62 // Mock 66 // Mock
63 when(publisherService.getAllPublisherVersions()).thenReturn(publisherVersions); 67 when(publisherService.getAllPublisherVersions()).thenReturn(publisherVersions);
64 listPublisherVersionsView = new ListPublisherVersionsView(publisherService); 68 listPublisherVersionsView = new ListPublisherVersionsView(publisherService);
69 + when(publisherService.getLastValidate(publisher)).thenReturn(publisherAction);
70 + when(publisherService.getLastValidate(publisher1)).thenReturn(null);
65 71
66 } 72 }
67 73
...@@ -72,7 +78,7 @@ public class ListPublisherVersionsViewTest { ...@@ -72,7 +78,7 @@ public class ListPublisherVersionsViewTest {
72 listPublisherVersionsView.setView(); 78 listPublisherVersionsView.setView();
73 Mockito.verify(publisherService).getAllPublisherVersions(); 79 Mockito.verify(publisherService).getAllPublisherVersions();
74 assertThat(listPublisherVersionsView.isViewAll()).isTrue(); 80 assertThat(listPublisherVersionsView.isViewAll()).isTrue();
75 - assertThat(listPublisherVersionsView.getPublisherVersions()).isEqualTo(this.publisherVersions); 81 + assertThat(listPublisherVersionsView.getPublisherVersions()).isEqualTo(publisherVersions);
76 } 82 }
77 83
78 @Test 84 @Test
...@@ -82,7 +88,7 @@ public class ListPublisherVersionsViewTest { ...@@ -82,7 +88,7 @@ public class ListPublisherVersionsViewTest {
82 listPublisherVersionsView.setView(); 88 listPublisherVersionsView.setView();
83 Mockito.verify(publisherService).getAllPublisherVersions(); 89 Mockito.verify(publisherService).getAllPublisherVersions();
84 assertThat(listPublisherVersionsView.isViewAll()).isFalse(); 90 assertThat(listPublisherVersionsView.isViewAll()).isFalse();
85 - assertThat(listPublisherVersionsView.getPublisherVersions()).containsExactly(this.publisherVersion1); 91 + assertThat(listPublisherVersionsView.getPublisherVersions()).containsExactly(publisherVersion1);
86 } 92 }
87 93
88 @Test 94 @Test
...@@ -92,4 +98,16 @@ public class ListPublisherVersionsViewTest { ...@@ -92,4 +98,16 @@ public class ListPublisherVersionsViewTest {
92 listPublisherVersionsView.validate(publisherVersion2); 98 listPublisherVersionsView.validate(publisherVersion2);
93 Mockito.verify(publisherService).validatePublisherVersion(publisherVersion2); 99 Mockito.verify(publisherService).validatePublisherVersion(publisherVersion2);
94 } 100 }
101 +
102 + @Test
103 + @DisplayName("Récupération effective dernière validation d'un éditeur")
104 + public void testGetLastValidate() {
105 + assertThat(listPublisherVersionsView.getLastValidate(publisher)).isEqualTo(publisherAction);
106 + }
107 +
108 + @Test
109 + @DisplayName("Échec de récupération de dernière validation d'un éditeur")
110 + public void testGetLastValidateNull() {
111 + assertThat(listPublisherVersionsView.getLastValidate(publisher1)).isNull();
112 + }
95 } 113 }
...\ No newline at end of file ...\ No newline at end of file
......