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-01-25 15:52:05 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c2b0ff066f6f4eabe40fb2f7d6aa0cef5dbad9c2
c2b0ff06
1 parent
5997729a
Début implantation intégration indexation.
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
118 additions
and
85 deletions
doc/searchPublisher.png
doc/searchPublisher.puml
doc/validatePublisherVersion.png
doc/validatePublisherVersion.puml
pom.xml
src/main/java/org/legrog/entities/IndexedPublisher.java
src/main/java/org/legrog/entities/PublisherSearchRepository.java
src/main/java/org/legrog/web/publisher/PublisherServiceSpring.java
src/test/java/org/legrog/web/book/BookServiceOldTest.java
src/test/java/org/legrog/web/publisher/PublisherServiceSpringTest.java
doc/searchPublisher.png
View file @
c2b0ff0
11.1 KB
|
W:
|
H:
36.8 KB
|
W:
|
H:
2-up
Swipe
Onion skin
doc/searchPublisher.puml
View file @
c2b0ff0
@startuml
Actor Visiteur
Visiteur -> PublisherSearchPage: (String)
PublisherSearchPage -> PublisherSearchView: search(String)
Activate PublisherSearchView
PublisherSearchView -> PublisherService: search
PublisherSearchView -> PublisherService: search
(String)
Activate PublisherService
PublisherService -> PublisherServiceSpring: search
PublisherService -> PublisherServiceSpring: search
(String)
Activate PublisherServiceSpring
PublisherServiceSpring -> PublisherSearchRepository: search
PublisherServiceSpring -> PublisherSearchRepository: search
(String)
Activate PublisherSearchRepository
PublisherSearchRepository --> PublisherServiceSpring
PublisherSearchRepository --> PublisherServiceSpring
: (List<IndexedPublisher>)
Deactivate PublisherSearchRepository
PublisherServiceSpring -> PublisherServiceSpring: convert(List<IndexedPublisher>)
Activate PublisherServiceSpring
PublisherServiceSpring -> PublisherVersionRepository: findByPublisherVersionIdIn(List<int>)
Activate PublisherVersionRepository
PublisherVersionRepository --> PublisherServiceSpring: (List<PublisherVersion>)
Deactivate PublisherVersionRepository
PublisherServiceSpring --> PublisherServiceSpring: (List<PublisherVersion>)
Deactivate PublisherServiceSpring
PublisherServiceSpring --> PublisherService
PublisherServiceSpring --> PublisherService
: (List<PublisherVersion>)
Deactivate PublisherServiceSpring
PublisherService --> PublisherSearchView
PublisherService --> PublisherSearchView
: (List<PublisherVersion>)
Deactivate PublisherService
PublisherSearchView --> PublisherSearchPage: (List<PublisherVersion>)
Deactivate PublisherSearchView
PublisherSearchPage --> Visiteur: resultPage
@enduml
\ No newline at end of file
...
...
doc/validatePublisherVersion.png
View file @
c2b0ff0
20.1 KB
|
W:
|
H:
35 KB
|
W:
|
H:
2-up
Swipe
Onion skin
doc/validatePublisherVersion.puml
View file @
c2b0ff0
@startuml
Actor Validator
Validator -> ListPublisherVersionsPage: validate(PublisherVersion)
ListPublisherVersionsPage -> ListPublisherVersionsView: validate(PublisherVersion)
Activate ListPublisherVersionsView
ListPublisherVersionsView -> PublisherService: validatePublisherVersion
ListPublisherVersionsView -> PublisherService: validatePublisherVersion(PublisherVersion)
Activate PublisherService
PublisherService -> PublisherServiceSpring: validatePublisherVersion
PublisherService -> PublisherServiceSpring: validatePublisherVersion
(PublisherVersion)
Activate PublisherServiceSpring
PublisherServiceSpring -> PublisherServiceSpring: savePublisher
PublisherServiceSpring -> PublisherServiceSpring: savePublisher(Publisher)
Activate PublisherServiceSpring
PublisherServiceSpring -> PublisherRepository: save
PublisherServiceSpring -> PublisherRepository: save(Publisher)
Activate PublisherRepository
PublisherRepository --> PublisherServiceSpring
Deactivate PublisherRepository
PublisherServiceSpring -> PublisherActionRepository: save
Activate PublisherActionRepository
PublisherActionRepository --> PublisherServiceSpring
Deactivate PublisherActionRepository
PublisherServiceSpring -> PublisherSearchRepository: save
Deactivate PublisherServiceSpring
PublisherServiceSpring -> PublisherSearchRepository: save(IndexedPublisher)
Activate PublisherSearchRepository
PublisherSearchRepository --> PublisherServiceSpring
Deactivate PublisherSearchRepository
Deactivate PublisherServiceSpring
PublisherServiceSpring -> PublisherActionRepository: save(PublisherAction)
Activate PublisherActionRepository
PublisherActionRepository --> PublisherServiceSpring
Deactivate PublisherActionRepository
PublisherServiceSpring --> PublisherService
Deactivate PublisherServiceSpring
PublisherService --> ListPublisherVersionsView
Deactivate PublisherService
ListPublisherVersionsView --> ListPublisherVersionsPage
Deactivate ListPublisherVersionsView
ListPublisherVersionsPage -> Validator: (resultPage)
@enduml
\ No newline at end of file
...
...
pom.xml
View file @
c2b0ff0
...
...
@@ -31,6 +31,8 @@
<junit.platform.version>
1.0.0-M2
</junit.platform.version>
<junit.jupiter.version>
5.0.0-M2
</junit.jupiter.version>
<mockito-core.version>
2.2.16
</mockito-core.version>
<spring-data-solr.version>
3.0.0.M1
</spring-data-solr.version>
<solr.version>
6.3.0
</solr.version>
<!-- paths -->
<custom.web.dir>
src/main/java/org/legrog/web
</custom.web.dir>
...
...
@@ -81,7 +83,23 @@
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.apache.solr
</groupId>
<artifactId>
solr-core
</artifactId>
<version>
${solr.version}
</version>
</dependency>
<dependency>
<artifactId>
solr-solrj
</artifactId>
<groupId>
org.apache.solr
</groupId>
<version>
${solr.version}
</version>
<type>
jar
</type>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
org.springframework.data
</groupId>
<artifactId>
spring-data-solr
</artifactId>
<version>
${spring-data-solr.version}
</version>
</dependency>
<!-- **** FRAMEWORK : JSF + CDI **** -->
...
...
@@ -372,6 +390,9 @@
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.19.1
</version>
<configuration>
<trimStackTrace>
false
</trimStackTrace>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
...
...
@@ -494,6 +515,16 @@
<name>
Apache Snapshot Repository
</name>
<url>
https://repository.apache.org/content/groups/snapshots/
</url>
</repository>
<repository>
<id>
alfresco-public
</id>
<name>
Alfresco Public Repository
</name>
<url>
https://artifacts.alfresco.com/nexus/content/repositories/public/
</url>
</repository>
<repository>
<id>
maven2-central
</id>
<name>
Central Repository
</name>
<url>
http://central.maven.org/maven2/
</url>
</repository>
</repositories>
</project>
...
...
src/main/java/org/legrog/entities/IndexedPublisher.java
0 → 100644
View file @
c2b0ff0
package
org
.
legrog
.
entities
;
/*
import org.apache.solr.client.solrj.beans.Field;
import org.springframework.data.solr.core.mapping.SolrDocument;
*/
import
javax.persistence.Id
;
import
javax.persistence.Lob
;
//@SolrDocument(solrCoreName = "publishers")
public
class
IndexedPublisher
{
@Id
// @Field
private
int
publisherId
;
// @Field
private
String
publisherName
;
@Lob
// @Field
private
String
publisherHistory
;
public
IndexedPublisher
(
Publisher
publisher
)
{
PublisherVersion
publisherVersion
=
publisher
.
getValidatedVersion
();
this
.
publisherId
=
publisher
.
getPublisherId
();
this
.
publisherName
=
publisherVersion
.
getPublisherName
();
this
.
publisherHistory
=
publisherVersion
.
getPublisherHistory
();
}
}
\ No newline at end of file
src/main/java/org/legrog/entities/PublisherSearchRepository.java
0 → 100644
View file @
c2b0ff0
package
org
.
legrog
.
entities
;
import
org.springframework.data.jpa.repository.Query
;
//import org.springframework.data.solr.repository.SolrCrudRepository;
import
java.util.List
;
public
interface
PublisherSearchRepository
/*extends SolrCrudRepository<IndexedPublisher, Integer>*/
{
@Query
(
"?0"
)
List
<
IndexedPublisher
>
search
(
String
search
);
}
src/main/java/org/legrog/web/publisher/PublisherServiceSpring.java
View file @
c2b0ff0
...
...
@@ -8,6 +8,7 @@ import org.slf4j.LoggerFactory;
import
javax.ejb.Stateless
;
import
javax.inject.Inject
;
import
javax.transaction.Transactional
;
import
java.sql.Timestamp
;
import
java.util.Date
;
import
java.util.HashSet
;
...
...
@@ -25,16 +26,19 @@ public class PublisherServiceSpring implements PublisherService {
PublisherRepository
publisherRepository
;
PublisherVersionRepository
publisherVersionRepository
;
PublisherActionRepository
publisherActionRepository
;
PublisherSearchRepository
publisherSearchRepository
;
SharedService
sharedService
;
@Inject
public
PublisherServiceSpring
(
PublisherRepository
publisherRepository
,
PublisherVersionRepository
publisherVersionRepository
,
PublisherActionRepository
publisherActionRepository
,
PublisherSearchRepository
publisherSearchRepository
,
SharedService
sharedService
)
{
this
.
publisherRepository
=
publisherRepository
;
this
.
publisherVersionRepository
=
publisherVersionRepository
;
this
.
publisherActionRepository
=
publisherActionRepository
;
this
.
publisherSearchRepository
=
publisherSearchRepository
;
this
.
sharedService
=
sharedService
;
}
...
...
@@ -69,6 +73,7 @@ public class PublisherServiceSpring implements PublisherService {
return
publisherVersion
;
}
@Transactional
public
PublisherAction
validatePublisherVersion
(
PublisherVersion
publisherVersion
)
{
Publisher
publisher
=
publisherVersion
.
getPublisher
();
publisher
.
setValidatedVersion
(
publisherVersion
);
...
...
@@ -79,6 +84,8 @@ public class PublisherServiceSpring implements PublisherService {
publisherAction
.
setPublisherVersion
(
publisherVersion
);
publisherAction
.
setPublisher
(
publisher
);
this
.
savePublisher
(
publisher
);
IndexedPublisher
indexedPublisher
=
new
IndexedPublisher
(
publisher
);
// publisherSearchRepository.save(indexedPublisher);
publisherActionRepository
.
save
(
publisherAction
);
return
publisherAction
;
}
...
...
src/test/java/org/legrog/web/book/BookServiceOldTest.java
deleted
100644 → 0
View file @
5997729
package
org
.
legrog
.
web
.
book
;
import
org.junit.Before
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.platform.runner.JUnitPlatform
;
import
org.junit.runner.RunWith
;
import
org.legrog.entities.Book
;
import
org.legrog.test.MockitoExtension
;
import
org.legrog.web.book.BookServiceOld
;
import
org.mockito.Answers
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
import
org.mockito.runners.MockitoJUnitRunner
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaQuery
;
import
java.util.Arrays
;
import
java.util.List
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
@RunWith
(
JUnitPlatform
.
class
)
@ExtendWith
(
MockitoExtension
.
class
)
public
class
BookServiceOldTest
{
@Mock
(
answer
=
Answers
.
RETURNS_DEEP_STUBS
)
private
EntityManager
entityManager
;
private
BookServiceOld
bookServiceOld
;
@BeforeEach
public
void
setUp
()
{
bookServiceOld
=
new
BookServiceOld
(
entityManager
);
}
@Test
public
void
testAddBook
()
{
Book
book
=
new
Book
();
bookServiceOld
.
addBook
(
book
);
Mockito
.
verify
(
entityManager
).
persist
(
book
);
}
@Test
public
void
testAllBooks
()
{
Book
book
=
new
Book
();
book
.
setBookId
(
0
);
CriteriaQuery
<
Book
>
cq
=
Mockito
.
mock
(
CriteriaQuery
.
class
);
Mockito
.
when
(
entityManager
.
getCriteriaBuilder
().
createQuery
(
Book
.
class
))
.
thenReturn
(
cq
);
Mockito
.
when
(
entityManager
.
createQuery
(
cq
).
getResultList
())
.
thenReturn
(
Arrays
.
asList
(
book
));
List
<
Book
>
allBooks
=
bookServiceOld
.
getAllBooks
();
assertThat
(
allBooks
).
as
(
"book list"
)
.
hasSize
(
1
)
.
contains
(
book
);
}
}
\ No newline at end of file
src/test/java/org/legrog/web/publisher/PublisherServiceSpringTest.java
View file @
c2b0ff0
...
...
@@ -42,9 +42,10 @@ public class PublisherServiceSpringTest {
public
void
setUp
(
@Mock
PublisherRepository
publisherRepository
,
@Mock
PublisherVersionRepository
publisherVersionRepository
,
@Mock
PublisherActionRepository
publisherActionRepository
,
@Mock
PublisherSearchRepository
publisherSearchRepository
,
@Mock
SharedService
sharedService
)
throws
Exception
{
publisherServiceSpring
=
new
PublisherServiceSpring
(
publisherRepository
,
publisherVersionRepository
,
publisherActionRepository
,
sharedService
);
publisherVersionRepository
,
publisherActionRepository
,
publisherSearchRepository
,
sharedService
);
publisherVersion
=
new
PublisherVersion
();
publisherVersion1
=
new
PublisherVersion
();
this
.
publisherRepository
=
publisherRepository
;
...
...
Please
register
or
login
to post a comment