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-24 11:29:11 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
de612c7a8aac52b5bd9adb9d2f6c0cbf1ad6e12d
de612c7a
1 parent
ecb22b1d
Couverture supposée suffisante de ListPublisherActionsView.
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
95 additions
and
0 deletions
src/test/java/org/legrog/web/publisher/ListPublisherActionsViewTest.java
src/test/java/org/legrog/web/publisher/ListPublisherActionsViewTest.java
0 → 100644
View file @
de612c7
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.jupiter.api.Nested
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.platform.runner.JUnitPlatform
;
import
org.junit.runner.RunWith
;
import
org.legrog.entities.Publisher
;
import
org.legrog.entities.PublisherAction
;
import
org.legrog.test.MockitoExtension
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
javax.inject.Inject
;
import
java.util.ArrayList
;
import
java.util.List
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Classe testant ListPublisherActionsView.
*/
@RunWith
(
JUnitPlatform
.
class
)
@ExtendWith
(
MockitoExtension
.
class
)
@DisplayName
(
"Visualisation d'actions sur éditeur"
)
public
class
ListPublisherActionsViewTest
{
ListPublisherActionsView
listPublisherActionsView
;
@Nested
@DisplayName
(
"setView method"
)
public
class
testSetView
{
boolean
filtered
;
@BeforeEach
public
void
setUp
(
@Mock
PublisherService
publisherServiceMock
){
filtered
=
false
;
listPublisherActionsView
=
new
ListPublisherActionsView
(
publisherServiceMock
)
{
@Override
public
void
filterOnID
()
{
filtered
=
true
;
}
};
}
@Test
@DisplayName
(
"should show all"
)
public
void
showAll
(
@Mock
PublisherService
publisherServiceMock
)
{
listPublisherActionsView
.
setPublisherId
(
null
);
listPublisherActionsView
.
setViewAll
(
false
);
listPublisherActionsView
.
setView
();
Mockito
.
verify
(
publisherServiceMock
).
getAllPublisherActions
();
assertThat
(
listPublisherActionsView
.
isViewAll
()).
isTrue
();
assertThat
(
filtered
).
isFalse
();
}
@Test
@DisplayName
(
"should show filtered"
)
public
void
showFiltered
(
@Mock
PublisherService
publisherServiceMock
)
{
listPublisherActionsView
.
setPublisherId
(
1
);
listPublisherActionsView
.
setViewAll
(
true
);
listPublisherActionsView
.
setView
();
Mockito
.
verify
(
publisherServiceMock
).
getAllPublisherActions
();
assertThat
(
listPublisherActionsView
.
isViewAll
()).
isFalse
();
assertThat
(
filtered
).
isTrue
();
}
}
@Test
@DisplayName
(
"filterId should filter"
)
public
void
testFilter
(
@Mock
PublisherService
publisherServiceMock
)
{
List
<
PublisherAction
>
publisherActions
=
new
ArrayList
<
PublisherAction
>();
Publisher
publisher
=
new
Publisher
();
Publisher
publisher1
=
new
Publisher
();
PublisherAction
publisherAction
=
new
PublisherAction
();
PublisherAction
publisherAction1
=
new
PublisherAction
();
publisher
.
setPublisherId
(
0
);
publisher1
.
setPublisherId
(
1
);
publisherAction
.
setPublisher
(
publisher
);
publisherAction1
.
setPublisher
(
publisher1
);
publisherActions
.
add
(
publisherAction
);
publisherActions
.
add
(
publisherAction1
);
listPublisherActionsView
=
new
ListPublisherActionsView
();
listPublisherActionsView
.
setPublisherActions
(
publisherActions
);
listPublisherActionsView
.
setPublisherId
(
1
);
listPublisherActionsView
.
filterOnID
();
assertThat
(
listPublisherActionsView
.
getPublisherActions
()).
containsExactly
(
publisherAction1
);
}
}
Please
register
or
login
to post a comment