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 { ...@@ -25,4 +25,5 @@ public interface PublisherService {
25 PublisherAction getLastValidate(Publisher publisher); 25 PublisherAction getLastValidate(Publisher publisher);
26 26
27 List<PublisherAction> getAllPublisherActions(); 27 List<PublisherAction> getAllPublisherActions();
28 + List<PublisherAction> getAllPublisherVersionActions(PublisherVersion publisherVersion);
28 } 29 }
......
1 package org.legrog.web.publisher; 1 package org.legrog.web.publisher;
2 2
3 -import org.legrog.entities.PublisherVersion; 3 +import org.legrog.entities.*;
4 import org.legrog.web.xyz.SharedService; 4 import org.legrog.web.xyz.SharedService;
5 -import org.legrog.entities.Country;
6 -import org.legrog.entities.Publisher;
7 -import org.legrog.entities.Person;
8 import org.slf4j.Logger; 5 import org.slf4j.Logger;
9 import org.slf4j.LoggerFactory; 6 import org.slf4j.LoggerFactory;
10 7
...@@ -54,6 +51,8 @@ public class PublisherVersionView implements Serializable { ...@@ -54,6 +51,8 @@ public class PublisherVersionView implements Serializable {
54 51
55 private List<Country> availableCountries; 52 private List<Country> availableCountries;
56 53
54 + private List<PublisherAction> publisherActions;
55 +
57 @Inject 56 @Inject
58 public PublisherVersionView(PublisherService publisherService, SharedService sharedService) { 57 public PublisherVersionView(PublisherService publisherService, SharedService sharedService) {
59 this.publisherService = publisherService; 58 this.publisherService = publisherService;
...@@ -176,6 +175,7 @@ public class PublisherVersionView implements Serializable { ...@@ -176,6 +175,7 @@ public class PublisherVersionView implements Serializable {
176 175
177 if (publisherVersionId != 0) { 176 if (publisherVersionId != 0) {
178 publisherVersion = publisherService.getPublisherVersion(publisherVersionId); 177 publisherVersion = publisherService.getPublisherVersion(publisherVersionId);
178 + publisherActions = publisherService.getAllPublisherVersionActions(publisherVersion);
179 } 179 }
180 180
181 if (publisherVersion != null) { 181 if (publisherVersion != null) {
...@@ -360,4 +360,8 @@ public class PublisherVersionView implements Serializable { ...@@ -360,4 +360,8 @@ public class PublisherVersionView implements Serializable {
360 public void setPublisher(Publisher publisher) { 360 public void setPublisher(Publisher publisher) {
361 this.publisher = publisher; 361 this.publisher = publisher;
362 } 362 }
363 +
364 + public List<PublisherAction> getPublisherActions() {
365 + return publisherActions;
366 + }
363 } 367 }
......
...@@ -29,26 +29,26 @@ ...@@ -29,26 +29,26 @@
29 <p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p> 29 <p jsf:rendered="#{listPublisherVersionsView.publisherVersions.isEmpty()}">Liste des révisions est vide</p>
30 <h:dataTable value="#{listPublisherVersionsView.publisherVersions}" var="version"> 30 <h:dataTable value="#{listPublisherVersionsView.publisherVersions}" var="version">
31 <h:column> 31 <h:column>
32 - <f:facet name="header">Visualiser ou Modifier</f:facet> 32 + <f:facet name="header"/>
33 <a jsf:outcome="publisherVersion">Visualiser ou Modifier Version 33 <a jsf:outcome="publisherVersion">Visualiser ou Modifier Version
34 <f:param name="publisherVersionId" value="#{version.publisherVersionId}"/> 34 <f:param name="publisherVersionId" value="#{version.publisherVersionId}"/>
35 </a> 35 </a>
36 </h:column> 36 </h:column>
37 <h:column rendered="#{listPublisherVersionsView.viewAll}"> 37 <h:column rendered="#{listPublisherVersionsView.viewAll}">
38 - <f:facet name="header">Editeur</f:facet> 38 + <f:facet name="header"/>
39 <a jsf:outcome="listPublisherVersions">Visualiser ou valider version éditeur 39 <a jsf:outcome="listPublisherVersions">Visualiser ou valider version éditeur
40 <f:param name="publisherId" value="#{version.publisher.publisherId}"/> 40 <f:param name="publisherId" value="#{version.publisher.publisherId}"/>
41 </a> 41 </a>
42 </h:column> 42 </h:column>
43 <h:column> 43 <h:column>
44 - <f:facet name="header">Actions</f:facet> 44 + <f:facet name="header"/>
45 <p jsf:rendered="#{version.publisher.actions.size() == 0}">Aucune action à lister</p> 45 <p jsf:rendered="#{version.publisher.actions.size() == 0}">Aucune action à lister</p>
46 <a jsf:outcome="listPublisherActions" jsf:rendered="#{version.publisher.actions.size() > 0}">Voir les actions 46 <a jsf:outcome="listPublisherActions" jsf:rendered="#{version.publisher.actions.size() > 0}">Voir les actions
47 <f:param name="publisherId" value="#{version.publisher.publisherId}"/> 47 <f:param name="publisherId" value="#{version.publisher.publisherId}"/>
48 </a> 48 </a>
49 </h:column> 49 </h:column>
50 <h:column> 50 <h:column>
51 - <f:facet name="header">Valide</f:facet> 51 + <f:facet name="header"/>
52 <p jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">Validé</p> 52 <p jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">Validé</p>
53 <p jsf:rendered="#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}">Non validé</p> 53 <p jsf:rendered="#{listPublisherVersionsView.viewAll and version.publisherVersionId != version.publisher.validatedVersion.publisherVersionId}">Non validé</p>
54 <!-- https://www.mkyong.com/jsf2/4-ways-to-pass-parameter-from-jsf-page-to-backing-bean/ f:param, problème avec Method expression --> 54 <!-- 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 @@ ...@@ -58,6 +58,18 @@
58 </form> 58 </form>
59 </h:column> 59 </h:column>
60 <h:column> 60 <h:column>
61 + <f:facet name="header"/>
62 + <div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
63 + ${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionAuthor.displayName}
64 + </div>
65 + </h:column>
66 + <h:column>
67 + <f:facet name="header"/>
68 + <div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
69 + ${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionDatetime}
70 + </div>
71 + </h:column>
72 + <h:column>
61 <f:facet name="header">Name</f:facet> 73 <f:facet name="header">Name</f:facet>
62 ${version.publisherName} 74 ${version.publisherName}
63 </h:column> 75 </h:column>
...@@ -97,18 +109,6 @@ ...@@ -97,18 +109,6 @@
97 <f:facet name="header">Version Datetime</f:facet> 109 <f:facet name="header">Version Datetime</f:facet>
98 ${version.publisherVersionDatetime} 110 ${version.publisherVersionDatetime}
99 </h:column> 111 </h:column>
100 - <h:column>
101 - <f:facet name="header">Validation author</f:facet>
102 - <div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
103 - ${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionAuthor.displayName}
104 - </div>
105 - </h:column>
106 - <h:column>
107 - <f:facet name="header">Validation Datetime</f:facet>
108 - <div jsf:rendered="#{version.publisherVersionId == version.publisher.validatedVersion.publisherVersionId}">
109 - ${listPublisherVersionsView.getLastValidate(version.publisher).publisherActionDatetime}
110 - </div>
111 - </h:column>
112 </h:dataTable> 112 </h:dataTable>
113 </body> 113 </body>
114 </html> 114 </html>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -69,5 +69,21 @@ ...@@ -69,5 +69,21 @@
69 <button jsf:rendered="#{publisherVersionView.editMode}" jsf:action="#{publisherVersionView.cancel}">Cancel</button> 69 <button jsf:rendered="#{publisherVersionView.editMode}" jsf:action="#{publisherVersionView.cancel}">Cancel</button>
70 </h:panelGrid> 70 </h:panelGrid>
71 </form> 71 </form>
72 +
73 +<h:dataTable value="#{publisherVersionView.publisherActions}" var="action">
74 + <h:column>
75 + <f:facet name="header"/>
76 + ${action.actionType.name()}
77 + </h:column>
78 + <h:column>
79 + <f:facet name="header"/>
80 + ${action.publisherActionAuthor.displayName}
81 + </h:column>
82 + <h:column>
83 + <f:facet name="header"/>
84 + ${action.publisherActionDatetime}
85 + </h:column>
86 +</h:dataTable>
87 +
72 </body> 88 </body>
73 </html> 89 </html>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
26 */ 26 */
27 @RunWith(JUnitPlatform.class) 27 @RunWith(JUnitPlatform.class)
28 @ExtendWith(MockitoExtension.class) 28 @ExtendWith(MockitoExtension.class)
29 -@DisplayName("Visualisation d'actions sur éditeur") 29 +@DisplayName("Shows publisher actions")
30 public class ListPublisherActionsViewTest { 30 public class ListPublisherActionsViewTest {
31 ListPublisherActionsView listPublisherActionsView; 31 ListPublisherActionsView listPublisherActionsView;
32 32
......
...@@ -28,7 +28,7 @@ import static org.mockito.Mockito.*; ...@@ -28,7 +28,7 @@ import static org.mockito.Mockito.*;
28 */ 28 */
29 @RunWith(JUnitPlatform.class) 29 @RunWith(JUnitPlatform.class)
30 @ExtendWith(MockitoExtension.class) 30 @ExtendWith(MockitoExtension.class)
31 -@DisplayName("Listes de versions d'éditeurs") 31 +@DisplayName("Shows lists of publisher versions, permits validation of one and retrieves last validation of one")
32 public class ListPublisherVersionsViewTest { 32 public class ListPublisherVersionsViewTest {
33 Logger logger = LoggerFactory.getLogger(getClass()); 33 Logger logger = LoggerFactory.getLogger(getClass());
34 34
...@@ -76,7 +76,7 @@ public class ListPublisherVersionsViewTest { ...@@ -76,7 +76,7 @@ public class ListPublisherVersionsViewTest {
76 } 76 }
77 77
78 @Test 78 @Test
79 - @DisplayName("Liste complète") 79 + @DisplayName("List of all versions")
80 public void testSetViewAll() { 80 public void testSetViewAll() {
81 listPublisherVersionsView.setPublisherId(null); 81 listPublisherVersionsView.setPublisherId(null);
82 listPublisherVersionsView.setView(); 82 listPublisherVersionsView.setView();
...@@ -86,7 +86,7 @@ public class ListPublisherVersionsViewTest { ...@@ -86,7 +86,7 @@ public class ListPublisherVersionsViewTest {
86 } 86 }
87 87
88 @Test 88 @Test
89 - @DisplayName("Liste pour un éditeur") 89 + @DisplayName("List of a pulisher's versions")
90 public void testSetViewNotAllAlsoTestingFilterOnId() { 90 public void testSetViewNotAllAlsoTestingFilterOnId() {
91 listPublisherVersionsView.setPublisherId(1); 91 listPublisherVersionsView.setPublisherId(1);
92 listPublisherVersionsView.setView(); 92 listPublisherVersionsView.setView();
...@@ -96,7 +96,7 @@ public class ListPublisherVersionsViewTest { ...@@ -96,7 +96,7 @@ public class ListPublisherVersionsViewTest {
96 } 96 }
97 97
98 @Test 98 @Test
99 - @DisplayName("Test de l'appel de validation") 99 + @DisplayName("Validates a publisher version using service")
100 public void testValidate() { 100 public void testValidate() {
101 listPublisherVersionsView.setPublisherId(0); 101 listPublisherVersionsView.setPublisherId(0);
102 listPublisherVersionsView.validate(publisherVersion2); 102 listPublisherVersionsView.validate(publisherVersion2);
...@@ -104,13 +104,13 @@ public class ListPublisherVersionsViewTest { ...@@ -104,13 +104,13 @@ public class ListPublisherVersionsViewTest {
104 } 104 }
105 105
106 @Test 106 @Test
107 - @DisplayName("Récupération effective dernière validation d'un éditeur") 107 + @DisplayName("Gets last validate for a publisher")
108 public void testGetLastValidate() { 108 public void testGetLastValidate() {
109 assertThat(listPublisherVersionsView.getLastValidate(publisher)).isEqualTo(publisherAction); 109 assertThat(listPublisherVersionsView.getLastValidate(publisher)).isEqualTo(publisherAction);
110 } 110 }
111 111
112 @Test 112 @Test
113 - @DisplayName("Échec de récupération de dernière validation d'un éditeur") 113 + @DisplayName("Returns null when publisher has no validate action")
114 public void testGetLastValidateNull() { 114 public void testGetLastValidateNull() {
115 assertThat(listPublisherVersionsView.getLastValidate(publisher1)).isNull(); 115 assertThat(listPublisherVersionsView.getLastValidate(publisher1)).isNull();
116 } 116 }
......
...@@ -25,7 +25,7 @@ import static org.mockito.Mockito.*; ...@@ -25,7 +25,7 @@ import static org.mockito.Mockito.*;
25 */ 25 */
26 @RunWith(JUnitPlatform.class) 26 @RunWith(JUnitPlatform.class)
27 @ExtendWith(MockitoExtension.class) 27 @ExtendWith(MockitoExtension.class)
28 -@DisplayName("Couche service de gestion d'éditeur") 28 +@DisplayName("Service layer for all publisher-related data")
29 public class PublisherServiceSpringTest { 29 public class PublisherServiceSpringTest {
30 30
31 PublisherServiceSpring publisherServiceSpring; 31 PublisherServiceSpring publisherServiceSpring;
...@@ -50,7 +50,7 @@ public class PublisherServiceSpringTest { ...@@ -50,7 +50,7 @@ public class PublisherServiceSpringTest {
50 this.publisherRepository = publisherRepository; 50 this.publisherRepository = publisherRepository;
51 } 51 }
52 52
53 - @DisplayName("Test ajout nouvel éditeur") 53 + @DisplayName("Adds a new publisher by setting it and its first version up and saving both")
54 @Test 54 @Test
55 public void testAddNewPublisher(@Mock PublisherVersionRepository publisherVersionRepository) { 55 public void testAddNewPublisher(@Mock PublisherVersionRepository publisherVersionRepository) {
56 publisherServiceSpring.addNewPublisher(publisherVersion); 56 publisherServiceSpring.addNewPublisher(publisherVersion);
...@@ -61,7 +61,7 @@ public class PublisherServiceSpringTest { ...@@ -61,7 +61,7 @@ public class PublisherServiceSpringTest {
61 verify(publisherVersionRepository).save(publisherVersion); 61 verify(publisherVersionRepository).save(publisherVersion);
62 } 62 }
63 63
64 - @DisplayName("Test ajout nouvelle version éditeur") 64 + @DisplayName("Adds a new version of a publisher, setting it up, attaching it to publisher and saving both")
65 @Test 65 @Test
66 public void testAddVersionToPublisher(@Mock PublisherRepository publisherRepository, 66 public void testAddVersionToPublisher(@Mock PublisherRepository publisherRepository,
67 @Mock PublisherVersionRepository publisherVersionRepository) { 67 @Mock PublisherVersionRepository publisherVersionRepository) {
...@@ -74,7 +74,7 @@ public class PublisherServiceSpringTest { ...@@ -74,7 +74,7 @@ public class PublisherServiceSpringTest {
74 verify(publisherVersionRepository).save(publisherVersion1); 74 verify(publisherVersionRepository).save(publisherVersion1);
75 } 75 }
76 76
77 - @DisplayName("Test validation version éditeur") 77 + @DisplayName("Validates a version by creating a VALIDATE action that links to publisher and version, sets versions in publisher's validated and saves it")
78 @Test 78 @Test
79 public void testValidateVersion(@Mock PublisherActionRepository publisherActionRepository) { 79 public void testValidateVersion(@Mock PublisherActionRepository publisherActionRepository) {
80 Set<PublisherVersion> publisherVersions; 80 Set<PublisherVersion> publisherVersions;
......
...@@ -29,7 +29,7 @@ import static org.mockito.Mockito.when; ...@@ -29,7 +29,7 @@ import static org.mockito.Mockito.when;
29 */ 29 */
30 @RunWith(JUnitPlatform.class) 30 @RunWith(JUnitPlatform.class)
31 @ExtendWith(MockitoExtension.class) 31 @ExtendWith(MockitoExtension.class)
32 -@DisplayName("Création et visualisation de version d'éditeur") 32 +@DisplayName("Creates new versions of a publisher, and shows existing with history of actions on it")
33 public class PublisherVersionViewTest { 33 public class PublisherVersionViewTest {
34 Logger logger = LoggerFactory.getLogger(getClass()); 34 Logger logger = LoggerFactory.getLogger(getClass());
35 35
...@@ -70,7 +70,7 @@ public class PublisherVersionViewTest { ...@@ -70,7 +70,7 @@ public class PublisherVersionViewTest {
70 assertThat(publisherVersionView).isNotNull(); 70 assertThat(publisherVersionView).isNotNull();
71 } 71 }
72 72
73 - @DisplayName("Passage en mode édition") 73 + @DisplayName("Switches to edit mode")
74 @Test 74 @Test
75 public void testEdit() { 75 public void testEdit() {
76 assertThat(publisherVersionView.isEditMode()).isFalse(); 76 assertThat(publisherVersionView.isEditMode()).isFalse();
...@@ -78,7 +78,7 @@ public class PublisherVersionViewTest { ...@@ -78,7 +78,7 @@ public class PublisherVersionViewTest {
78 assertThat(publisherVersionView.isEditMode()).isTrue(); 78 assertThat(publisherVersionView.isEditMode()).isTrue();
79 } 79 }
80 80
81 - @DisplayName("Annulation des données saisie pour un nouvel éditeur") 81 + @DisplayName("Cleans new form data on cancel")
82 @Test 82 @Test
83 public void testCancelNewPublisher() { 83 public void testCancelNewPublisher() {
84 publisherVersionView.setNewPublisher(true); 84 publisherVersionView.setNewPublisher(true);
...@@ -99,7 +99,7 @@ public class PublisherVersionViewTest { ...@@ -99,7 +99,7 @@ public class PublisherVersionViewTest {
99 assertThat(publisherVersionView.isEditMode()).isTrue(); 99 assertThat(publisherVersionView.isEditMode()).isTrue();
100 } 100 }
101 101
102 - @DisplayName("Annulation de saisie de nouvelle version d'un éditeur existant") 102 + @DisplayName("Reverts to original data of version on canceled update")
103 @Test 103 @Test
104 public void testCancelNewVersionOfPublisher() { 104 public void testCancelNewVersionOfPublisher() {
105 publisherVersionView.setNewPublisher(false); 105 publisherVersionView.setNewPublisher(false);
...@@ -134,8 +134,20 @@ public class PublisherVersionViewTest { ...@@ -134,8 +134,20 @@ public class PublisherVersionViewTest {
134 134
135 } 135 }
136 136
137 + @Nested
138 + @DisplayName("loadData method")
139 + class loadDataTests{
140 +
137 @Test 141 @Test
138 - @DisplayName("Test de la fonction de chargement des valeurs initiales pour leur affichage") 142 + @DisplayName("Loads all actions on it")
143 + public void testLoadActions(@Mock PublisherService publisherService) {
144 + publisherVersionView.setPublisherVersionId(1);
145 + publisherVersionView.loadData();
146 + Mockito.verify(publisherService).getAllPublisherVersionActions(publisherVersion);
147 + }
148 +
149 + @Test
150 + @DisplayName("Loads data from existing version into the form")
139 public void testLoadData() { 151 public void testLoadData() {
140 publisherVersionView.setNewPublisher(true); 152 publisherVersionView.setNewPublisher(true);
141 publisherVersionView.setPublisherVersionId(1); 153 publisherVersionView.setPublisherVersionId(1);
...@@ -155,7 +167,7 @@ public class PublisherVersionViewTest { ...@@ -155,7 +167,7 @@ public class PublisherVersionViewTest {
155 } 167 }
156 168
157 @Test 169 @Test
158 - @DisplayName("Test initialisation formulaire pour nouvel éditeur") 170 + @DisplayName("Sets default value in form for new version")
159 public void testLoadDataEmpty() { 171 public void testLoadDataEmpty() {
160 publisherVersionView.setNewPublisher(false); 172 publisherVersionView.setNewPublisher(false);
161 publisherVersionView.setPublisherVersionId(0); 173 publisherVersionView.setPublisherVersionId(0);
...@@ -164,6 +176,8 @@ public class PublisherVersionViewTest { ...@@ -164,6 +176,8 @@ public class PublisherVersionViewTest {
164 assertThat(publisherVersionView.isEditMode()).isTrue(); 176 assertThat(publisherVersionView.isEditMode()).isTrue();
165 } 177 }
166 178
179 + }
180 +
167 @Nested 181 @Nested
168 @DisplayName("save method") 182 @DisplayName("save method")
169 class saveTests{ 183 class saveTests{
...@@ -271,7 +285,7 @@ public class PublisherVersionViewTest { ...@@ -271,7 +285,7 @@ public class PublisherVersionViewTest {
271 publisherVersionView.update(); 285 publisherVersionView.update();
272 } 286 }
273 287
274 - @DisplayName("doit ajouter une nouvelle version à un éditeur") 288 + @DisplayName("should add a new version to apublisher")
275 @Test 289 @Test
276 public void shouldAddNewVersion(@Mock PublisherService publisherService) { 290 public void shouldAddNewVersion(@Mock PublisherService publisherService) {
277 Mockito.verify(publisherService).addVersionToPublisher(publisherArgumentCaptor.capture(), publisherVersionArgumentCaptor.capture()); 291 Mockito.verify(publisherService).addVersionToPublisher(publisherArgumentCaptor.capture(), publisherVersionArgumentCaptor.capture());
......