Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
+invoker, poc
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Jun 1, 2023
1 parent f387955 commit 39372ce
Show file tree
Hide file tree
Showing 16 changed files with 401 additions and 71 deletions.
18 changes: 15 additions & 3 deletions .rultor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
architect:
- h1alexbel
docker:
image: l3r8y/rultor-image:1.0.2
image: l3r8y/rultor-image:1.0.3
assets:
settings.xml: eo-cqrs/eo-cqrs-secrets#assets/settings.xml
secring.gpg: eo-cqrs/eo-cqrs-secrets#assets/secring.gpg
pubring.gpg: eo-cqrs/eo-cqrs-secrets#assets/pubring.gpg
merge:
script:
- "mvn -version"
- "mvn clean install --errors --batch-mode"
- "mvn clean install --errors --batch-mode"
release:
pre: false
sensitive:
- settings.xml
script: |-
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
mvn versions:set "-DnewVersion=${tag}"
git commit -am "${tag}"
mvn clean deploy -Prelease --errors --settings ../settings.xml
61 changes: 50 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ SOFTWARE.
<version>0.65.0</version>
</parent>
<groupId>io.github.eo-cqrs</groupId>
<artifactId>eo-qce</artifactId>
<artifactId>eo-events</artifactId>
<version>1.0-SNAPSHOT</version>
<name>eo-qce</name>
<name>eo-events</name>
<description>
Objects for handling Queries, Commands and Events in Event Sourcing &amp; CQRS
Objects for handling Events
</description>
<inceptionYear>2023</inceptionYear>
<developers>
Expand All @@ -52,28 +52,28 @@ SOFTWARE.
</developers>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/eo-cqrs/eo-qce/issues</url>
<url>https://github.com/eo-cqrs/eo-events/issues</url>
</issueManagement>
<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/eo-cqrs/eo-qce/actions</url>
<url>https://github.com/eo-cqrs/eo-events/actions</url>
</ciManagement>
<licenses>
<license>
<name>MIT</name>
<url>https://github.com/eo-cqrs/eo-qce/blob/master/LICENSE.txt</url>
<url>https://github.com/eo-cqrs/eo-events/blob/master/LICENSE.txt</url>
<distribution>site</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/eo-cqrs/eo-qce.git</connection>
<developerConnection>scm:git:ssh://github.com:eo-cqrs/eo-qce.git</developerConnection>
<url>https://github.com/eo-cqrs/eo-qce/tree/master</url>
<connection>scm:git:git://github.com/eo-cqrs/eo-events.git</connection>
<developerConnection>scm:git:ssh://github.com:eo-cqrs/eo-events.git</developerConnection>
<url>https://github.com/eo-cqrs/eo-events/tree/master</url>
</scm>
<distributionManagement>
<site>
<id>eo-cqrs.github.io/eo-qce/</id>
<url>https://eo-cqrs.github.io/eo-qce/</url>
<id>eo-cqrs.github.io/eo-events/</id>
<url>https://eo-cqrs.github.io/eo-events/</url>
</site>
</distributionManagement>
<properties>
Expand All @@ -95,6 +95,7 @@ SOFTWARE.
<sa-tan.version>0.1.5</sa-tan.version>
<maven-source-plugin.version>3.3.0</maven-source-plugin.version>
<maven-gpg-plugin.version>3.1.0</maven-gpg-plugin.version>
<maven-invoker-plugin.version>3.5.1</maven-invoker-plugin.version>
</properties>
<dependencies>
<dependency>
Expand Down Expand Up @@ -370,5 +371,43 @@ SOFTWARE.
</plugins>
</build>
</profile>
<profile>
<id>invoker</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>${maven-invoker-plugin.version}</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
<settingsFile>src/it/settings.xml</settingsFile>
<localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
<postBuildHookScript>verify</postBuildHookScript>
<streamLogsOnFailures>true</streamLogsOnFailures>
</configuration>
<executions>
<execution>
<id>integration-tests</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
113 changes: 113 additions & 0 deletions src/it/events/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
MIT License
Copyright (c) 2023 Aliaksei Bialiauski, EO-CQRS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.eo-cqrs</groupId>
<artifactId>events</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>events</name>
<properties>
<project.java.version>17</project.java.version>
<maven.compiler.source>${project.java.version}</maven.compiler.source>
<maven.compiler.target>${project.java.version}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.9.3</junit.version>
<hamcrest.version>2.2</hamcrest.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
<maven-surefire-plugin.version>3.1.0</maven-surefire-plugin.version>
<mockito-core.version>5.3.1</mockito-core.version>
</properties>
<dependencies>
<dependency>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.28</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.rnorth.duct-tape</groupId>
<artifactId>duct-tape</artifactId>
<version>1.0.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.7</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<includes>
<include>**/*Spec.*</include>
<include>**/*Test.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
7 changes: 7 additions & 0 deletions src/it/events/src/main/java/Entry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @author Aliaksei Bialiauski ()
* @since 0.0.0
*/
public class Entry {

}
28 changes: 28 additions & 0 deletions src/it/events/src/test/java/ChangeUsernameTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import prep.ChangeUsername;
import prep.EnUser;
import prep.User;

/**
* Test case for {@link ChangeUsername}
*
* @author Aliaksei Bialiauski ([email protected])
* @since 0.0.0
*/
final class ChangeUsernameTest {

@Test
void changesUsername() {
final User user = new EnUser(1, "hialexbel");
final String name = "h1alexbel";
MatcherAssert.assertThat(
"Name has changed",
new ChangeUsername(name)
.submitTo(user)
.username(),
Matchers.equalTo(name)
);
}
}
27 changes: 27 additions & 0 deletions src/it/events/src/test/java/prep/ChangeUsername.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package prep;

import io.github.eocqrs.events.Event;
import lombok.RequiredArgsConstructor;

/**
* @author Aliaksei Bialiauski ([email protected])
* @since 0.0.0
*/
@RequiredArgsConstructor
public final class ChangeUsername implements Event<User> {

private final String name;

@Override
public User submitTo(final User user) {
return new EnUser(user.id(), this.name);
}

@Override
public String payload() {
return "new username will be: %s"
.formatted(
this.name
);
}
}
24 changes: 24 additions & 0 deletions src/it/events/src/test/java/prep/EnUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package prep;

import lombok.RequiredArgsConstructor;

/**
* @author Aliaksei Bialiauski ([email protected])
* @since 0.0.0
*/
@RequiredArgsConstructor
public final class EnUser implements User {

private final int id;
private final String username;

@Override
public int id() {
return this.id;
}

@Override
public String username() {
return this.username;
}
}
14 changes: 14 additions & 0 deletions src/it/events/src/test/java/prep/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package prep;

import io.github.eocqrs.events.Resource;

/**
* @author Aliaksei Bialiauski ([email protected])
* @since 0.0.0
*/
public interface User extends Resource<User> {

int id();

String username();
}
29 changes: 29 additions & 0 deletions src/it/events/src/test/java/prep/UserChain.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package prep;

import io.github.eocqrs.events.Event;
import io.github.eocqrs.events.EventChain;
import lombok.RequiredArgsConstructor;

import java.util.Collections;
import java.util.Set;

/**
* @author Aliaksei Bialiauski ([email protected])
* @since 0.0.0
*/
@RequiredArgsConstructor
public final class UserChain implements EventChain<User> {

private final Set<Event<User>> events;

@Override
public Set<Event<User>> value() {
return Collections.unmodifiableSet(this.events);
}

@Override
public EventChain<User> append(final Event<User> event) {
this.events.add(event);
return new UserChain(this.events);
}
}
Loading

1 comment on commit 39372ce

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 39372ce Jun 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 6-49a65616 discovered in src/test/java/io/github/eocqrs/qce/EventTest.java) and submitted as #38. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.