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 16:13:21 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9e7fd0b24b81682a6a924dcaeba408f1805dccea
9e7fd0b2
1 parent
d9cebafa
Couverture satisfaisante de ListPublisherVersionsView par tests
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
100 additions
and
0 deletions
src/test/java/org/legrog/web/publisher/ListPublisherVersionsViewTest.java
src/test/java/org/legrog/web/publisher/ListPublisherVersionsViewTest.java
0 → 100644
View file @
9e7fd0b
package
org
.
legrog
.
web
.
publisher
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.jupiter.api.DisplayName
;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherVersion
;
import
org.mockito.Answers
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.*;
/**
* Classe testant ListPublisherVersionsView.
*/
@RunWith
(
MockitoJUnitRunner
.
class
)
@DisplayName
(
"Listes de versions d'éditeurs"
)
public
class
ListPublisherVersionsViewTest
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
ListPublisherVersionsView
listPublisherVersionsView
;
private
List
<
PublisherVersion
>
publisherVersions
;
private
PublisherVersion
publisherVersion
;
private
PublisherVersion
publisherVersion1
;
private
PublisherVersion
publisherVersion2
;
@Mock
(
answer
=
Answers
.
RETURNS_DEEP_STUBS
)
private
PublisherService
publisherService
;
@Before
public
void
setUp
()
{
listPublisherVersionsView
=
new
ListPublisherVersionsView
();
// Données
publisherVersion
=
new
PublisherVersion
();
publisherVersion1
=
new
PublisherVersion
();
publisherVersion2
=
new
PublisherVersion
();
publisherVersion
.
setPublisherVersionId
(
0
);
publisherVersion1
.
setPublisherVersionId
(
1
);
publisherVersion2
.
setPublisherVersionId
(
2
);
Publisher
publisher
=
new
Publisher
();
Publisher
publisher1
=
new
Publisher
();
publisher
.
setPublisherId
(
0
);
publisher1
.
setPublisherId
(
1
);
logger
.
trace
(
"publisher {}"
,
publisher
);
logger
.
trace
(
"publisher1 {}"
,
publisher1
);
publisherVersion
.
setPublisher
(
publisher
);
publisherVersion1
.
setPublisher
(
publisher1
);
publisherVersion2
.
setPublisher
(
publisher
);
publisher
.
setValidatedVersion
(
publisherVersion
);
logger
.
trace
(
"publisherVersion {}"
,
publisherVersion
);
logger
.
trace
(
"publisherVersion1 {}"
,
publisherVersion1
);
publisherVersions
=
new
ArrayList
<
PublisherVersion
>();
publisherVersions
.
add
(
publisherVersion
);
publisherVersions
.
add
(
publisherVersion1
);
// Mock
when
(
publisherService
.
getAllPublisherVersions
()).
thenReturn
(
publisherVersions
);
listPublisherVersionsView
.
setPublisherService
(
publisherService
);
logger
.
trace
(
"listPublisherVersionsView : {}"
,
listPublisherVersionsView
);
logger
.
trace
(
"listPublisherVersionsView, publisherVersions : {}"
,
publisherVersions
);
}
@Test
@DisplayName
(
"Liste complète"
)
public
void
testSetViewAll
()
{
listPublisherVersionsView
.
setPublisherId
(
null
);
listPublisherVersionsView
.
setView
();
Mockito
.
verify
(
publisherService
).
getAllPublisherVersions
();
assertThat
(
listPublisherVersionsView
.
isViewAll
()).
isTrue
();
assertThat
(
listPublisherVersionsView
.
getPublisherVersions
()).
isEqualTo
(
this
.
publisherVersions
);
}
@Test
@DisplayName
(
"Liste pour un éditeur"
)
public
void
testSetViewNotAllAlsoTestingFilterOnId
()
{
listPublisherVersionsView
.
setPublisherId
(
new
Integer
(
1
));
listPublisherVersionsView
.
setView
();
Mockito
.
verify
(
publisherService
).
getAllPublisherVersions
();
assertThat
(
listPublisherVersionsView
.
isViewAll
()).
isFalse
();
assertThat
(
listPublisherVersionsView
.
getPublisherVersions
()).
containsExactly
(
this
.
publisherVersion1
);
}
@Test
@DisplayName
(
"Test de l'appel de validation"
)
public
void
testValidate
()
{
listPublisherVersionsView
.
setPublisherId
(
new
Integer
(
0
));
listPublisherVersionsView
.
validate
(
publisherVersion2
);
Mockito
.
verify
(
publisherService
).
validatePublisherVersion
(
publisherVersion2
);
}
}
\ No newline at end of file
Please
register
or
login
to post a comment