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
2017-03-09 12:34:55 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
429977df18aec3959f8e3fba3d79a68b58aaa875
429977df
1 parent
ccd7e636
ReindexView et Test
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
1 deletions
src/main/java/org/legrog/web/xyz/ReindexView.java
src/test/java/org/legrog/web/xyz/ReindexViewTest.java
src/main/java/org/legrog/web/xyz/ReindexView.java
View file @
429977d
package
org
.
legrog
.
web
.
xyz
;
import
org.legrog.web.account.AccountService
;
import
org.legrog.web.publisher.PublisherService
;
import
javax.enterprise.context.RequestScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
java.io.Serializable
;
...
...
@@ -12,12 +16,23 @@ import java.io.Serializable;
public
class
ReindexView
implements
Serializable
{
private
int
indexedAccountsNumber
;
private
int
indexedPublishersNumber
;
private
PublisherService
publisherService
;
private
AccountService
accountService
;
@Inject
ReindexView
(
PublisherService
publisherService
,
AccountService
accountService
)
{
this
.
publisherService
=
publisherService
;
this
.
accountService
=
accountService
;
}
ReindexView
()
{
//no args constructor to make it proxyable
}
public
void
reindexAll
()
{
indexedPublishersNumber
=
publisherService
.
reindexAllPublishers
();
indexedAccountsNumber
=
accountService
.
reindexAllAccounts
();
}
public
int
getIndexedAccountsNumber
()
{
return
indexedAccountsNumber
;
...
...
src/test/java/org/legrog/web/xyz/ReindexViewTest.java
View file @
429977d
package
org
.
legrog
.
web
.
xyz
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.DisplayName
;
import
org.junit.jupiter.api.Nested
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.platform.runner.JUnitPlatform
;
import
org.junit.runner.RunWith
;
import
org.legrog.test.MockitoExtension
;
import
org.legrog.web.account.AccountService
;
import
org.legrog.web.publisher.PublisherService
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
when
;
/**
* Classe testing ReindexView
*/
@RunWith
(
JUnitPlatform
.
class
)
@ExtendWith
(
MockitoExtension
.
class
)
@DisplayName
(
"Reindexes data"
)
public
class
ReindexViewTest
{
private
ReindexView
reindexView
;
private
PublisherService
publisherService
;
private
AccountService
accountService
;
@BeforeEach
public
void
setUp
(
@Mock
PublisherService
publisherService
,
@Mock
AccountService
accountService
)
{
this
.
publisherService
=
publisherService
;
this
.
accountService
=
accountService
;
this
.
reindexView
=
new
ReindexView
(
publisherService
,
accountService
);
}
@Nested
@DisplayName
(
"reindexAll method"
)
class
ReindexAllTests
{
@DisplayName
(
"when called, should call for reindexing of publishers and accounts"
)
@Test
public
void
reindexAllTest
(
@Mock
PublisherService
publisherService
,
@Mock
AccountService
accountService
)
{
reindexView
.
reindexAll
();
Mockito
.
verify
(
publisherService
).
reindexAllPublishers
();
Mockito
.
verify
(
accountService
).
reindexAllAccounts
();
}
@DisplayName
(
"when called, should set its indexed numbers to values returned by reindexers"
)
@Test
public
void
setReturnIntegers
(
@Mock
PublisherService
publisherService
,
@Mock
AccountService
accountService
)
{
when
(
publisherService
.
reindexAllPublishers
()).
thenReturn
(
1
);
when
(
accountService
.
reindexAllAccounts
()).
thenReturn
(
2
);
reindexView
.
reindexAll
();
assertThat
(
reindexView
.
getIndexedPublishersNumber
()).
isEqualTo
(
1
);
assertThat
(
reindexView
.
getIndexedAccountsNumber
()).
isEqualTo
(
2
);
}
}
}
...
...
Please
register
or
login
to post a comment