Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2016-11-15 18:15:01 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
02f1d088b045948c812b918b95f555161a0f4dc5
02f1d088
1 parent
cb801508
Début des tests pour PublisherVersionView
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
0 deletions
src/main/java/org/legrog/web/publisher/PublisherVersionView.java
src/test/java/org/legrog/web/publisher/PublisherVersionViewTest.java
src/main/java/org/legrog/web/publisher/PublisherVersionView.java
View file @
02f1d08
...
...
@@ -81,6 +81,7 @@ public class PublisherVersionView implements Serializable {
publisherURL
=
null
;
publisherActive
=
false
;
publisherHistory
=
null
;
// Je ne pense pas que la ligne suivante soit nécessaire
publisher
=
null
;
editMode
=
true
;
...
...
@@ -329,4 +330,11 @@ public class PublisherVersionView implements Serializable {
return
editMode
;
}
public
void
setEditMode
(
boolean
editMode
)
{
this
.
editMode
=
editMode
;
}
public
void
setNewPublisher
(
boolean
newPublisher
)
{
this
.
newPublisher
=
newPublisher
;
}
}
...
...
src/test/java/org/legrog/web/publisher/PublisherVersionViewTest.java
0 → 100644
View file @
02f1d08
package
org
.
legrog
.
web
.
publisher
;
import
org.junit.Before
;
import
org.junit.Test
;
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
(
answer
=
Answers
.
RETURNS_DEEP_STUBS
)
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
);
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();
}
*/
}
Please
register
or
login
to post a comment