Jean-Francois Leveque

Test de la méthode derrière le bouton save et simplification code de test.

......@@ -83,19 +83,6 @@ public class PublisherVersionViewTest {
public void testCancelNewPublisher() {
publisherVersionView.setNewPublisher(true);
publisherVersionView.setPublisherName("A");
publisherVersionView.setPublisherStreetAddress("B");
publisherVersionView.setPublisherPostalCode("C");
publisherVersionView.setPublisherPostOfficeBoxNumber("D");
publisherVersionView.setPublisherAddressRegion("E");
publisherVersionView.setPublisherAddressLocality("F");
publisherVersionView.setPublisherAddressCountry(new Country());
publisherVersionView.setPublisherTelephone("G");
publisherVersionView.setPublisherEmail("H");
publisherVersionView.setPublisherURL("I");
publisherVersionView.setPublisherActive(true);
publisherVersionView.setPublisherHistory("J");
publisherVersionView.cancel();
assertThat(publisherVersionView.getPublisherName()).isNull();
......@@ -178,6 +165,49 @@ public class PublisherVersionViewTest {
}
@Nested
@DisplayName("save method")
class saveTests{
PublisherVersionView publisherVersionViewForSave;
public boolean addCalled = false;
public boolean updateCalled = false;
@BeforeEach
@DisplayName("Given some test reimplementation")
public void given() {
publisherVersionViewForSave = new PublisherVersionView() {
@Override
public void add() {
addCalled = true;
}
@Override
public void update() {
updateCalled = true;
}
};
}
@Test
@DisplayName("Test should call add on new publisher")
public void testSaveAdd() {
publisherVersionViewForSave.setNewPublisher(true);
publisherVersionViewForSave.save();
assertThat(addCalled).isTrue();
}
@Test
@DisplayName("Test should call update on old publisher")
public void testSaveUpdate() {
publisherVersionViewForSave.setNewPublisher(false);
publisherVersionViewForSave.save();
assertThat(updateCalled).isTrue();
}
}
@Nested
@DisplayName("post construct method")
class init {
......@@ -288,7 +318,6 @@ public class PublisherVersionViewTest {
publisherVersionView.setPublisherURL("I");
publisherVersionView.setPublisherActive(true);
publisherVersionView.setPublisherHistory("J");
// WHY, JR ?
publisherVersionView.setPublisher(publisherMock);
}
......