Jean-Francois Leveque

Passage en when/should et ajout d'assertions.

......@@ -37,12 +37,16 @@ public class PublisherVersionViewTest {
private PublisherVersionView publisherVersionView;
private PublisherVersion publisherVersion;
private PublisherService publisherService;
private SharedService sharedService;
@Mock
PublisherVersion publisherVersionMock;
@BeforeEach
public void setUp(@Mock PublisherService publisherService, @Mock SharedService sharedService) throws Exception {
this.publisherService = publisherService;
this.sharedService = sharedService;
publisherVersionView = new PublisherVersionView(publisherService, sharedService);
publisherVersionView.setEditMode(false);
publisherVersionView.setNewPublisher(false);
......@@ -66,12 +70,14 @@ public class PublisherVersionViewTest {
}
@Test
@DisplayName("depends on Shared Service and Publisher Service")
@DisplayName("when constructed, should have right dependencies : Shared Service and Publisher Service")
public void testDependencies() {
assertThat(publisherVersionView).isNotNull();
assertThat(publisherVersionView.publisherService).isEqualTo(publisherService);
assertThat(publisherVersionView.sharedService).isEqualTo(sharedService);
}
@DisplayName("Switches to edit mode")
@DisplayName("when edit is clicked, should switch to edit mode")
@Test
public void testEdit() {
assertThat(publisherVersionView.isEditMode()).isFalse();
......@@ -79,7 +85,7 @@ public class PublisherVersionViewTest {
assertThat(publisherVersionView.isEditMode()).isTrue();
}
@DisplayName("Cleans new form data on cancel")
@DisplayName("when cancel is clicked for an new publisher, should clean new form data and switch to non-edit mode")
@Test
public void testCancelNewPublisher() {
publisherVersionView.setNewPublisher(true);
......@@ -99,7 +105,7 @@ public class PublisherVersionViewTest {
assertThat(publisherVersionView.isEditMode()).isTrue();
}
@DisplayName("Reverts to original data of version on canceled update")
@DisplayName("whan cancel is clicked for a publisher update, should revert to original data and switch to non-edit mode")
@Test
public void testCancelNewVersionOfPublisher() {
publisherVersionView.setNewPublisher(false);
......@@ -146,7 +152,7 @@ public class PublisherVersionViewTest {
}
@Test
@DisplayName("Loads data from existing version into the form")
@DisplayName("when called for existing publisher, should get the rigtht data into the form")
public void testLoadData() {
publisherVersionView.setNewPublisher(true);
publisherVersionView.setPublisherVersionId(1);
......@@ -165,7 +171,7 @@ public class PublisherVersionViewTest {
}
@Test
@DisplayName("Sets default value in form for new version")
@DisplayName("when called for new publisher, should set form for new version")
public void testLoadDataEmpty() {
publisherVersionView.setNewPublisher(false);
publisherVersionView.setPublisherVersionId(0);
......@@ -298,7 +304,7 @@ public class PublisherVersionViewTest {
publisherVersionView.update();
}
@DisplayName("should add a new version to apublisher")
@DisplayName("should add a new version to a publisher")
@Test
public void shouldAddNewVersion(@Mock PublisherService publisherService) {
Mockito.verify(publisherService).addVersionToPublisher(publisherArgumentCaptor.capture(), publisherVersionArgumentCaptor.capture());
......@@ -366,7 +372,7 @@ public class PublisherVersionViewTest {
publisherVersionView.add();
}
@DisplayName("should create in the application a new publisher with its first version")
@DisplayName("should create a new publisher in the application with its first version")
@Test
public void shouldSave(@Mock PublisherService publisherService) {
Mockito.verify(publisherService).addNewPublisher(publisherVersionArgumentCaptor.capture());
......