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-02-03 16:31:06 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1995cd7a957ab34eb23a717432646d6ebb777af8
1995cd7a
1 parent
21541847
Commentaires, tests et adaptation code et tests pour indexation Publisher validé.
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
5 deletions
src/main/java/org/legrog/entities/IndexedPublisher.java
src/main/java/org/legrog/entities/PublisherSearchRepository.java
src/main/java/org/legrog/entities/PublisherSearchRepositorySolrj.java
src/test/java/org/legrog/web/publisher/PublisherServiceSpringTest.java
src/main/java/org/legrog/entities/IndexedPublisher.java
View file @
1995cd7
...
...
@@ -23,4 +23,16 @@ public class IndexedPublisher {
this
.
publisherName
=
publisherVersion
.
getPublisherName
();
this
.
publisherHistory
=
publisherVersion
.
getPublisherHistory
();
}
public
int
getPublisherId
()
{
return
publisherId
;
}
public
String
getPublisherName
()
{
return
publisherName
;
}
public
String
getPublisherHistory
()
{
return
publisherHistory
;
}
}
\ No newline at end of file
...
...
src/main/java/org/legrog/entities/PublisherSearchRepository.java
View file @
1995cd7
...
...
@@ -9,5 +9,11 @@ public interface PublisherSearchRepository /*extends SolrCrudRepository<IndexedP
// @Query("?0")
// List<IndexedPublisher> search(String search);
/*
@param IndexedPublisher
@return IndexedPublisher
Indexe la version simplifiée de Publisher, IndexedPublisher.
*/
public
IndexedPublisher
save
(
IndexedPublisher
indexedPublisher
);
}
...
...
src/main/java/org/legrog/entities/PublisherSearchRepositorySolrj.java
View file @
1995cd7
...
...
@@ -9,6 +9,9 @@ import org.slf4j.LoggerFactory;
import
javax.inject.Inject
;
import
java.io.IOException
;
/*
Classe implémentant l'interface PublisherSearchRepository avec l'API SolrJ
*/
public
class
PublisherSearchRepositorySolrj
implements
PublisherSearchRepository
{
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
...
...
src/test/java/org/legrog/web/publisher/PublisherServiceSpringTest.java
View file @
1995cd7
...
...
@@ -9,7 +9,10 @@ import org.junit.runner.RunWith;
import
org.legrog.entities.*
;
import
org.legrog.test.MockitoExtension
;
import
org.legrog.web.xyz.SharedService
;
import
org.mockito.ArgumentCaptor
;
import
org.mockito.Captor
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
javax.inject.Inject
;
import
java.util.ArrayList
;
...
...
@@ -38,6 +41,9 @@ public class PublisherServiceSpringTest {
@Mock
PublisherVersion
publisherVersionMock
;
@Captor
ArgumentCaptor
<
IndexedPublisher
>
indexedPublisherArgumentCaptor
;
@BeforeEach
public
void
setUp
(
@Mock
PublisherRepository
publisherRepository
,
@Mock
PublisherVersionRepository
publisherVersionRepository
,
...
...
@@ -75,22 +81,50 @@ public class PublisherServiceSpringTest {
verify
(
publisherVersionRepository
).
save
(
publisherVersion1
);
}
@DisplayName
(
"
Validates a version by creating a VALIDATE action that links to publisher and version, sets versions in publisher's validated and saves it
"
)
@DisplayName
(
"
When a PublisherVersion is validated, it should be the right one
"
)
@Test
public
void
testValidateVersion
(
@Mock
PublisherActionRepository
publisherActionRepository
)
{
public
void
testValidateVersion
Right
(
)
{
Set
<
PublisherVersion
>
publisherVersions
;
ActionType
actionType
=
ActionType
.
VALIDATE
;
publisher
=
new
Publisher
();
publisherVersion
=
new
PublisherVersion
();
publisherVersions
=
new
HashSet
<
PublisherVersion
>();
publisherVersions
.
add
(
publisherVersion
);
publisherVersions
.
add
(
publisherVersionMock
);
publisher
.
setVersions
(
publisherVersions
);
when
(
publisherVersionMock
.
getPublisher
()).
thenReturn
(
publisher
);
publisherServiceSpring
.
validatePublisherVersion
(
publisherVersionMock
);
assertThat
(
publisher
.
getValidatedVersion
()).
isEqualTo
(
publisherVersionMock
);
}
@DisplayName
(
"When a publisherVersion is validated, the indexed IndexedPublisher should have all attributes right"
)
@Test
public
void
testValidateIndexPublisher
(
@Mock
PublisherSearchRepository
publisherSearchRepository
)
{
publisher
=
new
Publisher
();
publisher
.
setPublisherId
(
111
);
when
(
publisherVersionMock
.
getPublisher
()).
thenReturn
(
publisher
);
when
(
publisherVersionMock
.
getPublisherName
()).
thenReturn
(
"nom"
);
when
(
publisherVersionMock
.
getPublisherHistory
()).
thenReturn
(
"histoire"
);
publisherServiceSpring
.
validatePublisherVersion
(
publisherVersionMock
);
Mockito
.
verify
(
publisherSearchRepository
).
save
(
indexedPublisherArgumentCaptor
.
capture
());
IndexedPublisher
indexedPublisher
=
indexedPublisherArgumentCaptor
.
getValue
();
assertThat
(
indexedPublisher
.
getPublisherId
()).
isEqualTo
(
111
);
assertThat
(
indexedPublisher
.
getPublisherName
()).
isEqualTo
(
"nom"
);
assertThat
(
indexedPublisher
.
getPublisherHistory
()).
isEqualTo
(
"histoire"
);
}
@DisplayName
(
"When a validate creates a PublisherAction it should be saved and have all attributes right"
)
@Test
public
void
testValidateCreateAction
(
@Mock
PublisherActionRepository
publisherActionRepository
)
{
PublisherAction
publisherAction
;
ActionType
actionType
=
ActionType
.
VALIDATE
;
publisher
=
new
Publisher
();
when
(
publisherVersionMock
.
getPublisher
()).
thenReturn
(
publisher
);
publisherAction
=
publisherServiceSpring
.
validatePublisherVersion
(
publisherVersionMock
);
verify
(
publisherActionRepository
).
save
(
publisherAction
);
assertThat
(
publisherAction
.
getPublisherVersion
()).
isEqualTo
(
publisherVersionMock
);
...
...
@@ -98,4 +132,5 @@ public class PublisherServiceSpringTest {
assertThat
(
publisherAction
.
getPublisher
().
getValidatedVersion
()).
isEqualTo
(
publisherVersionMock
);
assertThat
(
publisherAction
.
getActionType
()).
isEqualTo
(
actionType
);
}
}
...
...
Please
register
or
login
to post a comment