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-23 10:34:34 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0232c87840f5da97476484cd174d2f7267fbd53f
0232c878
1 parent
1fc84986
Augmentation couverture de ListPublisherVersionsView par les tests.
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
5 deletions
src/test/java/org/legrog/web/publisher/ListPublisherVersionsViewTest.java
src/test/java/org/legrog/web/publisher/ListPublisherVersionsViewTest.java
View file @
0232c87
...
...
@@ -5,6 +5,7 @@ import org.junit.Test;
import
org.junit.runner.RunWith
;
import
org.junit.jupiter.api.DisplayName
;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherAction
;
import
org.legrog.entities.PublisherVersion
;
import
org.mockito.Answers
;
import
org.mockito.Mock
;
...
...
@@ -32,6 +33,9 @@ public class ListPublisherVersionsViewTest {
private
PublisherVersion
publisherVersion
;
private
PublisherVersion
publisherVersion1
;
private
PublisherVersion
publisherVersion2
;
private
Publisher
publisher
;
private
Publisher
publisher1
;
PublisherAction
publisherAction
;
@Mock
(
answer
=
Answers
.
RETURNS_DEEP_STUBS
)
private
PublisherService
publisherService
;
...
...
@@ -39,7 +43,6 @@ public class ListPublisherVersionsViewTest {
@Before
public
void
setUp
()
{
// Données
publisherVersion
=
new
PublisherVersion
();
publisherVersion1
=
new
PublisherVersion
();
...
...
@@ -47,8 +50,8 @@ public class ListPublisherVersionsViewTest {
publisherVersion
.
setPublisherVersionId
(
0
);
publisherVersion1
.
setPublisherVersionId
(
1
);
publisherVersion2
.
setPublisherVersionId
(
2
);
Publisher
publisher
=
new
Publisher
();
Publisher
publisher1
=
new
Publisher
();
publisher
=
new
Publisher
();
publisher1
=
new
Publisher
();
publisher
.
setPublisherId
(
0
);
publisher1
.
setPublisherId
(
1
);
publisherVersion
.
setPublisher
(
publisher
);
...
...
@@ -58,10 +61,13 @@ public class ListPublisherVersionsViewTest {
publisherVersions
=
new
ArrayList
<
PublisherVersion
>();
publisherVersions
.
add
(
publisherVersion
);
publisherVersions
.
add
(
publisherVersion1
);
publisherAction
=
new
PublisherAction
();
// Mock
when
(
publisherService
.
getAllPublisherVersions
()).
thenReturn
(
publisherVersions
);
listPublisherVersionsView
=
new
ListPublisherVersionsView
(
publisherService
);
when
(
publisherService
.
getLastValidate
(
publisher
)).
thenReturn
(
publisherAction
);
when
(
publisherService
.
getLastValidate
(
publisher1
)).
thenReturn
(
null
);
}
...
...
@@ -72,7 +78,7 @@ public class ListPublisherVersionsViewTest {
listPublisherVersionsView
.
setView
();
Mockito
.
verify
(
publisherService
).
getAllPublisherVersions
();
assertThat
(
listPublisherVersionsView
.
isViewAll
()).
isTrue
();
assertThat
(
listPublisherVersionsView
.
getPublisherVersions
()).
isEqualTo
(
this
.
publisherVersions
);
assertThat
(
listPublisherVersionsView
.
getPublisherVersions
()).
isEqualTo
(
publisherVersions
);
}
@Test
...
...
@@ -82,7 +88,7 @@ public class ListPublisherVersionsViewTest {
listPublisherVersionsView
.
setView
();
Mockito
.
verify
(
publisherService
).
getAllPublisherVersions
();
assertThat
(
listPublisherVersionsView
.
isViewAll
()).
isFalse
();
assertThat
(
listPublisherVersionsView
.
getPublisherVersions
()).
containsExactly
(
this
.
publisherVersion1
);
assertThat
(
listPublisherVersionsView
.
getPublisherVersions
()).
containsExactly
(
publisherVersion1
);
}
@Test
...
...
@@ -92,4 +98,16 @@ public class ListPublisherVersionsViewTest {
listPublisherVersionsView
.
validate
(
publisherVersion2
);
Mockito
.
verify
(
publisherService
).
validatePublisherVersion
(
publisherVersion2
);
}
@Test
@DisplayName
(
"Récupération effective dernière validation d'un éditeur"
)
public
void
testGetLastValidate
()
{
assertThat
(
listPublisherVersionsView
.
getLastValidate
(
publisher
)).
isEqualTo
(
publisherAction
);
}
@Test
@DisplayName
(
"Échec de récupération de dernière validation d'un éditeur"
)
public
void
testGetLastValidateNull
()
{
assertThat
(
listPublisherVersionsView
.
getLastValidate
(
publisher1
)).
isNull
();
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment