PublisherVersionViewTest.java
5.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package org.legrog.web.publisher;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.runner.RunWith;
import org.legrog.entities.Country;
import org.legrog.entities.Publisher;
import org.legrog.entities.PublisherVersion;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
/**
* Classe testant PublisherVersionView.
*/
@RunWith(MockitoJUnitRunner.class)
@DisplayName("Création et visualisation de version d'éditeur")
public class PublisherVersionViewTest {
Logger logger = LoggerFactory.getLogger(getClass());
private PublisherVersionView publisherVersionView;
@Mock
private PublisherService publisherService;
private PublisherVersion publisherVersion;
@Before
public void setUp() {
publisherVersionView = new PublisherVersionView();
publisherVersionView.setEditMode(false);
publisherVersionView.setNewPublisher(false);
publisherVersion = new PublisherVersion();
publisherVersion.setPublisherName("A");
publisherVersion.setPublisherStreetAddress("B");
publisherVersion.setPublisherPostalCode("C");
publisherVersion.setPublisherPostOfficeBoxNumber("D");
publisherVersion.setPublisherAddressRegion("E");
publisherVersion.setPublisherAddressLocality("F");
publisherVersion.setPublisherAddressCountry(new Country());
publisherVersion.setPublisherTelephone("G");
publisherVersion.setPublisherEmail("H");
publisherVersion.setPublisherURL("I");
publisherVersion.setPublisherActive(true);
publisherVersion.setPublisherHistory("J");
publisherVersion.setPublisher(new Publisher());
logger.trace("publisherVersion = {}", publisherVersion);
// todo uncomment when need to use it (new mockito refuses unnecessary stubbing)
// when(publisherService.getPublisherVersion(0)).thenReturn(publisherVersion);
}
@DisplayName("Passage en mode édition")
@Test
public void testEdit() {
assertThat(publisherVersionView.isEditMode()).isFalse();
publisherVersionView.edit();
assertThat(publisherVersionView.isEditMode()).isTrue();
}
@DisplayName("Annulation des données saisie pour un nouvel éditeur")
@Test
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();
assertThat(publisherVersionView.getPublisherStreetAddress()).isNull();
assertThat(publisherVersionView.getPublisherPostalCode()).isNull();
assertThat(publisherVersionView.getPublisherPostOfficeBoxNumber()).isNull();
assertThat(publisherVersionView.getPublisherAddressRegion()).isNull();
assertThat(publisherVersionView.getPublisherAddressLocality()).isNull();
assertThat(publisherVersionView.getPublisherTelephone()).isNull();
assertThat(publisherVersionView.getPublisherEmail()).isNull();
assertThat(publisherVersionView.getPublisherURL()).isNull();
assertThat(publisherVersionView.getPublisherHistory()).isNull();
assertThat(publisherVersionView.isPublisherActive()).isFalse();
assertThat(publisherVersionView.isEditMode()).isTrue();
}
// J'ai l'impression qu'on pourrait utiliser de l'imbrication ici
/*
@DisplayName("Annulation de saisie de nouvelle version de saisie d'un éditeur existant")
@Test
public void testCancelNewVersionOfPublisher() {
}*/
/*
@Test
@DisplayName("Test de la fonction de chargement des valeurs initiales pour leur affichage")
public void testLoadData() {
publisherVersionView.setPublisherVersionId(0);
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();
}
*/
}