Jean-Francois Leveque

https://tree.taiga.io/project/jr-utily-grog-v3/us/107 Visualisation des actions …

…à partir de la version
https://tree.taiga.io/project/jr-utily-grog-v3/us/122 Retirer les noms des colonnes extérieures à l'objet
https://tree.taiga.io/project/jr-utily-grog-v3/us/127 Uniformiser les tests en mode "specification dans les tests"
......@@ -25,4 +25,5 @@ public interface PublisherService {
PublisherAction getLastValidate(Publisher publisher);
List<PublisherAction> getAllPublisherActions();
List<PublisherAction> getAllPublisherVersionActions(PublisherVersion publisherVersion);
}
......
package org.legrog.web.publisher;
import org.legrog.entities.PublisherVersion;
import org.legrog.entities.*;
import org.legrog.web.xyz.SharedService;
import org.legrog.entities.Country;
import org.legrog.entities.Publisher;
import org.legrog.entities.Person;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -54,6 +51,8 @@ public class PublisherVersionView implements Serializable {
private List<Country> availableCountries;
private List<PublisherAction> publisherActions;
@Inject
public PublisherVersionView(PublisherService publisherService, SharedService sharedService) {
this.publisherService = publisherService;
......@@ -176,6 +175,7 @@ public class PublisherVersionView implements Serializable {
if (publisherVersionId != 0) {
publisherVersion = publisherService.getPublisherVersion(publisherVersionId);
publisherActions = publisherService.getAllPublisherVersionActions(publisherVersion);
}
if (publisherVersion != null) {
......@@ -360,4 +360,8 @@ public class PublisherVersionView implements Serializable {
public void setPublisher(Publisher publisher) {
this.publisher = publisher;
}
public List<PublisherAction> getPublisherActions() {
return publisherActions;
}
}
......
......@@ -29,26 +29,26 @@
<p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p>
<h:dataTable value="#{listPublisherVersionsView.publisherVersions}" var="version">
<h:column>
<f:facet name="header">Visualiser ou Modifier</f:facet>
<f:facet name="header"/>
<a jsf:outcome="publisherVersion">Visualiser ou Modifier Version
<f:param name="publisherVersionId" value="#{version.publisherVersionId}"/>
</a>
</h:column>
<h:column rendered="#{listPublisherVersionsView.viewAll}">
<f:facet name="header">Editeur</f:facet>
<f:facet name="header"/>
<a jsf:outcome="listPublisherVersions">Visualiser ou valider version éditeur
<f:param name="publisherId" value="#{version.publisher.publisherId}"/>
</a>
</h:column>
<h:column>
<f:facet name="header">Actions</f:facet>
<f:facet name="header"/>
<p jsf:rendered="#{version.publisher.actions.size() == 0}">Aucune action à lister</p>
<a jsf:outcome="listPublisherActions" jsf:rendered="#{version.publisher.actions.size() > 0}">Voir les actions
<f:param name="publisherId" value="#{version.publisher.publisherId}"/>
</a>
</h:column>
<h:column>
<f:facet name="header">Valide</f:facet>
<f:facet name="header"/>
<p jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">Validé</p>
<p jsf:rendered="#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}">Non validé</p>
<!-- https://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/ f:param, problème avec Method expression -->
......@@ -58,6 +58,18 @@
</form>
</h:column>
<h:column>
<f:facet name="header"/>
<div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionAuthor.displayName}
</div>
</h:column>
<h:column>
<f:facet name="header"/>
<div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionDatetime}
</div>
</h:column>
<h:column>
<f:facet name="header">Name</f:facet>
${version.publisherName}
</h:column>
......@@ -97,18 +109,6 @@
<f:facet name="header">Version Datetime</f:facet>
${version.publisherVersionDatetime}
</h:column>
<h:column>
<f:facet name="header">Validation author</f:facet>
<div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionAuthor.displayName}
</div>
</h:column>
<h:column>
<f:facet name="header">Validation Datetime</f:facet>
<div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionDatetime}
</div>
</h:column>
</h:dataTable>
</body>
</html>
\ No newline at end of file
......
......@@ -69,5 +69,21 @@
<button jsf:rendered="#{publisherVersionView.editMode}" jsf:action="#{publisherVersionView.cancel}">Cancel</button>
</h:panelGrid>
</form>
<h:dataTable value="#{publisherVersionView.publisherActions}" var="action">
<h:column>
<f:facet name="header"/>
${action.actionType.name()}
</h:column>
<h:column>
<f:facet name="header"/>
${action.publisherActionAuthor.displayName}
</h:column>
<h:column>
<f:facet name="header"/>
${action.publisherActionDatetime}
</h:column>
</h:dataTable>
</body>
</html>
\ No newline at end of file
......
......@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(JUnitPlatform.class)
@ExtendWith(MockitoExtension.class)
@DisplayName("Visualisation d'actions sur éditeur")
@DisplayName("Shows publisher actions")
public class ListPublisherActionsViewTest {
ListPublisherActionsView listPublisherActionsView;
......
......@@ -28,7 +28,7 @@ import static org.mockito.Mockito.*;
*/
@RunWith(JUnitPlatform.class)
@ExtendWith(MockitoExtension.class)
@DisplayName("Listes de versions d'éditeurs")
@DisplayName("Shows lists of publisher versions, permits validation of one and retrieves last validation of one")
public class ListPublisherVersionsViewTest {
Logger logger = LoggerFactory.getLogger(getClass());
......@@ -76,7 +76,7 @@ public class ListPublisherVersionsViewTest {
}
@Test
@DisplayName("Liste complète")
@DisplayName("List of all versions")
public void testSetViewAll() {
listPublisherVersionsView.setPublisherId(null);
listPublisherVersionsView.setView();
......@@ -86,7 +86,7 @@ public class ListPublisherVersionsViewTest {
}
@Test
@DisplayName("Liste pour un éditeur")
@DisplayName("List of a pulisher's versions")
public void testSetViewNotAllAlsoTestingFilterOnId() {
listPublisherVersionsView.setPublisherId(1);
listPublisherVersionsView.setView();
......@@ -96,7 +96,7 @@ public class ListPublisherVersionsViewTest {
}
@Test
@DisplayName("Test de l'appel de validation")
@DisplayName("Validates a publisher version using service")
public void testValidate() {
listPublisherVersionsView.setPublisherId(0);
listPublisherVersionsView.validate(publisherVersion2);
......@@ -104,13 +104,13 @@ public class ListPublisherVersionsViewTest {
}
@Test
@DisplayName("Récupération effective dernière validation d'un éditeur")
@DisplayName("Gets last validate for a publisher")
public void testGetLastValidate() {
assertThat(listPublisherVersionsView.getLastValidate(publisher)).isEqualTo(publisherAction);
}
@Test
@DisplayName("Échec de récupération de dernière validation d'un éditeur")
@DisplayName("Returns null when publisher has no validate action")
public void testGetLastValidateNull() {
assertThat(listPublisherVersionsView.getLastValidate(publisher1)).isNull();
}
......
......@@ -25,7 +25,7 @@ import static org.mockito.Mockito.*;
*/
@RunWith(JUnitPlatform.class)
@ExtendWith(MockitoExtension.class)
@DisplayName("Couche service de gestion d'éditeur")
@DisplayName("Service layer for all publisher-related data")
public class PublisherServiceSpringTest {
PublisherServiceSpring publisherServiceSpring;
......@@ -50,7 +50,7 @@ public class PublisherServiceSpringTest {
this.publisherRepository = publisherRepository;
}
@DisplayName("Test ajout nouvel éditeur")
@DisplayName("Adds a new publisher by setting it and its first version up and saving both")
@Test
public void testAddNewPublisher(@Mock PublisherVersionRepository publisherVersionRepository) {
publisherServiceSpring.addNewPublisher(publisherVersion);
......@@ -61,7 +61,7 @@ public class PublisherServiceSpringTest {
verify(publisherVersionRepository).save(publisherVersion);
}
@DisplayName("Test ajout nouvelle version éditeur")
@DisplayName("Adds a new version of a publisher, setting it up, attaching it to publisher and saving both")
@Test
public void testAddVersionToPublisher(@Mock PublisherRepository publisherRepository,
@Mock PublisherVersionRepository publisherVersionRepository) {
......@@ -74,7 +74,7 @@ public class PublisherServiceSpringTest {
verify(publisherVersionRepository).save(publisherVersion1);
}
@DisplayName("Test validation version éditeur")
@DisplayName("Validates a version by creating a VALIDATE action that links to publisher and version, sets versions in publisher's validated and saves it")
@Test
public void testValidateVersion(@Mock PublisherActionRepository publisherActionRepository) {
Set<PublisherVersion> publisherVersions;
......
......@@ -29,7 +29,7 @@ import static org.mockito.Mockito.when;
*/
@RunWith(JUnitPlatform.class)
@ExtendWith(MockitoExtension.class)
@DisplayName("Création et visualisation de version d'éditeur")
@DisplayName("Creates new versions of a publisher, and shows existing with history of actions on it")
public class PublisherVersionViewTest {
Logger logger = LoggerFactory.getLogger(getClass());
......@@ -70,7 +70,7 @@ public class PublisherVersionViewTest {
assertThat(publisherVersionView).isNotNull();
}
@DisplayName("Passage en mode édition")
@DisplayName("Switches to edit mode")
@Test
public void testEdit() {
assertThat(publisherVersionView.isEditMode()).isFalse();
......@@ -78,7 +78,7 @@ public class PublisherVersionViewTest {
assertThat(publisherVersionView.isEditMode()).isTrue();
}
@DisplayName("Annulation des données saisie pour un nouvel éditeur")
@DisplayName("Cleans new form data on cancel")
@Test
public void testCancelNewPublisher() {
publisherVersionView.setNewPublisher(true);
......@@ -99,7 +99,7 @@ public class PublisherVersionViewTest {
assertThat(publisherVersionView.isEditMode()).isTrue();
}
@DisplayName("Annulation de saisie de nouvelle version d'un éditeur existant")
@DisplayName("Reverts to original data of version on canceled update")
@Test
public void testCancelNewVersionOfPublisher() {
publisherVersionView.setNewPublisher(false);
......@@ -134,34 +134,48 @@ public class PublisherVersionViewTest {
}
@Test
@DisplayName("Test de la fonction de chargement des valeurs initiales pour leur affichage")
public void testLoadData() {
publisherVersionView.setNewPublisher(true);
publisherVersionView.setPublisherVersionId(1);
publisherVersionView.loadData();
assertThat(publisherVersionView.getPublisherName()).isEqualTo("A");
assertThat(publisherVersionView.getPublisherStreetAddress()).isEqualTo("B");
assertThat(publisherVersionView.getPublisherPostalCode()).isEqualTo("C");
assertThat(publisherVersionView.getPublisherPostOfficeBoxNumber()).isEqualTo("D");
assertThat(publisherVersionView.getPublisherAddressRegion()).isEqualTo("E");
assertThat(publisherVersionView.getPublisherAddressLocality()).isEqualTo("F");
assertThat(publisherVersionView.getPublisherTelephone()).isEqualTo("G");
assertThat(publisherVersionView.getPublisherEmail()).isEqualTo("H");
assertThat(publisherVersionView.getPublisherURL()).isEqualTo("I");
assertThat(publisherVersionView.isPublisherActive()).isTrue();
assertThat(publisherVersionView.getPublisherHistory()).isEqualTo("J");
assertThat(publisherVersionView.isNewPublisher()).isFalse();
}
@Nested
@DisplayName("loadData method")
class loadDataTests{
@Test
@DisplayName("Loads all actions on it")
public void testLoadActions(@Mock PublisherService publisherService) {
publisherVersionView.setPublisherVersionId(1);
publisherVersionView.loadData();
Mockito.verify(publisherService).getAllPublisherVersionActions(publisherVersion);
}
@Test
@DisplayName("Loads data from existing version into the form")
public void testLoadData() {
publisherVersionView.setNewPublisher(true);
publisherVersionView.setPublisherVersionId(1);
publisherVersionView.loadData();
assertThat(publisherVersionView.getPublisherName()).isEqualTo("A");
assertThat(publisherVersionView.getPublisherStreetAddress()).isEqualTo("B");
assertThat(publisherVersionView.getPublisherPostalCode()).isEqualTo("C");
assertThat(publisherVersionView.getPublisherPostOfficeBoxNumber()).isEqualTo("D");
assertThat(publisherVersionView.getPublisherAddressRegion()).isEqualTo("E");
assertThat(publisherVersionView.getPublisherAddressLocality()).isEqualTo("F");
assertThat(publisherVersionView.getPublisherTelephone()).isEqualTo("G");
assertThat(publisherVersionView.getPublisherEmail()).isEqualTo("H");
assertThat(publisherVersionView.getPublisherURL()).isEqualTo("I");
assertThat(publisherVersionView.isPublisherActive()).isTrue();
assertThat(publisherVersionView.getPublisherHistory()).isEqualTo("J");
assertThat(publisherVersionView.isNewPublisher()).isFalse();
}
@Test
@DisplayName("Sets default value in form for new version")
public void testLoadDataEmpty() {
publisherVersionView.setNewPublisher(false);
publisherVersionView.setPublisherVersionId(0);
publisherVersionView.loadData();
assertThat(publisherVersionView.isNewPublisher()).isTrue();
assertThat(publisherVersionView.isEditMode()).isTrue();
}
@Test
@DisplayName("Test initialisation formulaire pour nouvel éditeur")
public void testLoadDataEmpty() {
publisherVersionView.setNewPublisher(false);
publisherVersionView.setPublisherVersionId(0);
publisherVersionView.loadData();
assertThat(publisherVersionView.isNewPublisher()).isTrue();
assertThat(publisherVersionView.isEditMode()).isTrue();
}
@Nested
......@@ -271,7 +285,7 @@ public class PublisherVersionViewTest {
publisherVersionView.update();
}
@DisplayName("doit ajouter une nouvelle version à un éditeur")
@DisplayName("should add a new version to apublisher")
@Test
public void shouldAddNewVersion(@Mock PublisherService publisherService) {
Mockito.verify(publisherService).addVersionToPublisher(publisherArgumentCaptor.capture(), publisherVersionArgumentCaptor.capture());
......