Jean-Francois Leveque

Réorganisation des tests (Nested)

package org.legrog.web.publisher;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
......@@ -57,6 +58,10 @@ public class PublisherServiceDefaultTest {
this.publisherRepository = publisherRepository;
}
@Nested
@DisplayName("addNewPublisher method")
class AddNewPublisherTests {
@DisplayName("When a new publisher is added, both Publisher and PublisherVersion should be saved in the right state")
@Test
public void testAddNewPublisher(@Mock PublisherVersionRepository publisherVersionRepository) {
......@@ -68,6 +73,12 @@ public class PublisherServiceDefaultTest {
verify(publisherVersionRepository).save(publisherVersion);
}
}
@Nested
@DisplayName("addVersionToPublisher method")
class AddVersionToPublisherTests {
@DisplayName("When a new version of a publisher is added, setting it up, attaching it to publisher and saving both")
@Test
public void testAddVersionToPublisher(@Mock PublisherRepository publisherRepository,
......@@ -81,6 +92,12 @@ public class PublisherServiceDefaultTest {
verify(publisherVersionRepository).save(publisherVersion1);
}
}
@Nested
@DisplayName("addVersionToPublisher method")
class ValidatePublisherVersionTests {
@DisplayName("When a PublisherVersion is validated, it should be the right one")
@Test
public void testValidateVersionRight() {
......@@ -137,4 +154,6 @@ public class PublisherServiceDefaultTest {
assertThat(publisherAction.getActionType()).isEqualTo(actionType);
}
}
}
......