Skip to content

Commit 28a20b9

Browse files
authored
Merge pull request #2 from SirMarjan/feature/cqrs2
Feature/cqrs2
2 parents 1efff8b + 6b712d6 commit 28a20b9

41 files changed

Lines changed: 823 additions & 167 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package pl.marcinsobanski.notificationssystem.api.cqrs.common.cqrs;
22

3-
public interface Command<RESULT> {
3+
public non-sealed interface Command<RESULT> extends Message<RESULT> {
44
}

NotificationsSystemApi/src/main/java/pl/marcinsobanski/notificationssystem/api/cqrs/common/cqrs/CommandHandler.java

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package pl.marcinsobanski.notificationssystem.api.cqrs.common.cqrs;
2+
3+
public sealed interface Message<Result> permits Command, Query {
4+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
package pl.marcinsobanski.notificationssystem.api.cqrs.common.cqrs;
22

3-
public interface Query<RESULT> {
3+
public non-sealed interface Query<RESULT> extends Message<RESULT> {
44
}

NotificationsSystemApi/src/main/java/pl/marcinsobanski/notificationssystem/api/cqrs/common/cqrs/QueryHandler.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

NotificationsSystemApplication/pom.xml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
<groupId>pl.marcinsobanski.notificationssystem.application</groupId>
1313
<artifactId>NotificationsSystemApplication</artifactId>
1414

15-
<properties>
16-
<maven.compiler.source>25</maven.compiler.source>
17-
<maven.compiler.target>25</maven.compiler.target>
18-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19-
</properties>
20-
2115
<dependencies>
2216
<dependency>
2317
<groupId>pl.marcinsobanski.notificationssystem.api</groupId>
@@ -33,6 +27,27 @@
3327
<artifactId>lombok</artifactId>
3428
<optional>true</optional>
3529
</dependency>
30+
31+
<dependency>
32+
<groupId>org.junit.jupiter</groupId>
33+
<artifactId>junit-jupiter</artifactId>
34+
<scope>test</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.junit.jupiter</groupId>
38+
<artifactId>junit-jupiter-params</artifactId>
39+
<scope>test</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.mockito</groupId>
43+
<artifactId>mockito-core</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.mockito</groupId>
48+
<artifactId>mockito-junit-jupiter</artifactId>
49+
<scope>test</scope>
50+
</dependency>
3651
</dependencies>
3752

3853
<build>

NotificationsSystemApplication/src/main/java/pl/marcinsobanski/notificationssystem/application/converters/RuleConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public Rule convertRule(pl.marcinsobanski.notificationssystem.api.cqrs.common.mo
2121
};
2222
}
2323

24-
public ItemTypeRule.Operator convertToItemTypeRule(RuleOperator ruleOperator) {
24+
private ItemTypeRule.Operator convertToItemTypeRule(RuleOperator ruleOperator) {
2525
return switch (ruleOperator) {
2626
case ITEM_IS -> ItemTypeRule.Operator.IS;
2727
case ITEM_IS_NOT -> ItemTypeRule.Operator.IS_NOT;
2828
default -> throw new IllegalArgumentException("Illegal argument" + ruleOperator);
2929
};
3030
}
3131

32-
public PriceRule.Operator convertToPriceRule(RuleOperator ruleOperator) {
32+
private PriceRule.Operator convertToPriceRule(RuleOperator ruleOperator) {
3333
return switch (ruleOperator) {
3434
case PRICE_GREATER -> PriceRule.Operator.GREATER;
3535
case PRICE_GREATER_OR_EQUALS -> PriceRule.Operator.GREATER_OR_EQUAL;

NotificationsSystemApplication/src/main/java/pl/marcinsobanski/notificationssystem/application/cqrs/CQCommandHandler.java renamed to NotificationsSystemApplication/src/main/java/pl/marcinsobanski/notificationssystem/application/cqrs/CQBus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pl.marcinsobanski.notificationssystem.api.cqrs.common.cqrs.Command;
44
import pl.marcinsobanski.notificationssystem.api.cqrs.common.cqrs.Query;
55

6-
public interface CQCommandHandler {
6+
public interface CQBus {
77

88
<RESULT> RESULT executeCommand(Command<RESULT> command);
99

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package pl.marcinsobanski.notificationssystem.application.cqrs;
2+
3+
4+
import pl.marcinsobanski.notificationssystem.api.cqrs.common.cqrs.Command;
5+
6+
public interface CommandHandler<RESULT, COMMAND extends Command<RESULT>> extends MessageHandler<RESULT, COMMAND> {
7+
8+
@Override
9+
RESULT handle(COMMAND command);
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package pl.marcinsobanski.notificationssystem.application.cqrs;
2+
3+
import pl.marcinsobanski.notificationssystem.api.cqrs.common.cqrs.Message;
4+
5+
public interface MessageHandler<RESULT, MESSAGE extends Message<RESULT>> {
6+
7+
RESULT handle(MESSAGE message);
8+
9+
}

0 commit comments

Comments
 (0)