split bounded contexts into separate maven modules
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -1,17 +0,0 @@
|
|||||||
FROM maven:3.8.5-openjdk-17 as build
|
|
||||||
|
|
||||||
COPY pom.xml .
|
|
||||||
|
|
||||||
RUN mvn -B dependency:go-offline
|
|
||||||
|
|
||||||
COPY src src
|
|
||||||
|
|
||||||
RUN mvn -B package
|
|
||||||
|
|
||||||
FROM openjdk:11-jre-slim-buster
|
|
||||||
|
|
||||||
COPY --from=build target/camunda-ddd-and-clean-architecture.jar .
|
|
||||||
|
|
||||||
EXPOSE 8080
|
|
||||||
|
|
||||||
ENTRYPOINT ["java", "-jar", "camunda-ddd-and-clean-architecture.jar"]
|
|
||||||
17
loan-agreement/Dockerfile
Normal file
17
loan-agreement/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM maven:3.8.5-openjdk-17 as build
|
||||||
|
|
||||||
|
COPY ../pom.xml .
|
||||||
|
|
||||||
|
RUN mvn -B dependency:go-offline
|
||||||
|
|
||||||
|
COPY ../src src
|
||||||
|
|
||||||
|
RUN mvn -B package
|
||||||
|
|
||||||
|
FROM openjdk:11-jre-slim-buster
|
||||||
|
|
||||||
|
COPY --from=build ../target/loan-agreement.jar .
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
ENTRYPOINT ["java", "-jar", "loan-agreement.jar"]
|
||||||
159
loan-agreement/pom.xml
Normal file
159
loan-agreement/pom.xml
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>de.weinbrecht.luc.bpm.architecture.loan.agreement</groupId>
|
||||||
|
<artifactId>loan-agreement</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
|
<version.springboot>2.6.4</version.springboot>
|
||||||
|
<version.camunda>7.17.0</version.camunda>
|
||||||
|
<version.junit5>5.8.2</version.junit5>
|
||||||
|
<version.lombok>1.18.24</version.lombok>
|
||||||
|
<version.domainprimitives>0.1.0</version.domainprimitives>
|
||||||
|
<version.bpmAssert>1.1.0</version.bpmAssert>
|
||||||
|
<version.camundaMockito>6.17.0</version.camundaMockito>
|
||||||
|
<version.okhttp>4.9.3</version.okhttp>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${version.springboot}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm</groupId>
|
||||||
|
<artifactId>camunda-bom</artifactId>
|
||||||
|
<version>${version.camunda}</version>
|
||||||
|
<scope>import</scope>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm.springboot</groupId>
|
||||||
|
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm.springboot</groupId>
|
||||||
|
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm.springboot</groupId>
|
||||||
|
<artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.domain-primitives</groupId>
|
||||||
|
<artifactId>domainprimitives-java</artifactId>
|
||||||
|
<version>${version.domainprimitives}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${version.lombok}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>${version.junit5}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
|
<version>${version.junit5}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>${version.junit5}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm.extension</groupId>
|
||||||
|
<artifactId>camunda-bpm-junit5</artifactId>
|
||||||
|
<version>${version.bpmAssert}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.community.mockito</groupId>
|
||||||
|
<artifactId>camunda-platform-7-mockito</artifactId>
|
||||||
|
<version>${version.camundaMockito}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>${version.okhttp}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>mockwebserver</artifactId>
|
||||||
|
<version>${version.okhttp}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${version.springboot}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture;
|
package de.weinbrecht.luc.bpm.architecture.loan.agreement;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@@ -6,8 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
public static void main(String... args) {
|
public static void main(String... args) {
|
||||||
SpringApplication.run(Application.class, args);
|
SpringApplication.run(Application.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.common;
|
||||||
|
|
||||||
|
public class ProcessConstants {
|
||||||
|
|
||||||
|
public static final String PROCESS_DEFINITION = "Loan_Agreement";
|
||||||
|
public static final String LOAN_START_EVENT_MESSAGE_REF = "loanAgreementReceivedMessage";
|
||||||
|
public static final String LOAN_AGREEMENT_NUMBER = "loanAgreementNumber";
|
||||||
|
|
||||||
|
public static final String RECOMMENDATION_START_EVENT_MESSAGE_REF = "crossSellingPotentialDiscoveredMessage";
|
||||||
|
public static final String RECOMMENDATION_CUSTOMER_NUMBER = "customerNumber";
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
|
|||||||
import org.camunda.bpm.engine.delegate.JavaDelegate;
|
import org.camunda.bpm.engine.delegate.JavaDelegate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.LoanAgreement.LOAN_AGREEMENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.common.ProcessConstants.LOAN_AGREEMENT_NUMBER;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -8,7 +8,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
|
|||||||
import org.camunda.bpm.engine.delegate.JavaDelegate;
|
import org.camunda.bpm.engine.delegate.JavaDelegate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.LoanAgreement.LOAN_AGREEMENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.common.ProcessConstants.LOAN_AGREEMENT_NUMBER;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -12,9 +12,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.CUSTOMER_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.common.ProcessConstants.*;
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.START_EVENT_MESSAGE_REF;
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.LoanAgreement.LOAN_AGREEMENT_NUMBER;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Component
|
@Component
|
||||||
@@ -29,10 +27,10 @@ public class SendCrossSellingRecommendation implements JavaDelegate {
|
|||||||
LoanAgreement loanAgreement = loanAgreementQuery.loadByNumber(new LoanAgreementNumber(loanNumber));
|
LoanAgreement loanAgreement = loanAgreementQuery.loadByNumber(new LoanAgreementNumber(loanNumber));
|
||||||
|
|
||||||
Map<String, Object> processVariables = new HashMap<>();
|
Map<String, Object> processVariables = new HashMap<>();
|
||||||
processVariables.put(CUSTOMER_NUMBER, loanAgreement.getRecipient().getCustomerNumber().getValue());
|
processVariables.put(RECOMMENDATION_CUSTOMER_NUMBER, loanAgreement.getRecipient().getCustomerNumber().getValue());
|
||||||
|
|
||||||
runtimeService.startProcessInstanceByMessage(
|
runtimeService.startProcessInstanceByMessage(
|
||||||
START_EVENT_MESSAGE_REF,
|
RECOMMENDATION_START_EVENT_MESSAGE_REF,
|
||||||
buildCrossSellingBusinessKey(loanNumber, execution.getBusinessKey()),
|
buildCrossSellingBusinessKey(loanNumber, execution.getBusinessKey()),
|
||||||
processVariables
|
processVariables
|
||||||
);
|
);
|
||||||
@@ -13,7 +13,7 @@ class LoanAgreementController {
|
|||||||
private final LoanAgreementCreation loanAgreementCreation;
|
private final LoanAgreementCreation loanAgreementCreation;
|
||||||
private final LoanAgreementMapper mapper;
|
private final LoanAgreementMapper mapper;
|
||||||
|
|
||||||
@PostMapping("{caseId}")
|
@PostMapping("/{caseId}")
|
||||||
public void create(@RequestBody LoanAgreementResource loanAgreementResource,
|
public void create(@RequestBody LoanAgreementResource loanAgreementResource,
|
||||||
@PathVariable String caseId) {
|
@PathVariable String caseId) {
|
||||||
loanAgreementCreation.create(mapper.mapToDomain(loanAgreementResource), new CaseId(caseId));
|
loanAgreementCreation.create(mapper.mapToDomain(loanAgreementResource), new CaseId(caseId));
|
||||||
@@ -17,9 +17,9 @@ class LoanAgreementRepository implements LoanAgreementCommand, LoanAgreementQuer
|
|||||||
private final LoanAgreementMapper mapper;
|
private final LoanAgreementMapper mapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoanAgreementNumber save(LoanAgreement loanAgreement) {
|
public LoanAgreement save(LoanAgreement loanAgreement) {
|
||||||
LoanAgreementEntity savedLoanAgreement = crudRepository.save(mapper.mapToDb(loanAgreement));
|
LoanAgreementEntity savedLoanAgreement = crudRepository.save(mapper.mapToDb(loanAgreement));
|
||||||
return new LoanAgreementNumber(savedLoanAgreement.getId());
|
return mapper.mapToDomain(savedLoanAgreement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.out.recommendation;
|
||||||
|
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CaseId;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.LoanAgreement;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.RecommendationTrigger;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
|
import static reactor.core.publisher.Mono.just;
|
||||||
|
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Component
|
||||||
|
class RecommendationClient implements RecommendationTrigger {
|
||||||
|
|
||||||
|
private final WebClient webClient;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public RecommendationClient(@Value("${custom.recommendation.address:localhost:8081}") String recommendationAddress) {
|
||||||
|
this.webClient = WebClient.create("http://" + recommendationAddress);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startLoanAgreement(CaseId caseId, LoanAgreement loanAgreement) {
|
||||||
|
RecommendationResource recommendationResource = new RecommendationResource();
|
||||||
|
recommendationResource.setLoanAgreementNumber(loanAgreement.getLoanAgreementNumber().getValue());
|
||||||
|
recommendationResource.setCustomerNumber(loanAgreement.getRecipient().getCustomerNumber().getValue());
|
||||||
|
|
||||||
|
webClient.post().uri("/recommendation/" + caseId.getValue())
|
||||||
|
.body(just(recommendationResource), RecommendationResource.class)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(Void.class)
|
||||||
|
.block();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.out.recommendation;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
class RecommendationResource {
|
||||||
|
private Long loanAgreementNumber;
|
||||||
|
private String customerNumber;
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.in.LoanAgreemen
|
|||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementCommand;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementCommand;
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementDistributor;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementDistributor;
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementQuery;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementQuery;
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.ProcessEngineCommand;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.RecommendationTrigger;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -17,15 +17,15 @@ import org.springframework.stereotype.Service;
|
|||||||
public class LoanAgreementService implements LoanAgreementCreation, LoanAgreementStatusCommand {
|
public class LoanAgreementService implements LoanAgreementCreation, LoanAgreementStatusCommand {
|
||||||
|
|
||||||
private final LoanAgreementCommand loanAgreementCommand;
|
private final LoanAgreementCommand loanAgreementCommand;
|
||||||
private final ProcessEngineCommand processEngineCommand;
|
private final RecommendationTrigger recommendationTrigger;
|
||||||
private final LoanAgreementDistributor loanAgreementDistributor;
|
private final LoanAgreementDistributor loanAgreementDistributor;
|
||||||
private final LoanAgreementQuery loanAgreementQuery;
|
private final LoanAgreementQuery loanAgreementQuery;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(LoanAgreement loanAgreement, CaseId caseId) {
|
public void create(LoanAgreement loanAgreement, CaseId caseId) {
|
||||||
try {
|
try {
|
||||||
LoanAgreementNumber loanAgreementNumber = loanAgreementCommand.save(loanAgreement);
|
LoanAgreement savedLoanAgreement = loanAgreementCommand.save(loanAgreement);
|
||||||
processEngineCommand.startLoanAgreement(caseId, loanAgreementNumber);
|
recommendationTrigger.startLoanAgreement(caseId, savedLoanAgreement);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new LoanAgreementException("Cloud not save the loan agreement", e);
|
throw new LoanAgreementException("Cloud not save the loan agreement", e);
|
||||||
}
|
}
|
||||||
@@ -4,5 +4,5 @@ import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.LoanAgreem
|
|||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.LoanAgreementNumber;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.LoanAgreementNumber;
|
||||||
|
|
||||||
public interface LoanAgreementCommand {
|
public interface LoanAgreementCommand {
|
||||||
LoanAgreementNumber save(LoanAgreement loanAgreement);
|
LoanAgreement save(LoanAgreement loanAgreement);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out;
|
package de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CaseId;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CaseId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.LoanAgreementNumber;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.LoanAgreement;
|
||||||
|
|
||||||
public interface ProcessEngineCommand {
|
public interface RecommendationTrigger {
|
||||||
void startLoanAgreement(CaseId caseId, LoanAgreementNumber loanAgreementNumber);
|
void startLoanAgreement(CaseId caseId, LoanAgreement loanAgreement);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
spring.datasource.url: jdbc:h2:file:./camunda-h2-database
|
|
||||||
spring:
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:h2:file:./camunda-loan-agreement-h2-database
|
||||||
jpa:
|
jpa:
|
||||||
hibernate:
|
hibernate:
|
||||||
ddl-auto: create-drop
|
ddl-auto: create-drop
|
||||||
@@ -17,8 +17,7 @@ import org.junit.jupiter.params.provider.MethodSource;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.LoanAgreement.LOAN_AGREEMENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.common.ProcessConstants.LOAN_AGREEMENT_NUMBER;
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.LoanAgreement.PROCESS_DEFINITION;
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.assertj.core.api.Assertions.entry;
|
import static org.assertj.core.api.Assertions.entry;
|
||||||
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.assertThat;
|
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.assertThat;
|
||||||
@@ -33,6 +32,8 @@ import static org.camunda.community.mockito.DelegateExpressions.verifyJavaDelega
|
|||||||
@ExtendWith(ProcessEngineExtension.class)
|
@ExtendWith(ProcessEngineExtension.class)
|
||||||
class ProcessTest {
|
class ProcessTest {
|
||||||
|
|
||||||
|
public static final String PROCESS_DEFINITION = "Loan_Agreement";
|
||||||
|
|
||||||
private static final String START_EVENT = "LoanAgreementReciedStartEvent";
|
private static final String START_EVENT = "LoanAgreementReciedStartEvent";
|
||||||
private static final String APPROVE_RULE_TASK = "ApproveAgreementRuleTask";
|
private static final String APPROVE_RULE_TASK = "ApproveAgreementRuleTask";
|
||||||
private static final String APPROVE_AGREEMENT_SERVICE_TASK = "ApproveLoanAgreementServiceTask";
|
private static final String APPROVE_AGREEMENT_SERVICE_TASK = "ApproveLoanAgreementServiceTask";
|
||||||
@@ -104,7 +105,7 @@ class ProcessTest {
|
|||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("provideProcessVariablesForDMN")
|
@MethodSource("provideProcessVariablesForDMN")
|
||||||
@Deployment(resources = "approve_agreement.dmn")
|
@Deployment(resources = "approve_agreement.dmn")
|
||||||
void testTweetApprovalIBM(Long input, boolean expected) {
|
void testApprovementDMN(Long input, boolean expected) {
|
||||||
Map<String, Object> variables = withVariables(LOAN_AGREEMENT_NUMBER, input);
|
Map<String, Object> variables = withVariables(LOAN_AGREEMENT_NUMBER, input);
|
||||||
|
|
||||||
DmnDecisionTableResult tableResult = decisionService().evaluateDecisionTableByKey(DMN_DEFINITION, variables);
|
DmnDecisionTableResult tableResult = decisionService().evaluateDecisionTableByKey(DMN_DEFINITION, variables);
|
||||||
@@ -8,7 +8,7 @@ import org.mockito.InjectMocks;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoSettings;
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.LoanAgreement.LOAN_AGREEMENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.common.ProcessConstants.LOAN_AGREEMENT_NUMBER;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@MockitoSettings
|
@MockitoSettings
|
||||||
@@ -8,7 +8,7 @@ import org.mockito.InjectMocks;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoSettings;
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.LoanAgreement.LOAN_AGREEMENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.common.ProcessConstants.LOAN_AGREEMENT_NUMBER;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@MockitoSettings
|
@MockitoSettings
|
||||||
@@ -12,9 +12,7 @@ import org.mockito.junit.jupiter.MockitoSettings;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.CUSTOMER_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.common.ProcessConstants.*;
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.START_EVENT_MESSAGE_REF;
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.LoanAgreement.LOAN_AGREEMENT_NUMBER;
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.TestdataGenerator.createLoanAgreementWithNumber;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.TestdataGenerator.createLoanAgreementWithNumber;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@@ -43,9 +41,9 @@ class SendCrossSellingRecommendationTest {
|
|||||||
classUnderTest.execute(delegateExecution);
|
classUnderTest.execute(delegateExecution);
|
||||||
|
|
||||||
Map<String, Object> processVariables = new HashMap<>();
|
Map<String, Object> processVariables = new HashMap<>();
|
||||||
processVariables.put(CUSTOMER_NUMBER, loanAgreement.getRecipient().getCustomerNumber().getValue());
|
processVariables.put(RECOMMENDATION_CUSTOMER_NUMBER, loanAgreement.getRecipient().getCustomerNumber().getValue());
|
||||||
verify(runtimeService).startProcessInstanceByMessage(
|
verify(runtimeService).startProcessInstanceByMessage(
|
||||||
START_EVENT_MESSAGE_REF,
|
RECOMMENDATION_START_EVENT_MESSAGE_REF,
|
||||||
caseId + "-" + loanAgreement.getLoanAgreementNumber().getValue(),
|
caseId + "-" + loanAgreement.getLoanAgreementNumber().getValue(),
|
||||||
processVariables
|
processVariables
|
||||||
);
|
);
|
||||||
@@ -35,9 +35,9 @@ class LoanAgreementRepositoryTest {
|
|||||||
LoanAgreementEntity dbEntity = createLoanAgreementEntity();
|
LoanAgreementEntity dbEntity = createLoanAgreementEntity();
|
||||||
when(crudRepository.save(mapper.mapToDb(loanAgreement))).thenReturn(dbEntity);
|
when(crudRepository.save(mapper.mapToDb(loanAgreement))).thenReturn(dbEntity);
|
||||||
|
|
||||||
LoanAgreementNumber result = classUnderTest.save(loanAgreement);
|
LoanAgreement result = classUnderTest.save(loanAgreement);
|
||||||
|
|
||||||
assertThat(result.getValue()).isEqualTo(dbEntity.getId());
|
assertThat(result).isEqualTo(createLoanAgreementWithNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.loan.agreement.adapter.out.recommendation;
|
||||||
|
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CaseId;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.LoanAgreement;
|
||||||
|
import okhttp3.mockwebserver.MockResponse;
|
||||||
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
|
import okhttp3.mockwebserver.RecordedRequest;
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.TestdataGenerator.createLoanAgreement;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
class RecommendationClientTest {
|
||||||
|
|
||||||
|
private RecommendationClient classUnderTest;
|
||||||
|
|
||||||
|
public static MockWebServer mockBackEnd;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void setUp() throws IOException {
|
||||||
|
mockBackEnd = new MockWebServer();
|
||||||
|
mockBackEnd.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
static void tearDown() throws IOException {
|
||||||
|
mockBackEnd.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void initialize() {
|
||||||
|
String baseUrl = String.format("localhost:%s", mockBackEnd.getPort());
|
||||||
|
classUnderTest = new RecommendationClient(baseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_class_runtime_service_to_start() throws Exception {
|
||||||
|
CaseId caseId = new CaseId("11");
|
||||||
|
LoanAgreement loanAgreement = createLoanAgreement();
|
||||||
|
RecommendationResource recommendationResource = new RecommendationResource();
|
||||||
|
recommendationResource.setLoanAgreementNumber(loanAgreement.getLoanAgreementNumber().getValue());
|
||||||
|
recommendationResource.setCustomerNumber(loanAgreement.getRecipient().getCustomerNumber().getValue());
|
||||||
|
String requestJson = "{\"loanAgreementNumber\":" + loanAgreement.getLoanAgreementNumber().getValue() +
|
||||||
|
",\"customerNumber\":\"" + loanAgreement.getRecipient().getCustomerNumber().getValue() + "\"}";
|
||||||
|
|
||||||
|
mockBackEnd.enqueue(new MockResponse()
|
||||||
|
.addHeader("Content-Type", "application/json"));
|
||||||
|
|
||||||
|
classUnderTest.startLoanAgreement(caseId, loanAgreement);
|
||||||
|
|
||||||
|
RecordedRequest recordedRequest = mockBackEnd.takeRequest();
|
||||||
|
assertThat(recordedRequest.getMethod()).isEqualTo("POST");
|
||||||
|
assertThat(recordedRequest.getPath()).isEqualTo("/recommendation/" + caseId);
|
||||||
|
assertThat(recordedRequest.getBody().readUtf8()).isEqualTo(requestJson);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model;
|
|||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.recipient.Recipient;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.recipient.Recipient;
|
||||||
import io.github.domainprimitives.validation.InvariantException;
|
import io.github.domainprimitives.validation.InvariantException;
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ class LoanAgreementTest {
|
|||||||
LoanAgreement loanAgreement = new LoanAgreement(recipient, amount);
|
LoanAgreement loanAgreement = new LoanAgreement(recipient, amount);
|
||||||
|
|
||||||
assertThat(loanAgreement).isNotNull();
|
assertThat(loanAgreement).isNotNull();
|
||||||
assertThat(loanAgreement.getRecipient()).isEqualTo(recipient);
|
Assertions.assertThat(loanAgreement.getRecipient()).isEqualTo(recipient);
|
||||||
assertThat(loanAgreement.getAmount()).isEqualTo(amount);
|
assertThat(loanAgreement.getAmount()).isEqualTo(amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ class LoanAgreementTest {
|
|||||||
LoanAgreement loanAgreement = new LoanAgreement(loanAgreementNumber, recipient, amount);
|
LoanAgreement loanAgreement = new LoanAgreement(loanAgreementNumber, recipient, amount);
|
||||||
|
|
||||||
assertThat(loanAgreement).isNotNull();
|
assertThat(loanAgreement).isNotNull();
|
||||||
assertThat(loanAgreement.getRecipient()).isEqualTo(recipient);
|
Assertions.assertThat(loanAgreement.getRecipient()).isEqualTo(recipient);
|
||||||
assertThat(loanAgreement.getAmount()).isEqualTo(amount);
|
assertThat(loanAgreement.getAmount()).isEqualTo(amount);
|
||||||
assertThat(loanAgreement.getLoanAgreementNumber()).isEqualTo(loanAgreementNumber);
|
assertThat(loanAgreement.getLoanAgreementNumber()).isEqualTo(loanAgreementNumber);
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,13 @@ import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.LoanAgreem
|
|||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementCommand;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementCommand;
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementDistributor;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementDistributor;
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementQuery;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.LoanAgreementQuery;
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.ProcessEngineCommand;
|
import de.weinbrecht.luc.bpm.architecture.loan.agreement.usecase.out.RecommendationTrigger;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.InjectMocks;
|
import org.mockito.InjectMocks;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoSettings;
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
|
||||||
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.TestdataGenerator.createLoanAgreement;
|
||||||
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.TestdataGenerator.createLoanAgreementWithNumber;
|
import static de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.TestdataGenerator.createLoanAgreementWithNumber;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
@@ -26,7 +27,7 @@ class LoanAgreementServiceTest {
|
|||||||
private LoanAgreementCommand loanAgreementCommand;
|
private LoanAgreementCommand loanAgreementCommand;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private ProcessEngineCommand processEngineCommand;
|
private RecommendationTrigger recommendationTrigger;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private LoanAgreementDistributor loanAgreementDistributor;
|
private LoanAgreementDistributor loanAgreementDistributor;
|
||||||
@@ -36,13 +37,14 @@ class LoanAgreementServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_safe_and_set_loan_number_on_creation() {
|
void should_safe_and_set_loan_number_on_creation() {
|
||||||
LoanAgreement loanAgreement = createLoanAgreementWithNumber();
|
LoanAgreement loanAgreement = createLoanAgreement();
|
||||||
when(loanAgreementCommand.save(loanAgreement)).thenReturn(loanAgreement.getLoanAgreementNumber());
|
LoanAgreement savedLoanAgreement = createLoanAgreementWithNumber();
|
||||||
|
when(loanAgreementCommand.save(loanAgreement)).thenReturn(savedLoanAgreement);
|
||||||
CaseId caseId = new CaseId("12");
|
CaseId caseId = new CaseId("12");
|
||||||
|
|
||||||
classUnderTest.create(loanAgreement, caseId);
|
classUnderTest.create(loanAgreement, caseId);
|
||||||
|
|
||||||
verify(processEngineCommand).startLoanAgreement(caseId, loanAgreement.getLoanAgreementNumber());
|
verify(recommendationTrigger).startLoanAgreement(caseId, savedLoanAgreement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -54,7 +56,7 @@ class LoanAgreementServiceTest {
|
|||||||
assertThrows(LoanAgreementException.class,
|
assertThrows(LoanAgreementException.class,
|
||||||
() -> classUnderTest.create(loanAgreement, caseId));
|
() -> classUnderTest.create(loanAgreement, caseId));
|
||||||
|
|
||||||
verify(processEngineCommand, never()).startLoanAgreement(caseId, loanAgreement.getLoanAgreementNumber());
|
verify(recommendationTrigger, never()).startLoanAgreement(caseId, any());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
138
pom.xml
138
pom.xml
@@ -1,138 +0,0 @@
|
|||||||
<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>de.weinbrecht.luc.bpm.architecture</groupId>
|
|
||||||
<artifactId>camunda-ddd-and-clean-architecture</artifactId>
|
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
|
|
||||||
<version.junit5>5.8.2</version.junit5>
|
|
||||||
<version.lombok>1.18.24</version.lombok>
|
|
||||||
<version.domainprimitives>0.1.0</version.domainprimitives>
|
|
||||||
<version.bpmAssert>1.1.0</version.bpmAssert>
|
|
||||||
<version.camundaMockito>6.17.0</version.camundaMockito>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-dependencies</artifactId>
|
|
||||||
<version>2.6.4</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.camunda.bpm</groupId>
|
|
||||||
<artifactId>camunda-bom</artifactId>
|
|
||||||
<version>7.17.0</version>
|
|
||||||
<scope>import</scope>
|
|
||||||
<type>pom</type>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.camunda.bpm.springboot</groupId>
|
|
||||||
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.camunda.bpm.springboot</groupId>
|
|
||||||
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.camunda.bpm.springboot</groupId>
|
|
||||||
<artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.h2database</groupId>
|
|
||||||
<artifactId>h2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.github.domain-primitives</groupId>
|
|
||||||
<artifactId>domainprimitives-java</artifactId>
|
|
||||||
<version>${version.domainprimitives}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${version.lombok}</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
|
||||||
<version>${version.junit5}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-params</artifactId>
|
|
||||||
<version>${version.junit5}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.junit.jupiter</groupId>
|
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
|
||||||
<version>${version.junit5}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.camunda.bpm.extension</groupId>
|
|
||||||
<artifactId>camunda-bpm-junit5</artifactId>
|
|
||||||
<version>${version.bpmAssert}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.camunda.community.mockito</groupId>
|
|
||||||
<artifactId>camunda-platform-7-mockito</artifactId>
|
|
||||||
<version>${version.camundaMockito}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
<version>2.6.4</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
|
||||||
17
recommendation/Dockerfile
Normal file
17
recommendation/Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM maven:3.8.5-openjdk-17 as build
|
||||||
|
|
||||||
|
COPY ../pom.xml .
|
||||||
|
|
||||||
|
RUN mvn -B dependency:go-offline
|
||||||
|
|
||||||
|
COPY ../src src
|
||||||
|
|
||||||
|
RUN mvn -B package
|
||||||
|
|
||||||
|
FROM openjdk:11-jre-slim-buster
|
||||||
|
|
||||||
|
COPY --from=build ../target/recommendation.jar .
|
||||||
|
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
|
ENTRYPOINT ["java", "-jar", "recommendation.jar"]
|
||||||
140
recommendation/pom.xml
Normal file
140
recommendation/pom.xml
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>de.weinbrecht.luc.bpm.architecture.recommendation</groupId>
|
||||||
|
<artifactId>recommendation</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
||||||
|
<version.springboot>2.6.4</version.springboot>
|
||||||
|
<version.camunda>7.17.0</version.camunda>
|
||||||
|
<version.junit5>5.8.2</version.junit5>
|
||||||
|
<version.lombok>1.18.24</version.lombok>
|
||||||
|
<version.domainprimitives>0.1.0</version.domainprimitives>
|
||||||
|
<version.bpmAssert>1.1.0</version.bpmAssert>
|
||||||
|
<version.camundaMockito>6.17.0</version.camundaMockito>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-dependencies</artifactId>
|
||||||
|
<version>${version.springboot}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm</groupId>
|
||||||
|
<artifactId>camunda-bom</artifactId>
|
||||||
|
<version>${version.camunda}</version>
|
||||||
|
<scope>import</scope>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm.springboot</groupId>
|
||||||
|
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm.springboot</groupId>
|
||||||
|
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm.springboot</groupId>
|
||||||
|
<artifactId>camunda-bpm-spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.domain-primitives</groupId>
|
||||||
|
<artifactId>domainprimitives-java</artifactId>
|
||||||
|
<version>${version.domainprimitives}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>${version.lombok}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>${version.junit5}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
|
<version>${version.junit5}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>${version.junit5}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.bpm.extension</groupId>
|
||||||
|
<artifactId>camunda-bpm-junit5</artifactId>
|
||||||
|
<version>${version.bpmAssert}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.camunda.community.mockito</groupId>
|
||||||
|
<artifactId>camunda-platform-7-mockito</artifactId>
|
||||||
|
<version>${version.camundaMockito}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<version>${version.springboot}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class Application {
|
||||||
|
|
||||||
|
public static void main(String... args) {
|
||||||
|
SpringApplication.run(Application.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common;
|
||||||
|
|
||||||
|
public class ProcessConstants {
|
||||||
|
public static final String START_EVENT_MESSAGE_REF = "crossSellingPotentialDiscoveredMessage";
|
||||||
|
|
||||||
|
public static final String CUSTOMER_NUMBER = "customerNumber";
|
||||||
|
public static final String CONTENT_NUMBER = "contentNumber";
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
|
|||||||
import org.camunda.bpm.engine.delegate.JavaDelegate;
|
import org.camunda.bpm.engine.delegate.JavaDelegate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.CONTENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.CONTENT_NUMBER;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Component
|
@Component
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.in.process;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.in.process;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CustomerNumber;
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Recommendation;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Recommendation;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.RecommendationQuery;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.RecommendationQuery;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.SendNotification;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.SendNotification;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -12,8 +12,8 @@ import org.camunda.bpm.engine.delegate.DelegateExecution;
|
|||||||
import org.camunda.bpm.engine.delegate.JavaDelegate;
|
import org.camunda.bpm.engine.delegate.JavaDelegate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.CONTENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.CONTENT_NUMBER;
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.CUSTOMER_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.CUSTOMER_NUMBER;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Component
|
@Component
|
||||||
@@ -27,7 +27,7 @@ public class SendRecommendation implements JavaDelegate {
|
|||||||
Long contentId = (Long) execution.getVariable(CONTENT_NUMBER);
|
Long contentId = (Long) execution.getVariable(CONTENT_NUMBER);
|
||||||
String customerId = (String) execution.getVariable(CUSTOMER_NUMBER);
|
String customerId = (String) execution.getVariable(CUSTOMER_NUMBER);
|
||||||
Content content = recommendationQuery.findContentById(new ContentId(contentId));
|
Content content = recommendationQuery.findContentById(new ContentId(contentId));
|
||||||
Customer customer = recommendationQuery.findCustomerById(new CustomerNumber(customerId));
|
Customer customer = recommendationQuery.findCustomerById(new CustomerId(customerId));
|
||||||
|
|
||||||
Recommendation recommendation = new Recommendation(customer, content);
|
Recommendation recommendation = new Recommendation(customer, content);
|
||||||
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.in.web;
|
||||||
|
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.in.RecommendationCreation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("recommendation")
|
||||||
|
public class RecommendationController {
|
||||||
|
|
||||||
|
private final RecommendationCreation recommendationCreation;
|
||||||
|
|
||||||
|
@PostMapping("/{caseId}")
|
||||||
|
public void create(@RequestBody RecommendationResource recommendationResource,
|
||||||
|
@PathVariable String caseId) {
|
||||||
|
recommendationCreation.create(
|
||||||
|
caseId,
|
||||||
|
recommendationResource.getLoanAgreementNumber(),
|
||||||
|
new CustomerId(recommendationResource.getCustomerNumber())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.in.web;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class RecommendationResource {
|
||||||
|
private Long loanAgreementNumber;
|
||||||
|
private String customerNumber;
|
||||||
|
}
|
||||||
@@ -1,20 +1,18 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CustomerNumber;
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentCRUDRepository;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentCRUDRepository;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentMapper;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentMapper;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentNotFoundException;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentNotFoundException;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.MailAddress;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.MailAddress;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Name;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Name;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.RecommendationQuery;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.RecommendationQuery;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import static java.lang.String.format;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Component
|
@Component
|
||||||
public class RecommendationRepository implements RecommendationQuery {
|
public class RecommendationRepository implements RecommendationQuery {
|
||||||
@@ -27,14 +25,14 @@ public class RecommendationRepository implements RecommendationQuery {
|
|||||||
return contentCRUDRepository.findById(contentId.getValue())
|
return contentCRUDRepository.findById(contentId.getValue())
|
||||||
.map(mapper::mapToDomain)
|
.map(mapper::mapToDomain)
|
||||||
.orElseThrow(() -> new ContentNotFoundException(
|
.orElseThrow(() -> new ContentNotFoundException(
|
||||||
format("Could not find recommendation content with id %s", contentId.getValue())));
|
String.format("Could not find recommendation content with id %s", contentId.getValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Customer findCustomerById(CustomerNumber customerNumber) {
|
public Customer findCustomerById(CustomerId customerId) {
|
||||||
// Here would be a own CRUDRepository for the customer information we need during recommendation
|
// Here would be a own CRUDRepository for the customer information we need during recommendation
|
||||||
return new Customer(
|
return new Customer(
|
||||||
customerNumber,
|
customerId,
|
||||||
new Name("Max Mustermann"),
|
new Name("Max Mustermann"),
|
||||||
new MailAddress("max@mustermann.de")
|
new MailAddress("max@mustermann.de")
|
||||||
);
|
);
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.process;
|
||||||
|
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.StartRecommendation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.camunda.bpm.engine.RuntimeService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.CUSTOMER_NUMBER;
|
||||||
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.START_EVENT_MESSAGE_REF;
|
||||||
|
import static java.util.Collections.singletonMap;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Component
|
||||||
|
public class ProcessEngineClient implements StartRecommendation {
|
||||||
|
|
||||||
|
private final RuntimeService runtimeService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(String caseId, CustomerId customerId) {
|
||||||
|
runtimeService.startProcessInstanceByMessage(
|
||||||
|
START_EVENT_MESSAGE_REF,
|
||||||
|
caseId,
|
||||||
|
singletonMap(CUSTOMER_NUMBER, customerId.getValue())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CustomerNumber;
|
|
||||||
import io.github.domainprimitives.object.ComposedValueObject;
|
import io.github.domainprimitives.object.ComposedValueObject;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -9,12 +8,12 @@ import lombok.Getter;
|
|||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class Customer extends ComposedValueObject {
|
public class Customer extends ComposedValueObject {
|
||||||
|
|
||||||
private final CustomerNumber customerNumber;
|
private final CustomerId customerId;
|
||||||
private final Name name;
|
private final Name name;
|
||||||
private final MailAddress mailAddress;
|
private final MailAddress mailAddress;
|
||||||
|
|
||||||
public Customer(CustomerNumber customerNumber, Name name, MailAddress mailAddress) {
|
public Customer(CustomerId customerId, Name name, MailAddress mailAddress) {
|
||||||
this.customerNumber = customerNumber;
|
this.customerId = customerId;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.mailAddress = mailAddress;
|
this.mailAddress = mailAddress;
|
||||||
this.validate();
|
this.validate();
|
||||||
@@ -22,7 +21,7 @@ public class Customer extends ComposedValueObject {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void validate() {
|
protected void validate() {
|
||||||
validateNotNull(customerNumber, "Customer Number");
|
validateNotNull(customerId, "Customer Number");
|
||||||
validateNotNull(name, "Name");
|
validateNotNull(name, "Name");
|
||||||
validateNotNull(mailAddress, "Mail Address");
|
validateNotNull(mailAddress, "Mail Address");
|
||||||
evaluateValidations();
|
evaluateValidations();
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer;
|
||||||
|
|
||||||
|
import io.github.domainprimitives.type.ValueObject;
|
||||||
|
|
||||||
|
import static io.github.domainprimitives.validation.Constraints.isNotBlank;
|
||||||
|
|
||||||
|
public class CustomerId extends ValueObject<String> {
|
||||||
|
public CustomerId(String value) {
|
||||||
|
super(value, isNotBlank());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +1,30 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.service;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.service;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.in.RecommendationCreation;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.in.RecommendationPicker;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.in.RecommendationPicker;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.RecommendationQuery;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.RecommendationQuery;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.StartRecommendation;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Component
|
@Component
|
||||||
class RecommendationService implements RecommendationPicker {
|
class RecommendationService implements RecommendationPicker, RecommendationCreation {
|
||||||
|
|
||||||
private final RecommendationQuery recommendationQuery;
|
private final RecommendationQuery recommendationQuery;
|
||||||
|
private final StartRecommendation startRecommendation;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContentId pickContent() {
|
public ContentId pickContent() {
|
||||||
// Magically decide which content is the right one for the customer
|
// Magically decide which content is the right one for the customer
|
||||||
return recommendationQuery.findContentById(new ContentId(1L)).getContentId();
|
return recommendationQuery.findContentById(new ContentId(1L)).getContentId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void create(String loanCaseId, Long loanAgreementNumber, CustomerId customerId) {
|
||||||
|
// Fetch customer her and save subset of needed values to recommendation
|
||||||
|
startRecommendation.start(loanCaseId + "-" + loanAgreementNumber, customerId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.usecase.in;
|
||||||
|
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
|
|
||||||
|
public interface RecommendationCreation {
|
||||||
|
void create(String loanCaseId, Long loanAgreementNumber, CustomerId customerId);
|
||||||
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CustomerNumber;
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
|
|
||||||
public interface RecommendationQuery {
|
public interface RecommendationQuery {
|
||||||
Content findContentById(ContentId contentId);
|
Content findContentById(ContentId contentId);
|
||||||
Customer findCustomerById(CustomerNumber customerNumber);
|
Customer findCustomerById(CustomerId customerId);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out;
|
||||||
|
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
|
|
||||||
|
public interface StartRecommendation {
|
||||||
|
void start(String caseId, CustomerId customerId);
|
||||||
|
}
|
||||||
16
recommendation/src/main/resources/application.yaml
Normal file
16
recommendation/src/main/resources/application.yaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
spring:
|
||||||
|
datasource:
|
||||||
|
url: jdbc:h2:file:./camunda-recommendation-h2-database
|
||||||
|
jpa:
|
||||||
|
hibernate:
|
||||||
|
ddl-auto: create-drop
|
||||||
|
|
||||||
|
camunda.bpm.admin-user:
|
||||||
|
id: admin
|
||||||
|
password: pw
|
||||||
|
generic-properties:
|
||||||
|
properties:
|
||||||
|
initializeTelemetry: false
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 8081
|
||||||
@@ -9,7 +9,6 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.PROCESS_DEFINITION;
|
|
||||||
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.assertThat;
|
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.assertThat;
|
||||||
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.runtimeService;
|
import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareTests.runtimeService;
|
||||||
import static org.camunda.community.mockito.DelegateExpressions.registerJavaDelegateMock;
|
import static org.camunda.community.mockito.DelegateExpressions.registerJavaDelegateMock;
|
||||||
@@ -18,6 +17,8 @@ import static org.camunda.community.mockito.DelegateExpressions.verifyJavaDelega
|
|||||||
@ExtendWith(ProcessEngineExtension.class)
|
@ExtendWith(ProcessEngineExtension.class)
|
||||||
class ProcessTest {
|
class ProcessTest {
|
||||||
|
|
||||||
|
public static final String PROCESS_DEFINITION = "Cross_Selling_Recommendation";
|
||||||
|
|
||||||
private static final String START_EVENT = "CrossSellingStartEvent";
|
private static final String START_EVENT = "CrossSellingStartEvent";
|
||||||
private static final String PICK_CONTENT_SERVICE_TASK = "PickContentServiceTask";
|
private static final String PICK_CONTENT_SERVICE_TASK = "PickContentServiceTask";
|
||||||
private static final String SEND_RECOMMENDATION_SERVICE_TASK = "SendRecommendationServiceTask";
|
private static final String SEND_RECOMMENDATION_SERVICE_TASK = "SendRecommendationServiceTask";
|
||||||
@@ -8,7 +8,7 @@ import org.mockito.InjectMocks;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoSettings;
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.CONTENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.CONTENT_NUMBER;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@MockitoSettings
|
@MockitoSettings
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.in.process;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.in.process;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CustomerNumber;
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Description;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Description;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Recommendation;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Recommendation;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.MailAddress;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.MailAddress;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Name;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Name;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.RecommendationQuery;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.out.RecommendationQuery;
|
||||||
@@ -16,8 +16,8 @@ import org.mockito.InjectMocks;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoSettings;
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.CONTENT_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.CONTENT_NUMBER;
|
||||||
import static de.weinbrecht.luc.bpm.architecture.common.ProcessConstants.CrossSellingRecommendation.CUSTOMER_NUMBER;
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.CUSTOMER_NUMBER;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
@MockitoSettings
|
@MockitoSettings
|
||||||
@@ -35,23 +35,23 @@ class SendRecommendationTest {
|
|||||||
@Test
|
@Test
|
||||||
void should_load_data_and_call_service_to_send_notification() {
|
void should_load_data_and_call_service_to_send_notification() {
|
||||||
ContentId contentId = new ContentId(1L);
|
ContentId contentId = new ContentId(1L);
|
||||||
CustomerNumber customerNumber = new CustomerNumber("A1");
|
CustomerId customerId = new CustomerId("A1");
|
||||||
DelegateExecution delegateExecution = mock(DelegateExecution.class);
|
DelegateExecution delegateExecution = mock(DelegateExecution.class);
|
||||||
when(delegateExecution.getVariable(CONTENT_NUMBER)).thenReturn(contentId.getValue());
|
when(delegateExecution.getVariable(CONTENT_NUMBER)).thenReturn(contentId.getValue());
|
||||||
when(delegateExecution.getVariable(CUSTOMER_NUMBER)).thenReturn(customerNumber.getValue());
|
when(delegateExecution.getVariable(CUSTOMER_NUMBER)).thenReturn(customerId.getValue());
|
||||||
Content content = new Content(contentId, new Description("Foo"));
|
Content content = new Content(contentId, new Description("Foo"));
|
||||||
when(recommendationQuery.findContentById(contentId)).thenReturn(content);
|
when(recommendationQuery.findContentById(contentId)).thenReturn(content);
|
||||||
Customer customer = createCustomer(customerNumber);
|
Customer customer = createCustomer(customerId);
|
||||||
when(recommendationQuery.findCustomerById(customerNumber)).thenReturn(customer);
|
when(recommendationQuery.findCustomerById(customerId)).thenReturn(customer);
|
||||||
|
|
||||||
classUnderTest.execute(delegateExecution);
|
classUnderTest.execute(delegateExecution);
|
||||||
|
|
||||||
verify(sendNotification).send(new Recommendation(customer, content));
|
verify(sendNotification).send(new Recommendation(customer, content));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Customer createCustomer(CustomerNumber customerNumber) {
|
private Customer createCustomer(CustomerId customerId) {
|
||||||
return new Customer(
|
return new Customer(
|
||||||
customerNumber,
|
customerId,
|
||||||
new Name("Tester"),
|
new Name("Tester"),
|
||||||
new MailAddress("tester@ewb.io")
|
new MailAddress("tester@ewb.io")
|
||||||
);
|
);
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.in.web;
|
||||||
|
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.usecase.in.RecommendationCreation;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||||
|
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||||
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
|
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||||
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE;
|
||||||
|
|
||||||
|
@WebMvcTest(RecommendationController.class)
|
||||||
|
class RecommendationControllerTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private RecommendationCreation recommendationCreation;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_class_creation_on_post() throws Exception {
|
||||||
|
String caseId = "A-11";
|
||||||
|
Long loanAgreementNumber = 1L;
|
||||||
|
CustomerId customerId = new CustomerId("C-8");
|
||||||
|
String requestJson = "{\"loanAgreementNumber\": \"" + loanAgreementNumber + "\",\"customerNumber\": \"" + customerId.getValue() + "\"}";
|
||||||
|
|
||||||
|
mockMvc.perform(
|
||||||
|
post("/recommendation/" + caseId)
|
||||||
|
.contentType(APPLICATION_JSON_VALUE)
|
||||||
|
.content(requestJson)
|
||||||
|
)
|
||||||
|
.andDo(print())
|
||||||
|
.andExpect(status().isOk());
|
||||||
|
verify(recommendationCreation).create(caseId, loanAgreementNumber, customerId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CustomerNumber;
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentCRUDRepository;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentCRUDRepository;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentEntity;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentEntity;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentMapper;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.db.content.ContentMapper;
|
||||||
@@ -9,6 +8,7 @@ import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Content;
|
|||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.ContentId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Description;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.Description;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.MailAddress;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.MailAddress;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Name;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Name;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -60,12 +60,12 @@ class RecommendationRepositoryTest {
|
|||||||
@Test
|
@Test
|
||||||
void should_find_customer() {
|
void should_find_customer() {
|
||||||
Customer customer = new Customer(
|
Customer customer = new Customer(
|
||||||
new CustomerNumber("A-11"),
|
new CustomerId("A-11"),
|
||||||
new Name("Max Mustermann"),
|
new Name("Max Mustermann"),
|
||||||
new MailAddress("max@mustermann.de")
|
new MailAddress("max@mustermann.de")
|
||||||
);
|
);
|
||||||
|
|
||||||
Customer result = classUnderTest.findCustomerById(customer.getCustomerNumber());
|
Customer result = classUnderTest.findCustomerById(customer.getCustomerId());
|
||||||
|
|
||||||
assertThat(result).isEqualTo(customer);
|
assertThat(result).isEqualTo(customer);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package de.weinbrecht.luc.bpm.architecture.recommendation.adapter.out.process;
|
||||||
|
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
|
import org.camunda.bpm.engine.RuntimeService;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
|
||||||
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.CUSTOMER_NUMBER;
|
||||||
|
import static de.weinbrecht.luc.bpm.architecture.recommendation.adapter.common.ProcessConstants.START_EVENT_MESSAGE_REF;
|
||||||
|
import static java.util.Collections.singletonMap;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
@MockitoSettings
|
||||||
|
class ProcessEngineClientTest {
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private ProcessEngineClient classUnderTest;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private RuntimeService runtimeService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_class_runtime_service_to_start() {
|
||||||
|
String caseId = "super-test";
|
||||||
|
CustomerId customerId = new CustomerId("Test");
|
||||||
|
|
||||||
|
classUnderTest.start(caseId, customerId);
|
||||||
|
|
||||||
|
verify(runtimeService).startProcessInstanceByMessage(
|
||||||
|
START_EVENT_MESSAGE_REF,
|
||||||
|
caseId,
|
||||||
|
singletonMap(CUSTOMER_NUMBER, customerId.getValue())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.model;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.model;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CustomerNumber;
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Customer;
|
||||||
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.CustomerId;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.MailAddress;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.MailAddress;
|
||||||
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Name;
|
import de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer.Name;
|
||||||
import io.github.domainprimitives.validation.InvariantException;
|
import io.github.domainprimitives.validation.InvariantException;
|
||||||
@@ -15,7 +15,7 @@ class RecommendationTest {
|
|||||||
@Test
|
@Test
|
||||||
void should_create_valid_object() {
|
void should_create_valid_object() {
|
||||||
Content content = new Content(new ContentId(1L), new Description("Test"));
|
Content content = new Content(new ContentId(1L), new Description("Test"));
|
||||||
Customer customer = new Customer(new CustomerNumber("A"), new Name("Tester"), new MailAddress("tester@web.io"));
|
Customer customer = new Customer(new CustomerId("A"), new Name("Tester"), new MailAddress("tester@web.io"));
|
||||||
|
|
||||||
Recommendation recommendation = new Recommendation(customer, content);
|
Recommendation recommendation = new Recommendation(customer, content);
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class RecommendationTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_throw_invariant_exception_if_content_is_null() {
|
void should_throw_invariant_exception_if_content_is_null() {
|
||||||
Customer customer = new Customer(new CustomerNumber("A"), new Name("Tester"), new MailAddress("tester@web.io"));
|
Customer customer = new Customer(new CustomerId("A"), new Name("Tester"), new MailAddress("tester@web.io"));
|
||||||
|
|
||||||
assertThrows(InvariantException.class, () -> new Recommendation(customer, null));
|
assertThrows(InvariantException.class, () -> new Recommendation(customer, null));
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer;
|
package de.weinbrecht.luc.bpm.architecture.recommendation.domain.model.customer;
|
||||||
|
|
||||||
import de.weinbrecht.luc.bpm.architecture.loan.agreement.domain.model.CustomerNumber;
|
|
||||||
import io.github.domainprimitives.validation.InvariantException;
|
import io.github.domainprimitives.validation.InvariantException;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -13,12 +12,12 @@ class CustomerTest {
|
|||||||
void should_create_valid_object() {
|
void should_create_valid_object() {
|
||||||
Name name = new Name("Tester");
|
Name name = new Name("Tester");
|
||||||
MailAddress mailAddress = new MailAddress("tester@web.io");
|
MailAddress mailAddress = new MailAddress("tester@web.io");
|
||||||
CustomerNumber customerNumber = new CustomerNumber("A-1");
|
CustomerId customerId = new CustomerId("A-1");
|
||||||
|
|
||||||
Customer customer = new Customer(customerNumber, name, mailAddress);
|
Customer customer = new Customer(customerId, name, mailAddress);
|
||||||
|
|
||||||
assertThat(customer).isNotNull();
|
assertThat(customer).isNotNull();
|
||||||
assertThat(customer.getCustomerNumber()).isEqualTo(customerNumber);
|
assertThat(customer.getCustomerId()).isEqualTo(customerId);
|
||||||
assertThat(customer.getName()).isEqualTo(name);
|
assertThat(customer.getName()).isEqualTo(name);
|
||||||
assertThat(customer.getMailAddress()).isEqualTo(mailAddress);
|
assertThat(customer.getMailAddress()).isEqualTo(mailAddress);
|
||||||
}
|
}
|
||||||
@@ -36,17 +35,17 @@ class CustomerTest {
|
|||||||
@Test
|
@Test
|
||||||
void should_throw_invariant_exception_if_name_is_null() {
|
void should_throw_invariant_exception_if_name_is_null() {
|
||||||
MailAddress mailAddress = new MailAddress("tester@web.io");
|
MailAddress mailAddress = new MailAddress("tester@web.io");
|
||||||
CustomerNumber customerNumber = new CustomerNumber("A-1");
|
CustomerId customerId = new CustomerId("A-1");
|
||||||
|
|
||||||
assertThrows(InvariantException.class, () -> new Customer(customerNumber, null, mailAddress));
|
assertThrows(InvariantException.class, () -> new Customer(customerId, null, mailAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_throw_invariant_exception_if_mail_is_null() {
|
void should_throw_invariant_exception_if_mail_is_null() {
|
||||||
Name name = new Name("Tester");
|
Name name = new Name("Tester");
|
||||||
CustomerNumber customerNumber = new CustomerNumber("A-1");
|
CustomerId customerId = new CustomerId("A-1");
|
||||||
|
|
||||||
assertThrows(InvariantException.class, () -> new Customer(customerNumber, name, null));
|
assertThrows(InvariantException.class, () -> new Customer(customerId, name, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user