-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
956 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...e/src/main/java/uk/gov/justice/services/example/cakeshop/persistence/IndexRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package uk.gov.justice.services.example.cakeshop.persistence; | ||
|
||
import uk.gov.justice.services.example.cakeshop.persistence.entity.Index; | ||
|
||
import java.util.UUID; | ||
|
||
import org.apache.deltaspike.data.api.EntityRepository; | ||
import org.apache.deltaspike.data.api.Repository; | ||
|
||
@Repository | ||
public interface IndexRepository extends EntityRepository<Index, UUID> { | ||
} |
55 changes: 55 additions & 0 deletions
55
...ence/src/main/java/uk/gov/justice/services/example/cakeshop/persistence/entity/Index.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package uk.gov.justice.services.example.cakeshop.persistence.entity; | ||
|
||
import java.io.Serializable; | ||
import java.time.ZonedDateTime; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Id; | ||
import javax.persistence.Table; | ||
|
||
@Entity | ||
@Table(name = "index") | ||
public class Index implements Serializable { | ||
|
||
@Id | ||
@Column(name = "index_id") | ||
private UUID indexId; | ||
|
||
@Column(name = "delivery_date", nullable = false, insertable = true, updatable = true) | ||
private ZonedDateTime deliveryDate; | ||
|
||
public Index(final UUID indexId, final ZonedDateTime deliveryDate) { | ||
this.indexId = indexId; | ||
this.deliveryDate = deliveryDate; | ||
} | ||
|
||
public Index() { | ||
|
||
} | ||
|
||
public UUID getIndexId() { | ||
return indexId; | ||
} | ||
|
||
public ZonedDateTime getDeliveryDate() { | ||
return deliveryDate; | ||
} | ||
|
||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
final Index index = (Index) o; | ||
return indexId.equals(index.indexId) && | ||
deliveryDate.equals(index.deliveryDate); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(indexId, deliveryDate); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...src/test/java/uk/gov/justice/services/example/cakeshop/persistence/IndexRepositoryIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package uk.gov.justice.services.example.cakeshop.persistence; | ||
|
||
import static org.hamcrest.CoreMatchers.equalTo; | ||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.notNullValue; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import uk.gov.justice.services.example.cakeshop.persistence.entity.Index; | ||
import uk.gov.justice.services.test.utils.persistence.BaseTransactionalTest; | ||
|
||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
import java.util.UUID; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(CdiTestRunner.class) | ||
public class IndexRepositoryIT extends BaseTransactionalTest { | ||
|
||
@Inject | ||
private IndexRepository indexRepository; | ||
|
||
|
||
@Test | ||
public void shouldStoreIndex() { | ||
final UUID indexId = UUID.randomUUID(); | ||
final ZonedDateTime deliveryDate = ZonedDateTime.of(2014, 5, 13, 4, 12, 12, 0, ZoneId.of("UTC")); | ||
|
||
final Index index = new Index(indexId, deliveryDate); | ||
indexRepository.save(index); | ||
|
||
final Index indexResult = indexRepository.findBy(indexId); | ||
|
||
assertThat(indexResult, is(notNullValue())); | ||
assertThat(indexResult.getIndexId(), equalTo(indexId)); | ||
assertThat(indexResult.getDeliveryDate(), equalTo(deliveryDate)); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../src/test/java/uk/gov/justice/services/example/cakeshop/persistence/entity/IndexTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package uk.gov.justice.services.example.cakeshop.persistence.entity; | ||
|
||
import static java.time.ZonedDateTime.now; | ||
import static java.util.UUID.*; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.util.UUID; | ||
|
||
import com.google.common.testing.EqualsTester; | ||
import org.junit.Test; | ||
|
||
public class IndexTest { | ||
|
||
private final static UUID ID = randomUUID(); | ||
private final static ZonedDateTime TIME = now(); | ||
|
||
@SuppressWarnings({"squid:MethodCyclomaticComplexity", "squid:S1067", "squid:S00122"}) | ||
@Test | ||
public void equalsAndHashCode() { | ||
final Index item1 = new Index(ID, TIME); | ||
final Index item2 = new Index(ID, TIME); | ||
final Index item3 = new Index(randomUUID(), TIME); | ||
|
||
new EqualsTester() | ||
.addEqualityGroup(item1, item2) | ||
.addEqualityGroup(item3) | ||
.testEquals(); | ||
} | ||
|
||
|
||
} |
134 changes: 134 additions & 0 deletions
134
example-context/example-service/example-event/example-event-indexer/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>example-event</artifactId> | ||
<groupId>uk.gov.justice.services.example</groupId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>example-event-indexer</artifactId> | ||
<packaging>war</packaging> | ||
|
||
<properties> | ||
<cpp.service-component>EVENT_INDEXER</cpp.service-component> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>javax</groupId> | ||
<artifactId>javaee-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.framework-api</groupId> | ||
<artifactId>framework-api-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>uk.gov.justice.framework-api</groupId> | ||
<artifactId>framework-api-unifiedsearch</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>uk.gov.justice.services</groupId> | ||
<artifactId>common</artifactId> | ||
<version>${framework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.services</groupId> | ||
<artifactId>core</artifactId> | ||
<version>${framework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.framework-generators</groupId> | ||
<artifactId>messaging-adapter-core</artifactId> | ||
<version>${framework-generators.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.framework-generators</groupId> | ||
<artifactId>unifiedsearch-client-generator</artifactId> | ||
<version>${framework-generators.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>joda-time</groupId> | ||
<artifactId>joda-time</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.event-store</groupId> | ||
<artifactId>subscription-manager</artifactId> | ||
<version>${event-store.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.event-store</groupId> | ||
<artifactId>event-subscription-registry</artifactId> | ||
<version>${event-store.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.event-store</groupId> | ||
<artifactId>subscription-event-interceptors</artifactId> | ||
<version>${event-store.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.framework-api</groupId> | ||
<artifactId>framework-api-event-listener-interceptors</artifactId> | ||
<version>${framework-api.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.ejb3</groupId> | ||
<artifactId>jboss-ejb3-ext-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.services.example</groupId> | ||
<artifactId>example-persistence</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.services.example</groupId> | ||
<artifactId>example-domain</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.event-store</groupId> | ||
<artifactId>event-buffer-core</artifactId> | ||
<version>${event-store.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>uk.gov.justice.json</groupId> | ||
<artifactId>json-transformer-jolt</artifactId> | ||
<version>${json-transformer.version}</version> | ||
</dependency> | ||
|
||
<!-- Test Dependencies --> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.services</groupId> | ||
<artifactId>test-utils-core</artifactId> | ||
<version>${framework.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.gov.justice.utils</groupId> | ||
<artifactId>test-utils-logging-simple</artifactId> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
29 changes: 29 additions & 0 deletions
29
...c/main/java/uk/gov/justice/services/example/cakeshop/dummy/DummyUnifiedSearchIndexer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package uk.gov.justice.services.example.cakeshop.dummy; | ||
|
||
import static java.util.UUID.fromString; | ||
|
||
import uk.gov.justice.services.example.cakeshop.persistence.IndexRepository; | ||
import uk.gov.justice.services.example.cakeshop.persistence.entity.Index; | ||
import uk.gov.justice.services.unifiedsearch.UnifiedSearchIndexer; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.util.UUID; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.inject.Inject; | ||
import javax.json.JsonObject; | ||
|
||
@ApplicationScoped | ||
public class DummyUnifiedSearchIndexer implements UnifiedSearchIndexer { | ||
|
||
@Inject | ||
private IndexRepository indexRepository; | ||
|
||
@Override | ||
public void indexData(final JsonObject jsonObject) { | ||
final UUID recipeId = fromString(jsonObject.getString("recipeId")); | ||
final ZonedDateTime deliveryDate = ZonedDateTime.parse(jsonObject.getString("deliveryDate")); | ||
final Index index = new Index(recipeId, deliveryDate); | ||
indexRepository.save(index); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...ava/uk/gov/justice/services/example/cakeshop/dummy/DummyUnifiedSearchIndexerProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package uk.gov.justice.services.example.cakeshop.dummy; | ||
|
||
import uk.gov.justice.services.unifiedsearch.UnifiedSearchIndexer; | ||
import uk.gov.justice.services.unifiedsearch.UnifiedSearchName; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Produces; | ||
import javax.enterprise.inject.spi.InjectionPoint; | ||
import javax.inject.Inject; | ||
|
||
@ApplicationScoped | ||
public class DummyUnifiedSearchIndexerProducer { | ||
|
||
@Inject | ||
private DummyUnifiedSearchIndexer dummyUnifiedSearchIndexer; | ||
|
||
@Produces | ||
@UnifiedSearchName | ||
public UnifiedSearchIndexer unifiedSearchClient(final InjectionPoint injectionPoint) { | ||
return dummyUnifiedSearchIndexer; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...example-service/example-event/example-event-indexer/src/main/resources/META-INF/beans.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xsi:schemaLocation=" | ||
http://xmlns.jcp.org/xml/ns/javaee | ||
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="all"> | ||
</beans> |
12 changes: 12 additions & 0 deletions
12
...xample-service/example-event/example-event-indexer/src/transformer/cake-ordered-spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"operations": [ | ||
{ | ||
"operation": "shift", | ||
"spec": { | ||
"cakeId": "cakeId", | ||
"recipeId": "recipeId", | ||
"deliveryDate": "deliveryDate" | ||
} | ||
} | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
...e-context/example-service/example-event/example-event-indexer/src/yaml/event-sources.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
event_sources: | ||
- name: indexer.event.source | ||
location: | ||
jms_uri: jms:topic:example.event | ||
rest_uri: http://localhost:8080/example/event-source-api/rest | ||
data_source: java:/app/example-single/DS.eventstore |
12 changes: 12 additions & 0 deletions
12
...xample-service/example-event/example-event-indexer/src/yaml/subscriptions-descriptor.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
subscriptions_descriptor: | ||
spec_version: 1.0.0 | ||
service: example | ||
service_component: EVENT_INDEXER | ||
subscriptions: | ||
- name: event indexer subscription | ||
events: | ||
- name: example.events.cake-ordered | ||
schema_uri: http://justice.gov.uk/example/event/listener/example.events.cake-ordered.json | ||
event_source_name: indexer.event.source | ||
|
||
|
Oops, something went wrong.