Refactored module structure

This commit is contained in:
Michael Schnell
2019-12-30 18:49:39 +01:00
parent fd08bb49ef
commit 291cb9f255
45 changed files with 329 additions and 2052 deletions

View File

@@ -15,7 +15,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<esc.version>0.3.1-SNAPSHOT</esc.version>
<esc.version>0.3.1</esc.version>
</properties>
<dependencies>

View File

@@ -31,7 +31,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<esc.version>0.3.1-SNAPSHOT</esc.version>
<esc.version>0.3.1</esc.version>
</properties>
<dependencyManagement>
@@ -63,13 +63,13 @@
<dependency>
<groupId>org.fuin</groupId>
<artifactId>ddd-4-java</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>cqrs-4-java</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.2.1</version>
</dependency>
<dependency>
@@ -250,7 +250,7 @@
<dependency>
<groupId>org.fuin</groupId>
<artifactId>units4j</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
<scope>test</scope>
</dependency>

View File

@@ -25,7 +25,7 @@ import org.fuin.cqrs4j.example.javasecdi.cmd.domain.PersonRepository;
import org.fuin.cqrs4j.example.javasecdi.cmd.domain.PersonRepositoryFactory;
import org.fuin.cqrs4j.example.shared.PersonId;
import org.fuin.cqrs4j.example.shared.PersonName;
import org.fuin.esc.api.EventStore;
import org.fuin.esc.esjc.IESJCEventStore;
import org.fuin.ext4logback.LogbackStandalone;
import org.fuin.ext4logback.NewLogConfigFileParams;
import org.slf4j.Logger;
@@ -39,7 +39,7 @@ public class CmdExampleApp {
private static final Logger LOG = LoggerFactory.getLogger(CmdExampleApp.class);
@Inject
private Instance<EventStore> eventStoreInstance;
private Instance<IESJCEventStore> eventStoreInstance;
/**
* Executes the application.
@@ -49,7 +49,7 @@ public class CmdExampleApp {
LOG.info("Executing...");
try (final EventStore eventStore = eventStoreInstance.get()) {
try (final IESJCEventStore eventStore = eventStoreInstance.get()) {
final PersonId id = new PersonId(UUID.fromString("f645969a-402d-41a9-882b-d2d8000d0f43"));
final PersonName name = new PersonName("Peter Parker Inc.");

View File

@@ -4,7 +4,7 @@ import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import org.fuin.esc.api.EventStore;
import org.fuin.esc.esjc.IESJCEventStore;
/**
* CDI factory that creates an event store connection and repositories.
@@ -22,7 +22,7 @@ public class PersonRepositoryFactory {
*/
@Produces
@Dependent
public PersonRepository create(final EventStore eventStore) {
public PersonRepository create(final IESJCEventStore eventStore) {
return new PersonRepository(eventStore);
}

View File

@@ -11,19 +11,12 @@
<version>1.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.0.1.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.0.1.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
<failsafe-plugin.version>2.22.2</failsafe-plugin.version>
<esc.version>0.3.1-SNAPSHOT</esc.version>
<esc.version>0.3.1</esc.version>
</properties>
<dependencyManagement>
@@ -31,9 +24,9 @@
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom</artifactId>
<version>1.0.1.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -81,28 +74,34 @@
<artifactId>quarkus-mailer</artifactId>
</dependency>
<dependency>
<groupId>org.fuin.cqrs4j.example</groupId>
<artifactId>cqrs4j-example-aggregates</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.fuin.cqrs4j.example.quarkus</groupId>
<artifactId>cqrs4j-quarkus-example-shared</artifactId>
<version>0.1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.fuin.esc</groupId>
<artifactId>esc-esjc</artifactId>
<version>${esc.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>cqrs-4-java</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.2.1</version>
</dependency>
<dependency>
@@ -134,7 +133,7 @@
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<version>1.0.1.Final</version>
<executions>
<execution>
<goals>
@@ -146,12 +145,12 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<version>2.22.1</version>
<configuration>
<systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
@@ -161,7 +160,7 @@
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe-plugin.version}</version>
<version>2.22.2</version>
<executions>
<execution>
<goals>
@@ -241,7 +240,7 @@
</properties>
</profile>
</profiles>
<repositories>
<repository>

View File

@@ -12,6 +12,7 @@
*/
package org.fuin.cqrs4j.example.quarkus.command.api;
import java.util.Optional;
import java.util.Set;
import javax.inject.Inject;
@@ -29,10 +30,10 @@ import javax.ws.rs.core.UriInfo;
import org.fuin.cqrs4j.CommandExecutionFailedException;
import org.fuin.cqrs4j.SimpleResult;
import org.fuin.cqrs4j.example.quarkus.command.domain.DuplicatePersonNameException;
import org.fuin.cqrs4j.example.quarkus.command.domain.Person;
import org.fuin.cqrs4j.example.quarkus.command.domain.PersonRepository;
import org.fuin.cqrs4j.example.quarkus.shared.CreatePersonCommand;
import org.fuin.cqrs4j.example.aggregates.DuplicatePersonNameException;
import org.fuin.cqrs4j.example.aggregates.Person;
import org.fuin.cqrs4j.example.aggregates.PersonRepository;
import org.fuin.cqrs4j.example.shared.CreatePersonCommand;
import org.fuin.ddd4j.ddd.AggregateAlreadyExistsException;
import org.fuin.ddd4j.ddd.AggregateDeletedException;
@@ -65,7 +66,7 @@ public class PersonResource {
// Create aggregate
final Person person = new Person(cmd.getAggregateRootId(), cmd.getName(), (name) -> {
// TODO Execute a call to the query side to verify if the name already exists
return null;
return Optional.empty();
});
repo.add(person);

View File

@@ -1,64 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved. http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.command.app;
import java.nio.charset.Charset;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
import org.fuin.esc.api.EventStore;
import org.fuin.esc.esjc.ESJCEventStore;
import org.fuin.esc.spi.EnhancedMimeType;
import org.fuin.esc.spi.SerDeserializerRegistry;
/**
* CDI factory that creates an event store connection and repositories.
*/
@ApplicationScoped
public class EventStoreFactory {
/**
* Creates an event store.<br>
* <br>
* CAUTION: The returned event store instance is NOT thread safe.
*
* @param es Native event store API.
* @param registry Serialization registry.
*
* @return Dependent scope event store.
*/
@Produces
@RequestScoped
public EventStore createEventStore(final com.github.msemys.esjc.EventStore es,
final SerDeserializerRegistry registry) {
final EventStore eventstore = new ESJCEventStore(es, registry, registry,
EnhancedMimeType.create("application", "json", Charset.forName("utf-8")));
eventstore.open();
return eventstore;
}
/**
* Closes the event store when the context is disposed.
*
* @param es Event store to close.
*/
public void closeEventStore(@Disposes final EventStore es) {
es.close();
}
}

View File

@@ -1,63 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved. http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.command.domain;
import javax.validation.constraints.NotNull;
import org.fuin.cqrs4j.example.quarkus.shared.PersonId;
import org.fuin.cqrs4j.example.quarkus.shared.PersonName;
/**
* A name that should be unique does already exist.
*/
public final class DuplicatePersonNameException extends Exception {
private static final long serialVersionUID = 1000L;
private PersonId personId;
private PersonName name;
/**
* Constructor with mandatory data.
*
* @param personId
* Identifier of the resource that caused the problem.
* @param name
* Name of the resource that caused the problem.
*/
public DuplicatePersonNameException(@NotNull final PersonId personId, @NotNull final PersonName name) {
super("The name '" + name + "' already exists: " + personId.asString());
this.personId = personId;
this.name = name;
}
/**
* Returns the identifier of the entity that has the name.
*
* @return Identifier.
*/
public final PersonId getPersonId() {
return personId;
}
/**
* Returns the name that already exists.
*
* @return Name.
*/
public final PersonName getName() {
return name;
}
}

View File

@@ -1,116 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved. http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.command.domain;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import org.fuin.cqrs4j.example.quarkus.shared.PersonCreatedEvent;
import org.fuin.cqrs4j.example.quarkus.shared.PersonId;
import org.fuin.cqrs4j.example.quarkus.shared.PersonName;
import org.fuin.ddd4j.ddd.AbstractAggregateRoot;
import org.fuin.ddd4j.ddd.ApplyEvent;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.objects4j.common.Contract;
import io.quarkus.runtime.annotations.RegisterForReflection;
/**
* A medical practitioner most likely also holder of an accredited academic degree.
*/
@RegisterForReflection
public class Person extends AbstractAggregateRoot<PersonId> implements Serializable {
private static final long serialVersionUID = 1000L;
@NotNull
private PersonId id;
@NotNull
private PersonName name;
/**
* Default constructor that is mandatory for aggregate roots.
*/
public Person() {
super();
}
/**
* Constructor with all data.
*
* @param id
* Unique identifier of the person.
* @param name
* Unique name of the person.
* @param service
* Service required by the method.
*
* @throws DuplicatePersonNameException
* The name already exists for another person.
*/
public Person(@NotNull final PersonId id, @NotNull final PersonName name, final PersonService service) throws DuplicatePersonNameException {
super();
// VERIFY PRECONDITIONS
Contract.requireArgNotNull("id", id);
Contract.requireArgNotNull("name", name);
// VERIFY BUSINESS RULES
// Rule 1: The name of the person must be unique
final PersonId otherId = service.loadPersonIdByName(name);
if (otherId != null) {
throw new DuplicatePersonNameException(otherId, name);
}
// CREATE EVENT
apply(new PersonCreatedEvent(id, name));
}
@Override
public PersonId getId() {
return id;
}
@Override
public EntityType getType() {
return PersonId.TYPE;
}
@ApplyEvent
public void applyEvent(final PersonCreatedEvent event) {
this.id = event.getEntityId();
this.name = event.getName();
}
/**
* Service for the constructor.
*/
public static interface PersonService {
/**
* Loads the person's identifier for a given name.
*
* @param name
* Person's name.
*
* @return Office identifier or {@literal null} if not found.
*/
public PersonId loadPersonIdByName(@NotNull PersonName name);
}
}

View File

@@ -1,63 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved. http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.command.domain;
import javax.annotation.concurrent.NotThreadSafe;
import javax.validation.constraints.NotNull;
import org.fuin.cqrs4j.example.quarkus.shared.PersonId;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.esrepo.EventStoreRepository;
import org.fuin.esc.api.EventStore;
/**
* Event sourced repository for storing a {@link Person} aggregate.
*/
@NotThreadSafe
public class PersonRepository extends EventStoreRepository<PersonId, Person> {
/**
* Constructor all mandatory data.
*
* @param eventStore
* Event store.
*/
public PersonRepository(final EventStore eventStore) {
super(eventStore);
}
@Override
@NotNull
public Class<Person> getAggregateClass() {
return Person.class;
}
@Override
@NotNull
public EntityType getAggregateType() {
return PersonId.TYPE;
}
@Override
@NotNull
public Person create() {
return new Person();
}
@Override
@NotNull
public String getIdParamName() {
return "personId";
}
}

View File

@@ -16,7 +16,8 @@ import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import org.fuin.esc.api.EventStore;
import org.fuin.cqrs4j.example.aggregates.PersonRepository;
import org.fuin.esc.esjc.IESJCEventStore;
/**
* CDI factory that creates an event store connection and repositories.
@@ -34,7 +35,7 @@ public class PersonRepositoryFactory {
*/
@Produces
@Dependent
public PersonRepository create(final EventStore eventStore) {
public PersonRepository create(final IESJCEventStore eventStore) {
return new PersonRepository(eventStore);
}

View File

@@ -1,10 +1,5 @@
package org.fuin.cqrs4j.example.quarkus.command.api;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
@@ -21,21 +16,25 @@ import javax.json.bind.Jsonb;
import org.fuin.cqrs4j.ResultType;
import org.fuin.cqrs4j.SimpleResult;
import org.fuin.cqrs4j.example.quarkus.shared.CreatePersonCommand;
import org.fuin.cqrs4j.example.quarkus.shared.PersonCreatedEvent;
import org.fuin.cqrs4j.example.quarkus.shared.PersonId;
import org.fuin.cqrs4j.example.quarkus.shared.PersonName;
import org.fuin.cqrs4j.example.shared.CreatePersonCommand;
import org.fuin.cqrs4j.example.shared.PersonCreatedEvent;
import org.fuin.cqrs4j.example.shared.PersonId;
import org.fuin.cqrs4j.example.shared.PersonName;
import org.fuin.esc.api.CommonEvent;
import org.fuin.esc.api.EventStore;
import org.fuin.esc.api.SimpleStreamId;
import org.fuin.esc.api.StreamEventsSlice;
import org.fuin.esc.api.TypeName;
import org.fuin.esc.esjc.IESJCEventStore;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
@QuarkusTest
public class PersonResourceIT {
@Inject
EventStore eventStore;
IESJCEventStore eventStore;
@Inject
Jsonb jsonb;

View File

@@ -11,19 +11,12 @@
<version>1.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<esc.version>0.3.1-SNAPSHOT</esc.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.0.1.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.0.1.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
<failsafe-plugin.version>2.22.2</failsafe-plugin.version>
<esc.version>0.3.1</esc.version>
</properties>
<dependencyManagement>
@@ -31,9 +24,9 @@
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom</artifactId>
<version>1.0.1.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -83,22 +76,28 @@
<artifactId>jakarta.security.jacc-api</artifactId>
</dependency>
<dependency>
<groupId>org.fuin.cqrs4j.example</groupId>
<artifactId>cqrs4j-example-aggregates</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.fuin.cqrs4j.example.quarkus</groupId>
<artifactId>cqrs4j-quarkus-example-shared</artifactId>
<version>0.1.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.fuin.esc</groupId>
<artifactId>esc-eshttp</artifactId>
<version>${esc.version}</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- test -->
@@ -130,7 +129,7 @@
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus-plugin.version}</version>
<version>1.0.1.Final</version>
<executions>
<execution>
<goals>
@@ -142,12 +141,12 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<version>3.8.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<version>2.22.1</version>
<configuration>
<systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
@@ -157,7 +156,7 @@
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${failsafe-plugin.version}</version>
<version>2.22.2</version>
<executions>
<execution>
<goals>

View File

@@ -23,11 +23,11 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.fuin.cqrs4j.example.quarkus.query.domain.QryPerson;
import org.fuin.cqrs4j.example.quarkus.query.views.personlist.PersonListEntry;
import org.fuin.objects4j.vo.UUIDStrValidator;
@Path("/persons")
public class PersonResource {
public class QryPersonResource {
@Inject
EntityManager em;
@@ -35,7 +35,7 @@ public class PersonResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getAll() {
final List<QryPerson> persons = em.createNamedQuery(QryPerson.FIND_ALL, QryPerson.class).getResultList();
final List<PersonListEntry> persons = em.createNamedQuery(PersonListEntry.FIND_ALL, PersonListEntry.class).getResultList();
return Response.ok(persons).build();
}
@@ -46,7 +46,7 @@ public class PersonResource {
if (!UUIDStrValidator.isValid(id)) {
return Response.status(Response.Status.BAD_REQUEST).entity("Invalid Person UUID").build();
}
final QryPerson person = em.find(QryPerson.class, id);
final PersonListEntry person = em.find(PersonListEntry.class, id);
if (person == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}

View File

@@ -1,148 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved. http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.app;
import java.net.MalformedURLException;
import java.net.URL;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import org.eclipse.microprofile.config.inject.ConfigProperty;
/**
* Application configuration.
*/
@ApplicationScoped
public class QryConfig {
private static final String EVENT_STORE_HOST = "127.0.0.1";
private static final int EVENT_STORE_HTTP_PORT = 2113;
private static final int EVENT_STORE_TCP_PORT = 1113;
private static final String EVENT_STORE_USER = "admin";
private static final String EVENT_STORE_PASSWORD = "changeit";
@Inject
@ConfigProperty(name = "EVENT_STORE_HOST", defaultValue = EVENT_STORE_HOST)
String eventStoreHost;
@Inject
@ConfigProperty(name = "EVENT_STORE_HTTP_PORT", defaultValue = "" + EVENT_STORE_HTTP_PORT)
int eventStoreHttpPort;
@Inject
@ConfigProperty(name = "EVENT_STORE_TCP_PORT", defaultValue = "" + EVENT_STORE_TCP_PORT)
int eventStoreTcpPort;
@Inject
@ConfigProperty(name = "EVENT_STORE_USER", defaultValue = EVENT_STORE_USER)
String eventStoreUser;
@Inject
@ConfigProperty(name = "EVENT_STORE_PASSWORD", defaultValue = EVENT_STORE_PASSWORD)
String eventStorePassword;
/**
* Constructor using default values internally.
*/
public QryConfig() {
super();
this.eventStoreHost = EVENT_STORE_HOST;
this.eventStoreHttpPort = EVENT_STORE_HTTP_PORT;
this.eventStoreTcpPort = EVENT_STORE_TCP_PORT;
this.eventStoreUser = EVENT_STORE_USER;
this.eventStorePassword = EVENT_STORE_PASSWORD;
}
/**
* Constructor with all data.
*
* @param eventStoreHost Host.
* @param eventStoreHttpPort HTTP port
* @param eventStoreTcpPort TCP port.
* @param eventStoreUser User.
* @param eventStorePassword Password.
*/
public QryConfig(final String eventStoreHost, final int eventStoreHttpPort, final int eventStoreTcpPort,
final String eventStoreUser, final String eventStorePassword) {
super();
this.eventStoreHost = eventStoreHost;
this.eventStoreHttpPort = eventStoreHttpPort;
this.eventStoreTcpPort = eventStoreTcpPort;
this.eventStoreUser = eventStoreUser;
this.eventStorePassword = eventStorePassword;
}
/**
* Returns the host name of the event store.
*
* @return Name.
*/
public String getEventStoreHost() {
return eventStoreHost;
}
/**
* Returns the HTTP port of the event store.
*
* @return Port.
*/
public int getEventStoreHttpPort() {
return eventStoreHttpPort;
}
/**
* Returns the TCP port of the event store.
*
* @return Port.
*/
public int getEventStoreTcpPort() {
return eventStoreTcpPort;
}
/**
* Returns the username of the event store.
*
* @return Username.
*/
public String getEventStoreUser() {
return eventStoreUser;
}
/**
* Returns the password of the event store.
*
* @return Password.
*/
public String getEventStorePassword() {
return eventStorePassword;
}
/**
* Creates a URL with parameters from the config.
*
* @return Event store base URL.
*/
public URL getEventStoreURL() {
try {
return new URL("http", eventStoreHost, eventStoreHttpPort, "/");
} catch (final MalformedURLException ex) {
throw new RuntimeException("Failed to create event store URL", ex);
}
}
}

View File

@@ -1,44 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved. http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.app;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.cqrs4j.example.quarkus.shared.SharedUtils;
/**
* CDI factory that creates a JSON-B instance.
*/
@ApplicationScoped
public class QryJsonbFactory {
/**
* Creates a JSON-B instance.
*
* @return Fully configured instance.
*/
@Produces
public Jsonb createJsonb() {
final JsonbConfig config = new JsonbConfig()
.withAdapters(SharedUtils.JSONB_ADAPTERS)
.withPropertyVisibilityStrategy(new FieldAccessStrategy());
final Jsonb jsonb = JsonbBuilder.create(config);
return jsonb;
}
}

View File

@@ -1,47 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved. http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.app;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import org.fuin.cqrs4j.example.quarkus.shared.SharedUtils;
import org.fuin.esc.spi.JsonbDeSerializer;
import org.fuin.esc.spi.SerDeserializerRegistry;
import org.fuin.esc.spi.SerializedDataTypeRegistry;
/**
* CDI bean that creates a {@link SerDeserializerRegistry}.
*/
@ApplicationScoped
public class QrySerDeserializerRegistryFactory {
@Produces
@ApplicationScoped
public SerDeserializerRegistry createRegistry() {
// Knows about all types for usage with JSON-B
final SerializedDataTypeRegistry typeRegistry = SharedUtils.createTypeRegistry();
// Does the actual marshalling/unmarshalling
final JsonbDeSerializer jsonbDeSer = SharedUtils.createJsonbDeSerializer();
// Registry connects the type with the appropriate serializer and de-serializer
final SerDeserializerRegistry serDeserRegistry = SharedUtils.createSerDeserializerRegistry(typeRegistry,
jsonbDeSer);
return serDeserRegistry;
}
}

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.handler;
package org.fuin.cqrs4j.example.quarkus.query.views.common;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -27,7 +27,7 @@ import org.fuin.objects4j.common.Contract;
*/
@Entity
@Table(name = "QRY_PERSON_PROJECTION_POS")
public class QryPersonProjectionPosition {
public class ProjectionPosition {
@Id
@Column(name = "STREAM_ID", nullable = false, length = 250, updatable = false)
@@ -41,7 +41,7 @@ public class QryPersonProjectionPosition {
/**
* JPA constructor.
*/
protected QryPersonProjectionPosition() {
protected ProjectionPosition() {
super();
}
@@ -53,7 +53,7 @@ public class QryPersonProjectionPosition {
* @param nextPos
* Next position from the stream to read.
*/
public QryPersonProjectionPosition(@NotNull final StreamId streamId, @NotNull final Long nextPos) {
public ProjectionPosition(@NotNull final StreamId streamId, @NotNull final Long nextPos) {
super();
Contract.requireArgNotNull("streamId", streamId);
Contract.requireArgNotNull("nextPos", nextPos);

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.handler;
package org.fuin.cqrs4j.example.quarkus.query.views.common;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
@@ -25,7 +25,7 @@ import org.fuin.objects4j.common.Contract;
* Repository that contains the position of the stream.
*/
@ApplicationScoped
public class QryPersonProjectionPositionRepository implements ProjectionService {
public class ProjectionPositionRepository implements ProjectionService {
@Inject
EntityManager em;
@@ -33,7 +33,7 @@ public class QryPersonProjectionPositionRepository implements ProjectionService
@Override
public void resetProjectionPosition(@NotNull final StreamId streamId) {
Contract.requireArgNotNull("streamId", streamId);
final QryPersonProjectionPosition pos = em.find(QryPersonProjectionPosition.class, streamId.asString());
final ProjectionPosition pos = em.find(ProjectionPosition.class, streamId.asString());
if (pos != null) {
pos.setNextPosition(0L);
}
@@ -42,7 +42,7 @@ public class QryPersonProjectionPositionRepository implements ProjectionService
@Override
public Long readProjectionPosition(@NotNull StreamId streamId) {
Contract.requireArgNotNull("streamId", streamId);
final QryPersonProjectionPosition pos = em.find(QryPersonProjectionPosition.class, streamId.asString());
final ProjectionPosition pos = em.find(ProjectionPosition.class, streamId.asString());
if (pos == null) {
return 0L;
}
@@ -53,9 +53,9 @@ public class QryPersonProjectionPositionRepository implements ProjectionService
public void updateProjectionPosition(@NotNull StreamId streamId, @NotNull Long nextEventNumber) {
Contract.requireArgNotNull("streamId", streamId);
Contract.requireArgNotNull("nextEventNumber", nextEventNumber);
final QryPersonProjectionPosition pos = em.find(QryPersonProjectionPosition.class, streamId.asString());
final ProjectionPosition pos = em.find(ProjectionPosition.class, streamId.asString());
if (pos == null) {
em.persist(new QryPersonProjectionPosition(streamId, nextEventNumber));
em.persist(new ProjectionPosition(streamId, nextEventNumber));
} else {
pos.setNextPosition(nextEventNumber);
em.merge(pos);

View File

@@ -10,8 +10,9 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.handler;
package org.fuin.cqrs4j.example.quarkus.query.views;
/**
* Code related to event handlers.
* Contains the views used in this query application. A view never uses code of another view, means all views are completely independent of
* each other. As an exception, the 'commons' package has some small classes that are not view specific.
*/

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.handler;
package org.fuin.cqrs4j.example.quarkus.query.views.personlist;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
@@ -18,9 +18,8 @@ import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.fuin.cqrs4j.EventHandler;
import org.fuin.cqrs4j.example.quarkus.query.domain.QryPerson;
import org.fuin.cqrs4j.example.quarkus.shared.PersonCreatedEvent;
import org.fuin.cqrs4j.example.quarkus.shared.PersonId;
import org.fuin.cqrs4j.example.shared.PersonCreatedEvent;
import org.fuin.cqrs4j.example.shared.PersonId;
import org.fuin.ddd4j.ddd.EventType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,8 +45,8 @@ public class PersonCreatedEventHandler implements EventHandler<PersonCreatedEven
public void handle(final PersonCreatedEvent event) {
LOG.info("Handle " + event.getClass().getSimpleName() + ": " + event);
final PersonId personId = event.getEntityId();
if (em.find(QryPerson.class, personId.asString()) == null) {
em.persist(new QryPerson(personId, event.getName()));
if (em.find(PersonListEntry.class, personId.asString()) == null) {
em.persist(new PersonListEntry(personId, event.getName()));
}
}

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.domain;
package org.fuin.cqrs4j.example.quarkus.query.views.personlist;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -23,8 +23,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.fuin.cqrs4j.example.quarkus.shared.PersonId;
import org.fuin.cqrs4j.example.quarkus.shared.PersonName;
import org.fuin.cqrs4j.example.shared.PersonId;
import org.fuin.cqrs4j.example.shared.PersonName;
import org.fuin.objects4j.common.Contract;
import io.quarkus.runtime.annotations.RegisterForReflection;
@@ -33,14 +33,14 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
* Represents a person that will be stored in the database.
*/
@Entity
@Table(name = "QRY_PERSON")
@Table(name = "PERSON_LIST")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "qry-person")
@NamedQuery(name = QryPerson.FIND_ALL, query = "SELECT p FROM QryPerson p")
@XmlRootElement(name = "person")
@NamedQuery(name = PersonListEntry.FIND_ALL, query = "SELECT p FROM PersonListEntry p")
@RegisterForReflection
public class QryPerson {
public class PersonListEntry {
public static final String FIND_ALL = "QryPerson.findAll";
public static final String FIND_ALL = "PersonListEntry.findAll";
@Id
@Column(name = "ID", nullable = false, length = 36, updatable = false)
@@ -56,7 +56,7 @@ public class QryPerson {
/**
* JAX-B constructor.
*/
protected QryPerson() {
protected PersonListEntry() {
super();
}
@@ -68,7 +68,7 @@ public class QryPerson {
* @param name
* Name of the created person
*/
public QryPerson(@NotNull final PersonId id, @NotNull final PersonName name) {
public PersonListEntry(@NotNull final PersonId id, @NotNull final PersonName name) {
super();
Contract.requireArgNotNull("id", id);
Contract.requireArgNotNull("name", name);
@@ -109,7 +109,7 @@ public class QryPerson {
@Override
public String toString() {
return "QryPerson [id=" + id + ", name=" + name + "]";
return "PersonListEntry [id=" + id + ", name=" + name + "]";
}
}

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.handler;
package org.fuin.cqrs4j.example.quarkus.query.views.personlist;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
@@ -25,9 +25,9 @@ import org.slf4j.LoggerFactory;
@ApplicationScoped
@Transactional
public class QryEventChunkHandler {
public class PersonListEventChunkHandler {
private static final Logger LOG = LoggerFactory.getLogger(QryEventChunkHandler.class);
private static final Logger LOG = LoggerFactory.getLogger(PersonListEventChunkHandler.class);
/** Unique name of the event store projection that is used. */
public static final ProjectionStreamId PROJECTION_STREAM_ID = new ProjectionStreamId("qry-person-stream");

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.handler;
package org.fuin.cqrs4j.example.quarkus.query.views.personlist;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
@@ -22,7 +22,7 @@ import org.fuin.cqrs4j.SimpleEventDispatcher;
* Create an {@link EventDispatcher}.
*/
@ApplicationScoped
public class QryEventDispatcherFactory {
public class PersonListEventDispatcherFactory {
@Produces
@ApplicationScoped

View File

@@ -10,10 +10,10 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.handler;
package org.fuin.cqrs4j.example.quarkus.query.views.personlist;
import static org.fuin.cqrs4j.Cqrs4JUtils.tryLocked;
import static org.fuin.cqrs4j.example.quarkus.query.handler.QryEventChunkHandler.PROJECTION_STREAM_ID;
import static org.fuin.cqrs4j.example.quarkus.query.views.personlist.PersonListEventChunkHandler.PROJECTION_STREAM_ID;
import java.util.ArrayList;
import java.util.List;
@@ -27,9 +27,8 @@ import javax.inject.Inject;
import org.fuin.cqrs4j.EventDispatcher;
import org.fuin.cqrs4j.example.quarkus.query.app.QryCheckForViewUpdatesEvent;
import org.fuin.ddd4j.ddd.EventType;
import org.fuin.esc.api.EventStore;
import org.fuin.esc.api.ProjectionAdminEventStore;
import org.fuin.esc.api.TypeName;
import org.fuin.esc.eshttp.IESHttpEventStore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,9 +36,9 @@ import org.slf4j.LoggerFactory;
* Reads incoming events from an attached event store and dispatches them to the appropriate event handlers.
*/
@ApplicationScoped
public class QryProjector {
public class PersonListProjector {
private static final Logger LOG = LoggerFactory.getLogger(QryProjector.class);
private static final Logger LOG = LoggerFactory.getLogger(PersonListProjector.class);
/** Prevents more than one projector thread running at a time. */
private static final Semaphore LOCK = new Semaphore(1);
@@ -48,13 +47,10 @@ public class QryProjector {
// Above LOCK prevents multithreaded access
@Inject
ProjectionAdminEventStore eventstore;
IESHttpEventStore eventstore;
@Inject
EventStore eventStore;
@Inject
QryEventChunkHandler chunkHandler;
PersonListEventChunkHandler chunkHandler;
@Inject
EventDispatcher dispatcher;
@@ -92,7 +88,7 @@ public class QryProjector {
// Read and dispatch events
final Long nextEventNumber = chunkHandler.readNextEventNumber();
eventStore.readAllEventsForward(PROJECTION_STREAM_ID, nextEventNumber, 100, (currentSlice) -> {
eventstore.readAllEventsForward(PROJECTION_STREAM_ID, nextEventNumber, 100, (currentSlice) -> {
chunkHandler.handleChunk(currentSlice);
});

View File

@@ -10,8 +10,8 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.domain;
package org.fuin.cqrs4j.example.quarkus.query.views.personlist;
/**
* Domain specific code like view objects.
* Classes building the 'person list' view.
*/

View File

@@ -16,25 +16,25 @@ import javax.enterprise.context.control.ActivateRequestContext;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import org.fuin.cqrs4j.example.quarkus.query.domain.QryPerson;
import org.fuin.cqrs4j.example.quarkus.shared.PersonCreatedEvent;
import org.fuin.cqrs4j.example.quarkus.shared.PersonId;
import org.fuin.cqrs4j.example.quarkus.shared.PersonName;
import org.fuin.cqrs4j.example.quarkus.query.views.personlist.PersonListEntry;
import org.fuin.cqrs4j.example.shared.PersonCreatedEvent;
import org.fuin.cqrs4j.example.shared.PersonId;
import org.fuin.cqrs4j.example.shared.PersonName;
import org.fuin.esc.api.CommonEvent;
import org.fuin.esc.api.EventId;
import org.fuin.esc.api.EventStore;
import org.fuin.esc.api.SimpleCommonEvent;
import org.fuin.esc.api.SimpleStreamId;
import org.fuin.esc.api.TypeName;
import org.fuin.esc.eshttp.IESHttpEventStore;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;
@QuarkusTest
public class PersonResourceIT {
public class QryPersonResourceIT {
@Inject
EventStore eventStore;
IESHttpEventStore eventStore;
@Inject
EntityManager em;
@@ -51,7 +51,7 @@ public class PersonResourceIT {
@ActivateRequestContext
public boolean findPerson(final PersonId personId) {
return em.find(QryPerson.class, personId.asString()) != null;
return em.find(PersonListEntry.class, personId.asString()) != null;
}
@Test
@@ -70,7 +70,7 @@ public class PersonResourceIT {
// TEST & VERIFY
final QryPerson person =
final PersonListEntry person =
given()
.pathParam("id", personId.asString())
.when()
@@ -78,21 +78,21 @@ public class PersonResourceIT {
.then()
.statusCode(200)
.extract()
.as(QryPerson.class);
.as(PersonListEntry.class);
assertThat(person.getId(), is(equalTo(personId)));
assertThat(person.getName(), is(equalTo(personName)));
final QryPerson[] persons =
final PersonListEntry[] persons =
given()
.when()
.get("/persons")
.then()
.statusCode(200)
.extract()
.as(QryPerson[].class);
.as(PersonListEntry[].class);
assertThat(Arrays.asList(persons), is(not(empty())));
final QryPerson person0 = persons[0];
final PersonListEntry person0 = persons[0];
assertThat(person0.getId(), is(equalTo(personId)));
assertThat(person0.getName(), is(equalTo(personName)));

View File

@@ -1,135 +1,168 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.fuin.cqrs4j.example.quarkus</groupId>
<artifactId>cqrs4j-quarkus-example-shared</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>cqrs4j-quarkus-example-shared</name>
<description>Quarkus CQRS Shared Code for Demo Application</description>
<groupId>org.fuin.cqrs4j.example.quarkus</groupId>
<artifactId>cqrs4j-quarkus-example-shared</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>cqrs4j-quarkus-example-shared</name>
<description>Quarkus CQRS Shared Code for Demo Application</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<esc.version>0.3.1-SNAPSHOT</esc.version>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<esc.version>0.3.1</esc.version>
</properties>
<dependencies>
<dependencyManagement>
<!-- Compile -->
<dependencies>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>ddd-4-java</artifactId>
<version>0.2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom</artifactId>
<version>1.0.1.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>cqrs-4-java</artifactId>
<version>0.2.1-SNAPSHOT</version>
</dependency>
</dependencies>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>objects4j</artifactId>
<version>0.6.9-SNAPSHOT</version>
</dependency>
</dependencyManagement>
<dependency>
<groupId>org.fuin.esc</groupId>
<artifactId>esc-spi</artifactId>
<version>${esc.version}</version>
</dependency>
<dependencies>
<dependency>
<groupId>org.fuin.esc</groupId>
<artifactId>esc-api</artifactId>
<version>${esc.version}</version>
</dependency>
<!-- Compile -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.fuin.cqrs4j.example</groupId>
<artifactId>cqrs4j-example-shared</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.10.Final</version>
<exclusions>
<exclusion>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
<exclusion>
<artifactId>jaxb-api</artifactId>
<groupId>javax.xml.bind</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>ddd-4-java</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>cqrs-4-java</artifactId>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>objects4j</artifactId>
<version>0.6.9</version>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>org.fuin.esc</groupId>
<artifactId>esc-esjc</artifactId>
<version>${esc.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>org.fuin.esc</groupId>
<artifactId>esc-eshttp</artifactId>
<version>${esc.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-context-propagation</artifactId>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>units4j</artifactId>
<version>0.8.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>2.4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.config</groupId>
<artifactId>microprofile-config-api</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<exclusions>
<exclusion>
<artifactId>jaxb-impl</artifactId>
<groupId>com.sun.xml.bind</groupId>
</exclusion>
<exclusion>
<artifactId>jaxb-api</artifactId>
<groupId>javax.xml.bind</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.10.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>units4j</artifactId>
<version>0.8.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>2.4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.command.app;
package org.fuin.cqrs4j.example.quarkus.shared;
import java.net.MalformedURLException;
import java.net.URL;

View File

@@ -1,88 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import javax.annotation.concurrent.Immutable;
import javax.json.bind.annotation.JsonbProperty;
import javax.validation.constraints.NotNull;
import org.fuin.cqrs4j.AbstractAggregateCommand;
import org.fuin.ddd4j.ddd.DomainEventExpectedEntityIdPath;
import org.fuin.ddd4j.ddd.EventType;
import org.fuin.esc.spi.SerializedDataType;
import org.fuin.objects4j.common.Contract;
/**
* A new person should be created in the system.
*/
@Immutable
@DomainEventExpectedEntityIdPath(PersonId.class)
public final class CreatePersonCommand extends AbstractAggregateCommand<PersonId, PersonId> {
private static final long serialVersionUID = 1000L;
/** Never changing unique event type name. */
public static final EventType TYPE = new EventType("CreatePersonCommand");
/** Unique name used for marshalling/unmarshalling the event. */
public static final SerializedDataType SER_TYPE = new SerializedDataType(CreatePersonCommand.TYPE.asBaseType());
@NotNull
@JsonbProperty("name")
private PersonName name;
/**
* Protected default constructor for deserialization.
*/
protected CreatePersonCommand() {
super();
}
/**
* A new person was created in the system.
*
* @param id Identifies uniquely a person.
* @param name Name of a person.
*/
public CreatePersonCommand(@NotNull final PersonId id, @NotNull final PersonName name) {
super(id, null);
Contract.requireArgNotNull("name", name);
this.name = name;
}
@Override
public final EventType getEventType() {
return CreatePersonCommand.TYPE;
}
/**
* Returns: Name of a person.
*
* @return Current value.
*/
@NotNull
public final PersonName getName() {
return name;
}
@Override
public final String toString() {
return "Create person '" + name + "' with identifier '" + getAggregateRootId() + "'";
}
}

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.command.app;
package org.fuin.cqrs4j.example.quarkus.shared;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;

View File

@@ -10,13 +10,15 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.query.app;
package org.fuin.cqrs4j.example.quarkus.shared;
import java.nio.charset.Charset;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
@@ -27,16 +29,50 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
import org.fuin.esc.eshttp.ESEnvelopeType;
import org.fuin.esc.eshttp.ESHttpEventStore;
import org.fuin.esc.eshttp.IESHttpEventStore;
import org.fuin.esc.esjc.ESJCEventStore;
import org.fuin.esc.esjc.IESJCEventStore;
import org.fuin.esc.spi.EnhancedMimeType;
import org.fuin.esc.spi.SerDeserializerRegistry;
/**
* CDI factory that creates an event store connection and repositories.
*/
@ApplicationScoped
public class QryEventStoreFactory {
public class EventStoreFactory {
/**
* Creates an event store.<br>
* Creates an ESJC event store.<br>
* <br>
* CAUTION: The returned event store instance is NOT thread safe.
*
* @param es Native event store API.
* @param registry Serialization registry.
*
* @return Dependent scope event store.
*/
@Produces
@RequestScoped
public IESJCEventStore createEventStore(final com.github.msemys.esjc.EventStore es,
final SerDeserializerRegistry registry) {
final IESJCEventStore eventstore = new ESJCEventStore(es, registry, registry,
EnhancedMimeType.create("application", "json", Charset.forName("utf-8")));
eventstore.open();
return eventstore;
}
/**
* Closes the ESJC event store when the context is disposed.
*
* @param es Event store to close.
*/
public void closeEventStore(@Disposes final IESJCEventStore es) {
es.close();
}
/**
* Creates an HTTP event store.<br>
* <br>
* CAUTION: The returned event store instance is NOT thread safe.
*
@@ -49,7 +85,7 @@ public class QryEventStoreFactory {
*/
@Produces
@Dependent
public IESHttpEventStore createEventStore(final QryConfig config, final SerDeserializerRegistry registry) {
public IESHttpEventStore createEventStore(final Config config, final SerDeserializerRegistry registry) {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(config.getEventStoreUser(),
@@ -64,7 +100,7 @@ public class QryEventStoreFactory {
}
/**
* Closes the event store when the context is disposed.
* Closes the HTTP event store when the context is disposed.
*
* @param es
* Event store to close.
@@ -72,5 +108,5 @@ public class QryEventStoreFactory {
public void closeEventStore(@Disposes final IESHttpEventStore es) {
es.close();
}
}

View File

@@ -10,7 +10,7 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.command.app;
package org.fuin.cqrs4j.example.quarkus.shared;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
@@ -19,7 +19,7 @@ import javax.json.bind.JsonbBuilder;
import javax.json.bind.JsonbConfig;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.cqrs4j.example.quarkus.shared.SharedUtils;
import org.fuin.cqrs4j.example.shared.SharedUtils;
/**
* CDI factory that creates a JSON-B instance.
@@ -37,8 +37,7 @@ public class JsonbFactory {
final JsonbConfig config = new JsonbConfig()
.withAdapters(SharedUtils.JSONB_ADAPTERS)
.withPropertyVisibilityStrategy(new FieldAccessStrategy());
final Jsonb jsonb = JsonbBuilder.create(config);
return jsonb;
return JsonbBuilder.create(config);
}
}

View File

@@ -1,87 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import javax.annotation.concurrent.Immutable;
import javax.json.bind.annotation.JsonbProperty;
import javax.validation.constraints.NotNull;
import org.fuin.ddd4j.ddd.AbstractDomainEvent;
import org.fuin.ddd4j.ddd.EntityIdPath;
import org.fuin.ddd4j.ddd.EventType;
import org.fuin.esc.spi.SerializedDataType;
import org.fuin.objects4j.common.Contract;
/**
* A new person was created in the system.
*/
@Immutable
public final class PersonCreatedEvent extends AbstractDomainEvent<PersonId> {
private static final long serialVersionUID = 1000L;
/** Never changing unique event type name. */
public static final EventType TYPE = new EventType("PersonCreatedEvent");
/** Unique name used for marshalling/unmarshalling the event. */
public static final SerializedDataType SER_TYPE = new SerializedDataType(PersonCreatedEvent.TYPE.asBaseType());
@NotNull
@JsonbProperty("name")
private PersonName name;
/**
* Protected default constructor for deserialization.
*/
protected PersonCreatedEvent() {
super();
}
/**
* A new person was created in the system.
*
* @param id Identifies uniquely a person.
* @param name Name of a person.
*/
public PersonCreatedEvent(@NotNull final PersonId id, @NotNull final PersonName name) {
super(new EntityIdPath(id));
Contract.requireArgNotNull("name", name);
this.name = name;
}
@Override
public final EventType getEventType() {
return PersonCreatedEvent.TYPE;
}
/**
* Returns: Name of a person.
*
* @return Current value.
*/
@NotNull
public final PersonName getName() {
return name;
}
@Override
public final String toString() {
return "Person '" + name + "' was created";
}
}

View File

@@ -1,148 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import java.util.UUID;
import javax.annotation.concurrent.Immutable;
import javax.json.bind.adapter.JsonbAdapter;
import javax.validation.constraints.NotNull;
import org.fuin.ddd4j.ddd.AggregateRootUuid;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
import org.fuin.objects4j.ui.Label;
import org.fuin.objects4j.ui.ShortLabel;
import org.fuin.objects4j.ui.Tooltip;
import org.fuin.objects4j.vo.ValueObjectConverter;
/**
* Identifies uniquely a person.
*/
@ShortLabel(bundle = "ddd-cqrs-4-java-example", key = "PersonId.slabel", value = "PID")
@Label(bundle = "ddd-cqrs-4-java-example", key = "PersonId.label", value = "Person's ID")
@Tooltip(bundle = "ddd-cqrs-4-java-example", key = "PersonId.tooltip", value = "Unique identifier of a person")
@Immutable
public final class PersonId extends AggregateRootUuid {
private static final long serialVersionUID = 1000L;
/** Unique name of the aggregate this identifier refers to. */
public static final EntityType TYPE = new StringBasedEntityType("PERSON");
/**
* Default constructor.
*/
protected PersonId() {
super(PersonId.TYPE);
}
/**
* Constructor with all data.
*
* @param value
* Persistent value.
*/
public PersonId(@NotNull final UUID value) {
super(PersonId.TYPE, value);
}
/**
* Verifies if the given string can be converted into a Person ID.
*
* @param value
* String with valid UUID string. A <code>null</code> value ris also valid.
*
* @return {@literal true} if the string is a valid UUID.
*/
public static boolean isValid(final String value) {
if (value == null) {
return true;
}
return AggregateRootUuid.isValid(value);
}
/**
* Parses a given string and returns a new instance of PersonId.
*
* @param value
* String with valid UUID to convert. A <code>null</code> value returns <code>null</code>.
*
* @return Converted value.
*/
public static PersonId valueOf(final String value) {
if (value == null) {
return null;
}
AggregateRootUuid.requireArgValid("value", value);
return new PersonId(UUID.fromString(value));
}
/**
* Converts the value object from/to UUID.
*/
public static final class Converter implements ValueObjectConverter<UUID, PersonId>, JsonbAdapter<PersonId, UUID> {
// Attribute Converter
@Override
public final Class<UUID> getBaseTypeClass() {
return UUID.class;
}
@Override
public final Class<PersonId> getValueObjectClass() {
return PersonId.class;
}
@Override
public boolean isValid(final UUID value) {
return true;
}
@Override
public final PersonId toVO(final UUID value) {
if (value == null) {
return null;
}
return new PersonId(value);
}
@Override
public final UUID fromVO(final PersonId value) {
if (value == null) {
return null;
}
return value.asBaseType();
}
// JSONB Adapter
@Override
public final UUID adaptToJson(final PersonId obj) throws Exception {
return fromVO(obj);
}
@Override
public final PersonId adaptFromJson(final UUID value) throws Exception {
return toVO(value);
}
}
}

View File

@@ -1,216 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.annotation.concurrent.Immutable;
import javax.json.bind.adapter.JsonbAdapter;
import javax.validation.Constraint;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import javax.validation.Payload;
import javax.validation.constraints.NotNull;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.fuin.objects4j.ui.Label;
import org.fuin.objects4j.ui.ShortLabel;
import org.fuin.objects4j.ui.Tooltip;
import org.fuin.objects4j.vo.AbstractStringValueObject;
import org.fuin.objects4j.vo.ValueObjectConverter;
/**
* Name of a person.
*/
@ShortLabel(bundle = "ddd-cqrs-4-java-example", key = "PersonName.slabel", value = "PNAME")
@Label(bundle = "ddd-cqrs-4-java-example", key = "PersonName.label", value = "Person's name")
@Tooltip(bundle = "ddd-cqrs-4-java-example", key = "PersonName.tooltip", value = "Name of a person")
@Immutable
public final class PersonName extends AbstractStringValueObject {
private static final long serialVersionUID = 1000L;
/** Max length of a person's name. */
public static final int MAX_LENGTH = 100;
@NotNull
@PersonNameStr
private String value;
/**
* Protected default constructor for deserialization.
*/
protected PersonName() {
super();
}
/**
* Constructor with mandatory data.
*
* @param value Value.
*/
public PersonName(final String value) {
super();
PersonName.requireArgValid("value", value);
this.value = value;
}
@Override
public final String asBaseType() {
return value;
}
@Override
public final String toString() {
return value;
}
/**
* Verifies that a given string can be converted into the type.
*
* @param value Value to validate.
*
* @return Returns <code>true</code> if it's a valid type else
* <code>false</code>.
*/
public static boolean isValid(final String value) {
if (value == null) {
return true;
}
if (value.length() == 0) {
return false;
}
final String trimmed = value.trim();
if (trimmed.length() > PersonName.MAX_LENGTH) {
return false;
}
return true;
}
/**
* Verifies if the argument is valid and throws an exception if this is not the
* case.
*
* @param name Name of the value for a possible error message.
* @param value Value to check.
*
* @throws ConstraintViolationException The value was not valid.
*/
public static void requireArgValid(@NotNull final String name, @NotNull final String value)
throws ConstraintViolationException {
if (!PersonName.isValid(value)) {
throw new ConstraintViolationException("The argument '" + name + "' is not valid: '" + value + "'");
}
}
/**
* Ensures that the string can be converted into the type.
*/
@Target({ ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { Validator.class })
@Documented
public static @interface PersonNameStr {
String message()
default "{org.fuin.cqrs4j.example.javasecdi.PersonName.message}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
/**
* Validates if a string is compliant with the type.
*/
public static final class Validator implements ConstraintValidator<PersonNameStr, String> {
@Override
public final void initialize(final PersonNameStr annotation) {
// Not used
}
@Override
public final boolean isValid(final String value, final ConstraintValidatorContext context) {
return PersonName.isValid(value);
}
}
/**
* Converts the value object from/to string.
*/
public static final class Converter
implements ValueObjectConverter<String, PersonName>, JsonbAdapter<PersonName, String> {
// Attribute Converter
@Override
public final Class<String> getBaseTypeClass() {
return String.class;
}
@Override
public final Class<PersonName> getValueObjectClass() {
return PersonName.class;
}
@Override
public boolean isValid(final String value) {
return PersonName.isValid(value);
}
@Override
public final PersonName toVO(final String value) {
if (value == null) {
return null;
}
return new PersonName(value);
}
@Override
public final String fromVO(final PersonName value) {
if (value == null) {
return null;
}
return value.asBaseType();
}
// JSONB Adapter
@Override
public final String adaptToJson(final PersonName obj) throws Exception {
return fromVO(obj);
}
@Override
public final PersonName adaptFromJson(final String str) throws Exception {
return toVO(str);
}
}
}

View File

@@ -10,12 +10,12 @@
* You should have received a copy of the GNU Lesser General Public License along with this library. If not, see
* http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.command.app;
package org.fuin.cqrs4j.example.quarkus.shared;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import org.fuin.cqrs4j.example.quarkus.shared.SharedUtils;
import org.fuin.cqrs4j.example.shared.SharedUtils;
import org.fuin.esc.spi.JsonbDeSerializer;
import org.fuin.esc.spi.SerDeserializerRegistry;
import org.fuin.esc.spi.SerializedDataTypeRegistry;
@@ -37,11 +37,9 @@ public class SerDeserializerRegistryFactory {
final JsonbDeSerializer jsonbDeSer = SharedUtils.createJsonbDeSerializer();
// Registry connects the type with the appropriate serializer and de-serializer
final SerDeserializerRegistry serDeserRegistry = SharedUtils.createSerDeserializerRegistry(typeRegistry,
return SharedUtils.createSerDeserializerRegistry(typeRegistry,
jsonbDeSer);
return serDeserRegistry;
}
}

View File

@@ -1,70 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import org.fuin.ddd4j.ddd.EntityId;
import org.fuin.ddd4j.ddd.EntityIdFactory;
/**
* Factory that creates entity identifier instances based on the type.
*/
public final class SharedEntityIdFactory implements EntityIdFactory {
private Map<String, Function<String, EntityId>> valueOfMap;
private Map<String, Function<String, Boolean>> isValidMap;
/**
* Default constructor.
*/
public SharedEntityIdFactory() {
super();
valueOfMap = new HashMap<>();
isValidMap = new HashMap<>();
valueOfMap.put(PersonId.TYPE.asString(), PersonId::valueOf);
isValidMap.put(PersonId.TYPE.asString(), PersonId::isValid);
}
@Override
public EntityId createEntityId(final String type, final String id) {
final Function<String, EntityId> factory = valueOfMap.get(type);
if (factory == null) {
throw new IllegalArgumentException("Unknown type: " + type);
}
return factory.apply(id);
}
@Override
public boolean containsType(final String type) {
return valueOfMap.containsKey(type);
}
@Override
public boolean isValid(String type, String id) {
final Function<String, Boolean> func = isValidMap.get(type);
if (func == null) {
return false;
}
return func.apply(id);
}
}

View File

@@ -1,189 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import java.nio.charset.Charset;
import javax.json.bind.adapter.JsonbAdapter;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.ddd4j.ddd.AggregateVersionConverter;
import org.fuin.ddd4j.ddd.EntityIdConverter;
import org.fuin.ddd4j.ddd.EntityIdPathConverter;
import org.fuin.ddd4j.ddd.EventIdConverter;
import org.fuin.esc.spi.Base64Data;
import org.fuin.esc.spi.EscEvent;
import org.fuin.esc.spi.EscEvents;
import org.fuin.esc.spi.EscMeta;
import org.fuin.esc.spi.EscSpiUtils;
import org.fuin.esc.spi.JsonbDeSerializer;
import org.fuin.esc.spi.SerDeserializerRegistry;
import org.fuin.esc.spi.SerializedDataType;
import org.fuin.esc.spi.SerializedDataTypeRegistry;
import org.fuin.esc.spi.SimpleSerializedDataTypeRegistry;
import org.fuin.esc.spi.SimpleSerializerDeserializerRegistry;
/**
* Utility code shared between command (write) and query (read) module.
*/
public final class SharedUtils {
/** All types that will be written into and read from the event store. */
private static TypeClass[] USER_DEFINED_TYPES = new TypeClass[] {
new TypeClass(PersonCreatedEvent.SER_TYPE, PersonCreatedEvent.class) };
/** All JSON-B adapters from this module. */
public static JsonbAdapter<?, ?>[] JSONB_ADAPTERS = new JsonbAdapter<?, ?>[] { new EventIdConverter(),
new EntityIdPathConverter(new SharedEntityIdFactory()), new EntityIdConverter(new SharedEntityIdFactory()),
new AggregateVersionConverter(), new PersonId.Converter(), new PersonName.Converter() };
private SharedUtils() {
throw new UnsupportedOperationException("It is not allowed to create an instance of a utiliy class");
}
/**
* Create a registry that allows finding types (classes) based on their unique type name.
*
* @return New instance.
*/
public static SerializedDataTypeRegistry createTypeRegistry() {
// Contains all types for usage with JSON-B
final SimpleSerializedDataTypeRegistry typeRegistry = new SimpleSerializedDataTypeRegistry();
// Base types always needed
typeRegistry.add(EscEvent.SER_TYPE, EscEvent.class);
typeRegistry.add(EscEvents.SER_TYPE, EscEvents.class);
typeRegistry.add(EscMeta.SER_TYPE, EscMeta.class);
typeRegistry.add(Base64Data.SER_TYPE, Base64Data.class);
// User defined types
for (final TypeClass tc : USER_DEFINED_TYPES) {
typeRegistry.add(tc.getType(), tc.getClasz());
}
return typeRegistry;
}
/**
* Creates a registry that connects the type with the appropriate serializer and de-serializer.
*
* @param typeRegistry
* Type registry (Mapping from type name to class).
* @param jsonbDeSer
* JSON-B serializer/deserializer to use.
*
* @return New instance.
*/
public static SerDeserializerRegistry createSerDeserializerRegistry(final SerializedDataTypeRegistry typeRegistry,
final JsonbDeSerializer jsonbDeSer) {
final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry();
// Base types always needed
registry.add(EscEvents.SER_TYPE, "application/json", jsonbDeSer);
registry.add(EscEvent.SER_TYPE, "application/json", jsonbDeSer);
registry.add(EscMeta.SER_TYPE, "application/json", jsonbDeSer);
registry.add(Base64Data.SER_TYPE, "application/json", jsonbDeSer);
// User defined types
for (final TypeClass tc : USER_DEFINED_TYPES) {
registry.add(tc.getType(), "application/json", jsonbDeSer);
}
jsonbDeSer.init(typeRegistry, registry, registry);
return registry;
}
/**
* Creates a registry that connects the type with the appropriate serializer and de-serializer.
*
* @return New instance.
*/
public static SerDeserializerRegistry createRegistry() {
// Knows about all types for usage with JSON-B
final SerializedDataTypeRegistry typeRegistry = SharedUtils.createTypeRegistry();
// Does the actual marshalling/unmarshalling
final JsonbDeSerializer jsonbDeSer = SharedUtils.createJsonbDeSerializer();
// Registry connects the type with the appropriate serializer and de-serializer
final SerDeserializerRegistry serDeserRegistry = SharedUtils.createSerDeserializerRegistry(typeRegistry, jsonbDeSer);
return serDeserRegistry;
}
/**
* Creates an instance of the JSON-B serializer/deserializer.
*
* @return New instance that is fully initialized with al necessary settings.
*/
public static JsonbDeSerializer createJsonbDeSerializer() {
return JsonbDeSerializer.builder().withSerializers(EscSpiUtils.createEscJsonbSerializers())
.withDeserializers(EscSpiUtils.createEscJsonbDeserializers()).withAdapters(JSONB_ADAPTERS)
.withPropertyVisibilityStrategy(new FieldAccessStrategy()).withEncoding(Charset.forName("utf-8")).build();
}
/**
* Helper class for type/class combination.
*/
private static final class TypeClass {
private final SerializedDataType type;
private final Class<?> clasz;
/**
* Constructor with all data.
*
* @param type
* Type.
* @param clasz
* Class.
*/
public TypeClass(final SerializedDataType type, final Class<?> clasz) {
super();
this.type = type;
this.clasz = clasz;
}
/**
* Returns the type.
*
* @return Type.
*/
public SerializedDataType getType() {
return type;
}
/**
* Returns the class.
*
* @return Class.
*/
public Class<?> getClasz() {
return clasz;
}
}
}

View File

@@ -13,5 +13,5 @@
package org.fuin.cqrs4j.example.quarkus.shared;
/**
* Domain specific code to be shared between all modules.
* Quarkus specific code to be shared between command / query service.
*/

View File

@@ -1,108 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
import java.nio.charset.Charset;
import java.time.ZonedDateTime;
import java.util.UUID;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.json.bind.JsonbConfig;
import org.apache.commons.io.IOUtils;
import org.eclipse.yasson.FieldAccessStrategy;
import org.fuin.utils4j.Utils4J;
import org.junit.Test;
// CHECKSTYLE:OFF
public final class CreatePersonCommandTest {
private static final String PERSON_UUID = "84565d62-115e-4502-b7c9-38ad69c64b05";
@Test
public final void testSerializeDeserialize() {
// PREPARE
final CreatePersonCommand original = createTestee();
// TEST
final CreatePersonCommand copy = Utils4J.deserialize(Utils4J.serialize(original));
// VERIFY
assertThat(copy).isEqualTo(original);
assertThat(copy.getAggregateRootId()).isEqualTo(original.getAggregateRootId());
assertThat(copy.getName()).isEqualTo(original.getName());
}
@Test
public final void testMarshalUnmarshalJson() {
// PREPARE
final CreatePersonCommand original = createTestee();
final JsonbConfig config = new JsonbConfig().withAdapters(SharedUtils.JSONB_ADAPTERS)
.withPropertyVisibilityStrategy(new FieldAccessStrategy());
final Jsonb jsonb = JsonbBuilder.create(config);
// TEST
final String json = jsonb.toJson(original, CreatePersonCommand.class);
final CreatePersonCommand copy = jsonb.fromJson(json, CreatePersonCommand.class);
// VERIFY
assertThat(copy).isEqualTo(original);
assertThat(copy.getAggregateRootId()).isEqualTo(original.getAggregateRootId());
assertThat(copy.getName()).isEqualTo(original.getName());
}
@Test
public final void testUnmarshalJsonFromFile() throws IOException {
// PREPARE
final String json = IOUtils.toString(this.getClass().getResourceAsStream("/commands/CreatePersonCommand.json"),
Charset.forName("utf-8"));
final JsonbConfig config = new JsonbConfig().withAdapters(SharedUtils.JSONB_ADAPTERS)
.withPropertyVisibilityStrategy(new FieldAccessStrategy());
final Jsonb jsonb = JsonbBuilder.create(config);
// TEST
final CreatePersonCommand copy = jsonb.fromJson(json, CreatePersonCommand.class);
// VERIFY
assertThat(copy.getEventId().asBaseType()).isEqualTo(UUID.fromString("109a77b2-1de2-46fc-aee1-97fa7740a552"));
assertThat(copy.getTimestamp()).isEqualTo(ZonedDateTime.parse("2019-11-17T10:27:13.183+01:00[Europe/Berlin]"));
assertThat(copy.getAggregateRootId().asString()).isEqualTo(PERSON_UUID);
assertThat(copy.getName().asString()).isEqualTo("Peter Parker");
}
private CreatePersonCommand createTestee() {
final PersonId personId = new PersonId(UUID.fromString(PERSON_UUID));
final PersonName personName = new PersonName("Peter Parker");
return new CreatePersonCommand(personId, personName);
}
}
// CHECKSTYLE:ON

View File

@@ -1,108 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import static org.assertj.core.api.Assertions.assertThat;
import static org.fuin.utils4j.Utils4J.deserialize;
import static org.fuin.utils4j.Utils4J.serialize;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.UUID;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import javax.json.bind.JsonbConfig;
import org.apache.commons.io.IOUtils;
import org.eclipse.yasson.FieldAccessStrategy;
import org.junit.Test;
// CHECKSTYLE:OFF
public final class PersonCreatedEventTest {
@Test
public final void testSerializeDeserialize() {
// PREPARE
final PersonCreatedEvent original = createTestee();
// TEST
final PersonCreatedEvent copy = deserialize(serialize(original));
// VERIFY
assertThat(copy).isEqualTo(original);
assertThat(copy.getName()).isEqualTo(original.getName());
}
@Test
public final void testMarshalUnmarshalJson() {
// PREPARE
final PersonCreatedEvent original = createTestee();
final JsonbConfig config = new JsonbConfig().withAdapters(SharedUtils.JSONB_ADAPTERS)
.withPropertyVisibilityStrategy(new FieldAccessStrategy());
final Jsonb jsonb = JsonbBuilder.create(config);
// TEST
final String json = jsonb.toJson(original, PersonCreatedEvent.class);
final PersonCreatedEvent copy = jsonb.fromJson(json, PersonCreatedEvent.class);
// VERIFY
assertThat(copy).isEqualTo(original);
assertThat(copy.getName()).isEqualTo(original.getName());
}
@Test
public final void testUnmarshalJson() throws IOException {
// PREPARE
final PersonCreatedEvent original = createTestee();
final JsonbConfig config = new JsonbConfig().withAdapters(SharedUtils.JSONB_ADAPTERS)
.withPropertyVisibilityStrategy(new FieldAccessStrategy());
final Jsonb jsonb = JsonbBuilder.create(config);
// TEST
final String json = IOUtils.toString(this.getClass().getResourceAsStream("/events/PersonCreatedEvent.json"),
Charset.forName("utf-8"));
final PersonCreatedEvent copy = jsonb.fromJson(json, PersonCreatedEvent.class);
// VERIFY
assertThat(copy.getEntityIdPath()).isEqualTo(original.getEntityIdPath());
assertThat(copy.getName()).isEqualTo(original.getName());
}
@Test
public final void testToString() {
assertThat(createTestee().toString())
.isEqualTo("Person 'Peter Parker' was created");
}
private PersonCreatedEvent createTestee() {
final PersonId personId = new PersonId(UUID.fromString("f645969a-402d-41a9-882b-d2d8000d0f43"));
final PersonName personName = new PersonName("Peter Parker");
return new PersonCreatedEvent(personId, personName);
}
}

View File

@@ -1,91 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
import java.util.UUID;
import org.fuin.ddd4j.ddd.EntityType;
import org.fuin.ddd4j.ddd.StringBasedEntityType;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.junit.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
/**
* Test for {@link PersonId}.
*/
public final class PersonIdTest {
private static final String PERSON_UUID = "84565d62-115e-4502-b7c9-38ad69c64b05";
@Test
public void testEquals() {
EqualsVerifier.forClass(PersonId.class).suppress(Warning.NONFINAL_FIELDS)
.withNonnullFields("entityType", "uuid")
.withPrefabValues(EntityType.class, new StringBasedEntityType("A"), new StringBasedEntityType("B"))
.verify();
}
@Test
public void testValueOf() {
final PersonId personId = PersonId.valueOf(PERSON_UUID);
assertThat(personId.asString()).isEqualTo(PERSON_UUID);
}
@Test
public void testValueOfIllegalArgumentCharacter() {
try {
PersonId.valueOf("abc");
fail();
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'value' is not valid: 'abc'");
}
}
@Test
public final void testConverterUnmarshal() throws Exception {
// PREPARE
final String personIdValue = PERSON_UUID;
// TEST
final PersonId personId = new PersonId.Converter().adaptFromJson(UUID.fromString(PERSON_UUID));
// VERIFY
assertThat(personId.asString()).isEqualTo(personIdValue);
}
@Test
public void testConverterMarshal() throws Exception {
final PersonId personId = PersonId.valueOf(PERSON_UUID);
// TEST
final UUID uuid = new PersonId.Converter().adaptToJson(personId);
// VERIFY
assertThat(uuid).isEqualTo(UUID.fromString(PERSON_UUID));
}
}

View File

@@ -1,134 +0,0 @@
/**
* Copyright (C) 2015 Michael Schnell. All rights reserved.
* http://www.fuin.org/
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library. If not, see http://www.gnu.org/licenses/.
*/
package org.fuin.cqrs4j.example.quarkus.shared;
import static org.assertj.core.api.Assertions.assertThat;
import org.fuin.objects4j.common.ConstraintViolationException;
import org.fuin.utils4j.Utils4J;
import org.junit.Assert;
import org.junit.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;
// CHECKSTYLE:OFF
public final class PersonNameTest {
@Test
public void testSerialize() {
final PersonName original = new PersonName("Peter Parker");
final PersonName copy = Utils4J.deserialize(Utils4J.serialize(original));
assertThat(original).isEqualTo(copy);
}
@Test
public void testHashCodeEquals() {
EqualsVerifier.forClass(PersonName.class).suppress(Warning.NULL_FIELDS).withRedefinedSuperclass().verify();
}
@Test
public void testMarshalJson() throws Exception {
// PREPARE
final String str = "Peter Parker";
final PersonName testee = new PersonName(str);
// TEST & VERIFY
assertThat(new PersonName.Converter().adaptToJson(testee)).isEqualTo(str);
assertThat(new PersonName.Converter().adaptToJson(null)).isNull();
}
@Test
public void testUnmarshalJson() throws Exception {
// PREPARE
final String str = "Peter Parker";
final PersonName testee = new PersonName(str);
// TEST & VERIFY
assertThat(new PersonName.Converter().adaptFromJson(str)).isEqualTo(testee);
assertThat(new PersonName.Converter().adaptFromJson(null)).isNull();
}
@Test
public void testIsValid() {
assertThat(PersonName.isValid(null)).isTrue();
assertThat(PersonName.isValid("Peter Parker")).isTrue();
assertThat(PersonName.isValid("")).isFalse();
assertThat(PersonName.isValid("123456789.123456789.123456789.123456789.123456789."
+ "123456789.123456789.123456789.123456789.123456789." + "12345")).isFalse();
}
@Test
public void testRequireArgValid() {
PersonName.requireArgValid("a", "Peter Parker");
PersonName.requireArgValid("b", null);
try {
PersonName.requireArgValid("c", "");
Assert.fail();
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage()).isEqualTo("The argument 'c' is not valid: ''");
}
try {
PersonName.requireArgValid("d", "123456789.123456789.123456789.123456789.123456789."
+ "123456789.123456789.123456789.123456789.123456789." + "12345");
Assert.fail();
} catch (final ConstraintViolationException ex) {
assertThat(ex.getMessage())
.isEqualTo("The argument 'd' is not valid: '" + "123456789.123456789.123456789.123456789.123456789."
+ "123456789.123456789.123456789.123456789.123456789." + "12345" + "'");
}
}
@Test
public void testValidator() {
assertThat(new PersonName.Validator().isValid(null, null)).isTrue();
assertThat(new PersonName.Validator().isValid("Peter Parker", null)).isTrue();
assertThat(new PersonName.Validator().isValid("", null)).isFalse();
assertThat(new PersonName.Validator().isValid("123456789.123456789.123456789.123456789.123456789."
+ "123456789.123456789.123456789.123456789.123456789." + "12345", null)).isFalse();
}
@Test
public void testValueObjectConverter() {
assertThat(new PersonName.Converter().getBaseTypeClass()).isEqualTo(String.class);
assertThat(new PersonName.Converter().getValueObjectClass()).isEqualTo(PersonName.class);
assertThat(new PersonName.Converter().isValid(null)).isTrue();
assertThat(new PersonName.Converter().isValid("Peter Parker")).isTrue();
assertThat(new PersonName.Converter().isValid("123456789.123456789.123456789.123456789.123456789."
+ "123456789.123456789.123456789.123456789.123456789." + "12345")).isFalse();
}
}

View File

@@ -15,7 +15,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<esc.version>0.3.1-SNAPSHOT</esc.version>
<esc.version>0.3.1</esc.version>
</properties>
<dependencies>
@@ -25,19 +25,19 @@
<dependency>
<groupId>org.fuin</groupId>
<artifactId>ddd-4-java</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>cqrs-4-java</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.2.1</version>
</dependency>
<dependency>
<groupId>org.fuin</groupId>
<artifactId>objects4j</artifactId>
<version>0.6.9-SNAPSHOT</version>
<version>0.6.9</version>
</dependency>
<dependency>