Jean-Francois Leveque

Passage en when/should et ajout d'assertions.

...@@ -37,12 +37,16 @@ public class PublisherVersionViewTest { ...@@ -37,12 +37,16 @@ public class PublisherVersionViewTest {
37 private PublisherVersionView publisherVersionView; 37 private PublisherVersionView publisherVersionView;
38 38
39 private PublisherVersion publisherVersion; 39 private PublisherVersion publisherVersion;
40 + private PublisherService publisherService;
41 + private SharedService sharedService;
40 42
41 @Mock 43 @Mock
42 PublisherVersion publisherVersionMock; 44 PublisherVersion publisherVersionMock;
43 45
44 @BeforeEach 46 @BeforeEach
45 public void setUp(@Mock PublisherService publisherService, @Mock SharedService sharedService) throws Exception { 47 public void setUp(@Mock PublisherService publisherService, @Mock SharedService sharedService) throws Exception {
48 + this.publisherService = publisherService;
49 + this.sharedService = sharedService;
46 publisherVersionView = new PublisherVersionView(publisherService, sharedService); 50 publisherVersionView = new PublisherVersionView(publisherService, sharedService);
47 publisherVersionView.setEditMode(false); 51 publisherVersionView.setEditMode(false);
48 publisherVersionView.setNewPublisher(false); 52 publisherVersionView.setNewPublisher(false);
...@@ -66,12 +70,14 @@ public class PublisherVersionViewTest { ...@@ -66,12 +70,14 @@ public class PublisherVersionViewTest {
66 } 70 }
67 71
68 @Test 72 @Test
69 - @DisplayName("depends on Shared Service and Publisher Service") 73 + @DisplayName("when constructed, should have right dependencies : Shared Service and Publisher Service")
70 public void testDependencies() { 74 public void testDependencies() {
71 assertThat(publisherVersionView).isNotNull(); 75 assertThat(publisherVersionView).isNotNull();
76 + assertThat(publisherVersionView.publisherService).isEqualTo(publisherService);
77 + assertThat(publisherVersionView.sharedService).isEqualTo(sharedService);
72 } 78 }
73 79
74 - @DisplayName("Switches to edit mode") 80 + @DisplayName("when edit is clicked, should switch to edit mode")
75 @Test 81 @Test
76 public void testEdit() { 82 public void testEdit() {
77 assertThat(publisherVersionView.isEditMode()).isFalse(); 83 assertThat(publisherVersionView.isEditMode()).isFalse();
...@@ -79,7 +85,7 @@ public class PublisherVersionViewTest { ...@@ -79,7 +85,7 @@ public class PublisherVersionViewTest {
79 assertThat(publisherVersionView.isEditMode()).isTrue(); 85 assertThat(publisherVersionView.isEditMode()).isTrue();
80 } 86 }
81 87
82 - @DisplayName("Cleans new form data on cancel") 88 + @DisplayName("when cancel is clicked for an new publisher, should clean new form data and switch to non-edit mode")
83 @Test 89 @Test
84 public void testCancelNewPublisher() { 90 public void testCancelNewPublisher() {
85 publisherVersionView.setNewPublisher(true); 91 publisherVersionView.setNewPublisher(true);
...@@ -99,7 +105,7 @@ public class PublisherVersionViewTest { ...@@ -99,7 +105,7 @@ public class PublisherVersionViewTest {
99 assertThat(publisherVersionView.isEditMode()).isTrue(); 105 assertThat(publisherVersionView.isEditMode()).isTrue();
100 } 106 }
101 107
102 - @DisplayName("Reverts to original data of version on canceled update") 108 + @DisplayName("whan cancel is clicked for a publisher update, should revert to original data and switch to non-edit mode")
103 @Test 109 @Test
104 public void testCancelNewVersionOfPublisher() { 110 public void testCancelNewVersionOfPublisher() {
105 publisherVersionView.setNewPublisher(false); 111 publisherVersionView.setNewPublisher(false);
...@@ -146,7 +152,7 @@ public class PublisherVersionViewTest { ...@@ -146,7 +152,7 @@ public class PublisherVersionViewTest {
146 } 152 }
147 153
148 @Test 154 @Test
149 - @DisplayName("Loads data from existing version into the form") 155 + @DisplayName("when called for existing publisher, should get the rigtht data into the form")
150 public void testLoadData() { 156 public void testLoadData() {
151 publisherVersionView.setNewPublisher(true); 157 publisherVersionView.setNewPublisher(true);
152 publisherVersionView.setPublisherVersionId(1); 158 publisherVersionView.setPublisherVersionId(1);
...@@ -165,7 +171,7 @@ public class PublisherVersionViewTest { ...@@ -165,7 +171,7 @@ public class PublisherVersionViewTest {
165 } 171 }
166 172
167 @Test 173 @Test
168 - @DisplayName("Sets default value in form for new version") 174 + @DisplayName("when called for new publisher, should set form for new version")
169 public void testLoadDataEmpty() { 175 public void testLoadDataEmpty() {
170 publisherVersionView.setNewPublisher(false); 176 publisherVersionView.setNewPublisher(false);
171 publisherVersionView.setPublisherVersionId(0); 177 publisherVersionView.setPublisherVersionId(0);
...@@ -298,7 +304,7 @@ public class PublisherVersionViewTest { ...@@ -298,7 +304,7 @@ public class PublisherVersionViewTest {
298 publisherVersionView.update(); 304 publisherVersionView.update();
299 } 305 }
300 306
301 - @DisplayName("should add a new version to apublisher") 307 + @DisplayName("should add a new version to a publisher")
302 @Test 308 @Test
303 public void shouldAddNewVersion(@Mock PublisherService publisherService) { 309 public void shouldAddNewVersion(@Mock PublisherService publisherService) {
304 Mockito.verify(publisherService).addVersionToPublisher(publisherArgumentCaptor.capture(), publisherVersionArgumentCaptor.capture()); 310 Mockito.verify(publisherService).addVersionToPublisher(publisherArgumentCaptor.capture(), publisherVersionArgumentCaptor.capture());
...@@ -366,7 +372,7 @@ public class PublisherVersionViewTest { ...@@ -366,7 +372,7 @@ public class PublisherVersionViewTest {
366 publisherVersionView.add(); 372 publisherVersionView.add();
367 } 373 }
368 374
369 - @DisplayName("should create in the application a new publisher with its first version") 375 + @DisplayName("should create a new publisher in the application with its first version")
370 @Test 376 @Test
371 public void shouldSave(@Mock PublisherService publisherService) { 377 public void shouldSave(@Mock PublisherService publisherService) {
372 Mockito.verify(publisherService).addNewPublisher(publisherVersionArgumentCaptor.capture()); 378 Mockito.verify(publisherService).addNewPublisher(publisherVersionArgumentCaptor.capture());
......