Showing
2 changed files
with
137 additions
and
0 deletions
... | @@ -81,6 +81,7 @@ public class PublisherVersionView implements Serializable { | ... | @@ -81,6 +81,7 @@ public class PublisherVersionView implements Serializable { |
81 | publisherURL = null; | 81 | publisherURL = null; |
82 | publisherActive = false; | 82 | publisherActive = false; |
83 | publisherHistory = null; | 83 | publisherHistory = null; |
84 | + // Je ne pense pas que la ligne suivante soit nécessaire | ||
84 | publisher = null; | 85 | publisher = null; |
85 | 86 | ||
86 | editMode = true; | 87 | editMode = true; |
... | @@ -329,4 +330,11 @@ public class PublisherVersionView implements Serializable { | ... | @@ -329,4 +330,11 @@ public class PublisherVersionView implements Serializable { |
329 | return editMode; | 330 | return editMode; |
330 | } | 331 | } |
331 | 332 | ||
333 | + public void setEditMode(boolean editMode) { | ||
334 | + this.editMode = editMode; | ||
335 | + } | ||
336 | + | ||
337 | + public void setNewPublisher(boolean newPublisher) { | ||
338 | + this.newPublisher = newPublisher; | ||
339 | + } | ||
332 | } | 340 | } | ... | ... |
1 | +package org.legrog.web.publisher; | ||
2 | + | ||
3 | +import org.junit.Before; | ||
4 | +import org.junit.Test; | ||
5 | +import org.junit.jupiter.api.DisplayName; | ||
6 | +import org.junit.runner.RunWith; | ||
7 | +import org.legrog.entities.Country; | ||
8 | +import org.legrog.entities.Publisher; | ||
9 | +import org.legrog.entities.PublisherVersion; | ||
10 | +import org.mockito.Answers; | ||
11 | +import org.mockito.Mock; | ||
12 | +import org.mockito.runners.MockitoJUnitRunner; | ||
13 | +import org.slf4j.Logger; | ||
14 | +import org.slf4j.LoggerFactory; | ||
15 | + | ||
16 | +import static org.assertj.core.api.Assertions.assertThat; | ||
17 | +import static org.mockito.Mockito.when; | ||
18 | + | ||
19 | +/** | ||
20 | + * Classe testant PublisherVersionView. | ||
21 | + */ | ||
22 | +@RunWith(MockitoJUnitRunner.class) | ||
23 | +@DisplayName("Création et visualisation de version d'éditeur") | ||
24 | +public class PublisherVersionViewTest { | ||
25 | + Logger logger = LoggerFactory.getLogger(getClass()); | ||
26 | + | ||
27 | + private PublisherVersionView publisherVersionView; | ||
28 | + | ||
29 | + @Mock(answer = Answers.RETURNS_DEEP_STUBS) | ||
30 | + private PublisherService publisherService; | ||
31 | + | ||
32 | + private PublisherVersion publisherVersion; | ||
33 | + | ||
34 | + @Before | ||
35 | + public void setUp() { | ||
36 | + publisherVersionView = new PublisherVersionView(); | ||
37 | + publisherVersionView.setEditMode(false); | ||
38 | + publisherVersionView.setNewPublisher(false); | ||
39 | + | ||
40 | + publisherVersion = new PublisherVersion(); | ||
41 | + publisherVersion.setPublisherName("A"); | ||
42 | + publisherVersion.setPublisherStreetAddress("B"); | ||
43 | + publisherVersion.setPublisherPostalCode("C"); | ||
44 | + publisherVersion.setPublisherPostOfficeBoxNumber("D"); | ||
45 | + publisherVersion.setPublisherAddressRegion("E"); | ||
46 | + publisherVersion.setPublisherAddressLocality("F"); | ||
47 | + publisherVersion.setPublisherAddressCountry(new Country()); | ||
48 | + publisherVersion.setPublisherTelephone("G"); | ||
49 | + publisherVersion.setPublisherEmail("H"); | ||
50 | + publisherVersion.setPublisherURL("I"); | ||
51 | + publisherVersion.setPublisherActive(true); | ||
52 | + publisherVersion.setPublisherHistory("J"); | ||
53 | + publisherVersion.setPublisher(new Publisher()); | ||
54 | + logger.trace("publisherVersion = {}", publisherVersion); | ||
55 | + | ||
56 | + when(publisherService.getPublisherVersion(0)).thenReturn(publisherVersion); | ||
57 | + | ||
58 | + } | ||
59 | + | ||
60 | + @DisplayName("Passage en mode édition") | ||
61 | + @Test | ||
62 | + public void testEdit() { | ||
63 | + assertThat(publisherVersionView.isEditMode()).isFalse(); | ||
64 | + publisherVersionView.edit(); | ||
65 | + assertThat(publisherVersionView.isEditMode()).isTrue(); | ||
66 | + } | ||
67 | + | ||
68 | + @DisplayName("Annulation des données saisie pour un nouvel éditeur") | ||
69 | + @Test | ||
70 | + public void testCancelNewPublisher() { | ||
71 | + publisherVersionView.setNewPublisher(true); | ||
72 | + | ||
73 | + publisherVersionView.setPublisherName("A"); | ||
74 | + publisherVersionView.setPublisherStreetAddress("B"); | ||
75 | + publisherVersionView.setPublisherPostalCode("C"); | ||
76 | + publisherVersionView.setPublisherPostOfficeBoxNumber("D"); | ||
77 | + publisherVersionView.setPublisherAddressRegion("E"); | ||
78 | + publisherVersionView.setPublisherAddressLocality("F"); | ||
79 | + publisherVersionView.setPublisherAddressCountry(new Country()); | ||
80 | + publisherVersionView.setPublisherTelephone("G"); | ||
81 | + publisherVersionView.setPublisherEmail("H"); | ||
82 | + publisherVersionView.setPublisherURL("I"); | ||
83 | + publisherVersionView.setPublisherActive(true); | ||
84 | + publisherVersionView.setPublisherHistory("J"); | ||
85 | + | ||
86 | + publisherVersionView.cancel(); | ||
87 | + | ||
88 | + assertThat(publisherVersionView.getPublisherName()).isNull(); | ||
89 | + assertThat(publisherVersionView.getPublisherStreetAddress()).isNull(); | ||
90 | + assertThat(publisherVersionView.getPublisherPostalCode()).isNull(); | ||
91 | + assertThat(publisherVersionView.getPublisherPostOfficeBoxNumber()).isNull(); | ||
92 | + assertThat(publisherVersionView.getPublisherAddressRegion()).isNull(); | ||
93 | + assertThat(publisherVersionView.getPublisherAddressLocality()).isNull(); | ||
94 | + assertThat(publisherVersionView.getPublisherTelephone()).isNull(); | ||
95 | + assertThat(publisherVersionView.getPublisherEmail()).isNull(); | ||
96 | + assertThat(publisherVersionView.getPublisherURL()).isNull(); | ||
97 | + assertThat(publisherVersionView.getPublisherHistory()).isNull(); | ||
98 | + assertThat(publisherVersionView.isPublisherActive()).isFalse(); | ||
99 | + assertThat(publisherVersionView.isEditMode()).isTrue(); | ||
100 | + } | ||
101 | + | ||
102 | + // J'ai l'impression qu'on pourrait utiliser de l'imbrication ici | ||
103 | + /* | ||
104 | + @DisplayName("Annulation de saisie de nouvelle version de saisie d'un éditeur existant") | ||
105 | + @Test | ||
106 | + public void testCancelNewVersionOfPublisher() { | ||
107 | + | ||
108 | + }*/ | ||
109 | +/* | ||
110 | + @Test | ||
111 | + @DisplayName("Test de la fonction de chargement des valeurs initiales pour leur affichage") | ||
112 | + public void testLoadData() { | ||
113 | + publisherVersionView.setPublisherVersionId(0); | ||
114 | + publisherVersionView.loadData(); | ||
115 | + assertThat(publisherVersionView.getPublisherName()).isEqualTo("A"); | ||
116 | + assertThat(publisherVersionView.getPublisherStreetAddress()).isEqualTo("B"); | ||
117 | + assertThat(publisherVersionView.getPublisherPostalCode()).isEqualTo("C"); | ||
118 | + assertThat(publisherVersionView.getPublisherPostOfficeBoxNumber()).isEqualTo("D"); | ||
119 | + assertThat(publisherVersionView.getPublisherAddressRegion()).isEqualTo("E"); | ||
120 | + assertThat(publisherVersionView.getPublisherAddressLocality()).isEqualTo("F"); | ||
121 | + assertThat(publisherVersionView.getPublisherTelephone()).isEqualTo("G"); | ||
122 | + assertThat(publisherVersionView.getPublisherEmail()).isEqualTo("H"); | ||
123 | + assertThat(publisherVersionView.getPublisherURL()).isEqualTo("I"); | ||
124 | + assertThat(publisherVersionView.isPublisherActive()).isTrue(); | ||
125 | + assertThat(publisherVersionView.getPublisherHistory()).isEqualTo("J"); | ||
126 | + assertThat(publisherVersionView.isNewPublisher()).isFalse(); | ||
127 | + } | ||
128 | +*/ | ||
129 | +} |
-
Please register or login to post a comment