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:38:28 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c6df86005e457c58fd49dc67a7d0d1d11f0f48bf
c6df8600
1 parent
5a3b61c1
Test avec problème
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
0 deletions
src/main/java/org/legrog/web/publisher/PublisherService.java
src/main/java/org/legrog/web/publisher/PublisherServiceDefault.java
src/test/java/org/legrog/web/publisher/PublisherServiceDefaultTest.java
src/main/java/org/legrog/web/publisher/PublisherService.java
View file @
c6df860
...
...
@@ -84,4 +84,10 @@ public interface PublisherService {
* @return PublisherVersion List
*/
List
<
PublisherVersion
>
convertIndexedPublishersIntoPublisherVersions
(
List
<
IndexedPublisher
>
indexedPublishers
);
/**
*
* @return number of indexed publishers
*/
public
int
reindexAllPublishers
();
}
\ No newline at end of file
...
...
src/main/java/org/legrog/web/publisher/PublisherServiceDefault.java
View file @
c6df860
...
...
@@ -157,4 +157,16 @@ public class PublisherServiceDefault implements PublisherService {
return
new
ArrayList
<>();
}
protected
List
<
IndexedPublisher
>
convertPublishersIntoIndexedPublishers
(
List
<
Publisher
>
publishers
)
{
return
new
ArrayList
<>();
}
@Override
public
int
reindexAllPublishers
()
{
List
<
Publisher
>
publishers
=
publisherRepository
.
findByValidatedVersionIsNotNull
();
List
<
IndexedPublisher
>
indexedPublishers
=
convertPublishersIntoIndexedPublishers
(
new
ArrayList
<>());
publisherSearchRepository
.
reindex
(
indexedPublishers
);
return
0
;
}
}
...
...
src/test/java/org/legrog/web/publisher/PublisherServiceDefaultTest.java
View file @
c6df860
...
...
@@ -47,6 +47,9 @@ public class PublisherServiceDefaultTest {
@Captor
ArgumentCaptor
<
IndexedPublisher
>
indexedPublisherArgumentCaptor
;
@Captor
ArgumentCaptor
<
List
<
Publisher
>>
publishersArgumentCaptor
;
@BeforeEach
public
void
setUp
(
@Mock
PublisherRepository
publisherRepository
,
@Mock
PublisherVersionRepository
publisherVersionRepository
,
...
...
@@ -205,4 +208,28 @@ public class PublisherServiceDefaultTest {
}
}
@Nested
@DisplayName
(
"reindexAllPublishers method"
)
class
ReindexAllPublishersTests
{
@DisplayName
(
"When called, should follow the call sequence"
)
@Test
public
void
testCorrectCalls
(
@Mock
PublisherRepository
publisherRepository
,
@Mock
PublisherSearchRepository
publisherSearchRepository
)
{
publisherServiceDefault
.
reindexAllPublishers
();
Mockito
.
verify
(
publisherRepository
).
findByValidatedVersionIsNotNull
();
verify
(
publisherServiceDefault
,
times
(
1
)).
convertPublishersIntoIndexedPublishers
(
Mockito
.
any
());
Mockito
.
verify
(
publisherSearchRepository
).
reindex
(
Mockito
.
any
());
}
@DisplayName
(
"When called, should send publishers it gets from findByValidatedVersionIsNotNull to convertPublishersIntoIndexedPublishers"
)
@Test
public
void
testTransmitsPublishers
(
@Mock
PublisherRepository
publisherRepository
)
{
List
<
Publisher
>
publishers
=
new
ArrayList
<>();
when
(
publisherRepository
.
findByValidatedVersionIsNotNull
()).
thenReturn
(
publishers
);
publisherServiceDefault
.
reindexAllPublishers
();
verify
(
publisherServiceDefault
,
times
(
1
)).
convertPublishersIntoIndexedPublishers
(
publishersArgumentCaptor
.
capture
());
// Si reindexAllPublishers fait convertPublishersIntoIndexedPublishers(new ArrayList<>()), je crois que ce test devrait échouer, mais ce n'est pas le cas
assertThat
(
publishersArgumentCaptor
.
getValue
()).
isEqualTo
(
publishers
);
}
}
}
...
...
Please
register
or
login
to post a comment