diff --git a/.gitignore b/.gitignore index 7334292..ba59bfa 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,6 @@ target/ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* **/bin/ + +# OpenPrevo-DB +**/openprevo.mv.db diff --git a/demo/build.gradle b/demo/build.gradle index 627f342..5152adc 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -30,12 +30,18 @@ task prepareHub(dependsOn: prepareHubDockerConfig, type: Copy) { into "${buildDir}/demo/Hub" doLast { def javaCmd = "java -Dserver.port=8859 -Dopen.prevo.hub.config.file=file:demo-nodes.yml -jar ${project(":hub").bootJar.archiveName}" - def batFile = new File("${buildDir}/demo/Hub/start.bat") - batFile.text = javaCmd - batFile.executable = true - def shFile = new File("${buildDir}/demo/Hub/start.sh") - shFile.text = javaCmd - shFile.executable = true + def startBatFile = new File("${buildDir}/demo/Hub/start.bat") + startBatFile.text = javaCmd + startBatFile.executable = true + def cleanBatFile = new File("${buildDir}/demo/Hub/clean-db.bat") + cleanBatFile.text = 'del openprevo.mv.db' + cleanBatFile.executable = true + def startShFile = new File("${buildDir}/demo/Hub/start.sh") + startShFile.text = "#!/usr/bin/env bash\n${javaCmd}" + startShFile.executable = true + def cleanDbShFile = new File("${buildDir}/demo/Hub/clean-db.sh") + cleanDbShFile.text = '#!/usr/bin/env bash\nrm openprevo.mv.db' + cleanDbShFile.executable = true } } @@ -73,11 +79,12 @@ def createTask(node) { into "${buildDir}/demo/${node.name}" doLast { + def javaCmd = getJavaCommandLineForNode(node) def batFile = new File("${buildDir}/demo/${node.name}/start.bat") - batFile.text = getJavaCommandLineForNode(node) + batFile.text = javaCmd batFile.executable = true def shFile = new File("${buildDir}/demo/${node.name}/start.sh") - shFile.text = getJavaCommandLineForNode(node) + shFile.text = "#!/usr/bin/env bash\n${javaCmd}" shFile.executable = true } } diff --git a/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchForCommencement.java b/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchForCommencement.java index 3a7487a..70fcde1 100644 --- a/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchForCommencement.java +++ b/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchForCommencement.java @@ -1,119 +1,26 @@ package ch.prevo.open.encrypted.model; -import java.time.LocalDate; - import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import java.time.LocalDate; + /** * Matching notification sent to an OpenPrevo Node. */ -public class MatchForCommencement { - - private String encryptedOasiNumber; - private String retirementFundUid; - private String previousRetirementFundUid; - private LocalDate commencementDate; - private LocalDate terminationDate; - - public MatchForCommencement() {} - - public MatchForCommencement(String encryptedOasiNumber, - String retirementFundUid, - String previousRetirementFundUid, - LocalDate commencementDate, - LocalDate terminationDate) { - this.encryptedOasiNumber = encryptedOasiNumber; - this.retirementFundUid = retirementFundUid; - this.previousRetirementFundUid = previousRetirementFundUid; - this.commencementDate = commencementDate; - this.terminationDate = terminationDate; - } - - public String getEncryptedOasiNumber() { - return encryptedOasiNumber; - } - - public void setEncryptedOasiNumber(String encryptedOasiNumber) { - this.encryptedOasiNumber = encryptedOasiNumber; - } - - public String getRetirementFundUid() { - return retirementFundUid; - } - - public void setRetirementFundUid(String retirementFundUid) { - this.retirementFundUid = retirementFundUid; - } +public class MatchForCommencement extends MatchNotification { - public String getPreviousRetirementFundUid() { - return previousRetirementFundUid; + public MatchForCommencement() { } - public void setPreviousRetirementFundUid(String previousRetirementFundUid) { - this.previousRetirementFundUid = previousRetirementFundUid; - } - - public LocalDate getCommencementDate() { - return commencementDate; - } - - public void setCommencementDate(LocalDate commencementDate) { - this.commencementDate = commencementDate; - } - - public LocalDate getTerminationDate() { - return terminationDate; - } - - public void setTerminationDate(LocalDate terminationDate) { - this.terminationDate = terminationDate; + public MatchForCommencement(String encryptedOasiNumber, String previousRetirementFundUid, String newRetirementFundUid, LocalDate commencementDate, LocalDate terminationDate) { + super(encryptedOasiNumber, previousRetirementFundUid, newRetirementFundUid, commencementDate, terminationDate); } @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) - .append("encryptedOasiNumber", encryptedOasiNumber) - .append("retirementFundUid", retirementFundUid) - .append("previousRetirementFundUid", previousRetirementFundUid) - .append("commencementDate", commencementDate) - .append("terminationDate", terminationDate) + .appendSuper(super.toString()) .toString(); } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - MatchForCommencement that = (MatchForCommencement) o; - - if (encryptedOasiNumber != null ? - !encryptedOasiNumber.equals(that.encryptedOasiNumber) : - that.encryptedOasiNumber != null) - return false; - if (retirementFundUid != null ? - !retirementFundUid.equals(that.retirementFundUid) : - that.retirementFundUid != null) - return false; - if (previousRetirementFundUid != null ? - !previousRetirementFundUid.equals(that.previousRetirementFundUid) : - that.previousRetirementFundUid != null) - return false; - if (commencementDate != null ? !commencementDate.equals(that.commencementDate) : that.commencementDate != null) - return false; - return terminationDate != null ? terminationDate.equals(that.terminationDate) : that.terminationDate == null; - } - - @Override - public int hashCode() { - int result = encryptedOasiNumber != null ? encryptedOasiNumber.hashCode() : 0; - result = 31 * result + (retirementFundUid != null ? retirementFundUid.hashCode() : 0); - result = 31 * result + (previousRetirementFundUid != null ? previousRetirementFundUid.hashCode() : 0); - result = 31 * result + (commencementDate != null ? commencementDate.hashCode() : 0); - result = 31 * result + (terminationDate != null ? terminationDate.hashCode() : 0); - return result; - } } diff --git a/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchForTermination.java b/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchForTermination.java index c46013c..8c5be47 100644 --- a/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchForTermination.java +++ b/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchForTermination.java @@ -1,5 +1,7 @@ package ch.prevo.open.encrypted.model; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -8,67 +10,19 @@ /** * Matching notification sent to an OpenPrevo Node. */ -public class MatchForTermination { +public class MatchForTermination extends MatchNotification { - private String encryptedOasiNumber; - private String previousRetirementFundUid; - private String newRetirementFundUid; - private LocalDate commencementDate; - private LocalDate terminationDate; private EncryptedData transferInformation; + public MatchForTermination() { } public MatchForTermination(String encryptedOasiNumber, String previousRetirementFundUid, String newRetirementFundUid, LocalDate commencementDate, LocalDate terminationDate, EncryptedData transferInformation) { - this.encryptedOasiNumber = encryptedOasiNumber; - this.previousRetirementFundUid = previousRetirementFundUid; - this.newRetirementFundUid = newRetirementFundUid; - this.commencementDate = commencementDate; - this.terminationDate = terminationDate; + super(encryptedOasiNumber, previousRetirementFundUid, newRetirementFundUid, commencementDate, terminationDate); this.transferInformation = transferInformation; } - public String getEncryptedOasiNumber() { - return encryptedOasiNumber; - } - - public void setEncryptedOasiNumber(String encryptedOasiNumber) { - this.encryptedOasiNumber = encryptedOasiNumber; - } - - public String getPreviousRetirementFundUid() { - return previousRetirementFundUid; - } - - public void setPreviousRetirementFundUid(String previousRetirementFundUid) { - this.previousRetirementFundUid = previousRetirementFundUid; - } - - public String getNewRetirementFundUid() { - return newRetirementFundUid; - } - - public void setNewRetirementFundUid(String newRetirementFundUid) { - this.newRetirementFundUid = newRetirementFundUid; - } - - public LocalDate getCommencementDate() { - return commencementDate; - } - - public void setCommencementDate(LocalDate commencementDate) { - this.commencementDate = commencementDate; - } - - public LocalDate getTerminationDate() { - return terminationDate; - } - - public void setTerminationDate(LocalDate terminationDate) { - this.terminationDate = terminationDate; - } - public EncryptedData getTransferInformation() { return transferInformation; } @@ -77,62 +31,33 @@ public void setTransferInformation(EncryptedData transferInformation) { this.transferInformation = transferInformation; } - /** - * I.E. are all attributes except the encrypted transfer info equal - */ - public boolean isSameMatch(MatchForTermination that) { - if (this == that) return true; - if (that == null) return false; - - if (encryptedOasiNumber != null ? !encryptedOasiNumber.equals(that.encryptedOasiNumber) : that.encryptedOasiNumber != null) - return false; - if (previousRetirementFundUid != null ? !previousRetirementFundUid.equals(that.previousRetirementFundUid) : that.previousRetirementFundUid != null) - return false; - if (newRetirementFundUid != null ? !newRetirementFundUid.equals(that.newRetirementFundUid) : that.newRetirementFundUid != null) - return false; - if (commencementDate != null ? !commencementDate.equals(that.commencementDate) : that.commencementDate != null) return false; - return terminationDate != null ? terminationDate.equals(that.terminationDate) : that.terminationDate == null; - } - - @Override - public String toString() { - return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) - .append("encryptedOasiNumber", encryptedOasiNumber) - .append("previousRetirementFundUid", previousRetirementFundUid) - .append("newRetirementFundUid", newRetirementFundUid) - .append("commencementDate", commencementDate) - .append("terminationDate", terminationDate) - .append("transferInformation", transferInformation) - .toString(); - } - @Override public boolean equals(Object o) { if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; MatchForTermination that = (MatchForTermination) o; - if (encryptedOasiNumber != null ? !encryptedOasiNumber.equals(that.encryptedOasiNumber) : that.encryptedOasiNumber != null) - return false; - if (previousRetirementFundUid != null ? !previousRetirementFundUid.equals(that.previousRetirementFundUid) : that.previousRetirementFundUid != null) - return false; - if (newRetirementFundUid != null ? !newRetirementFundUid.equals(that.newRetirementFundUid) : that.newRetirementFundUid != null) - return false; - if (commencementDate != null ? !commencementDate.equals(that.commencementDate) : that.commencementDate != null) return false; - if (terminationDate != null ? !terminationDate.equals(that.terminationDate) : that.terminationDate != null) return false; - return transferInformation != null ? transferInformation.equals(that.transferInformation) : that.transferInformation == null; + return new EqualsBuilder() + .appendSuper(super.equals(o)) + .append(transferInformation, that.transferInformation) + .isEquals(); } @Override public int hashCode() { - int result = encryptedOasiNumber != null ? encryptedOasiNumber.hashCode() : 0; - result = 31 * result + (previousRetirementFundUid != null ? previousRetirementFundUid.hashCode() : 0); - result = 31 * result + (newRetirementFundUid != null ? newRetirementFundUid.hashCode() : 0); - result = 31 * result + (commencementDate != null ? commencementDate.hashCode() : 0); - result = 31 * result + (terminationDate != null ? terminationDate.hashCode() : 0); - result = 31 * result + (transferInformation != null ? transferInformation.hashCode() : 0); - return result; + return new HashCodeBuilder(17, 37) + .appendSuper(super.hashCode()) + .append(transferInformation) + .toHashCode(); } + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .appendSuper(super.toString()) + .append("transferInformation", transferInformation) + .toString(); + } } diff --git a/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchNotification.java b/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchNotification.java new file mode 100644 index 0000000..bd6dabe --- /dev/null +++ b/encrypted-data-model/src/main/java/ch/prevo/open/encrypted/model/MatchNotification.java @@ -0,0 +1,106 @@ +package ch.prevo.open.encrypted.model; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.time.LocalDate; + +public abstract class MatchNotification { + + private String encryptedOasiNumber; + private String previousRetirementFundUid; + private String newRetirementFundUid; + private LocalDate commencementDate; + private LocalDate terminationDate; + + public MatchNotification() {} + + public MatchNotification(String encryptedOasiNumber, String previousRetirementFundUid, String newRetirementFundUid, LocalDate commencementDate, LocalDate terminationDate) { + this.encryptedOasiNumber = encryptedOasiNumber; + this.previousRetirementFundUid = previousRetirementFundUid; + this.newRetirementFundUid = newRetirementFundUid; + this.commencementDate = commencementDate; + this.terminationDate = terminationDate; + } + + public String getEncryptedOasiNumber() { + return encryptedOasiNumber; + } + + public void setEncryptedOasiNumber(String encryptedOasiNumber) { + this.encryptedOasiNumber = encryptedOasiNumber; + } + + public String getPreviousRetirementFundUid() { + return previousRetirementFundUid; + } + + public void setPreviousRetirementFundUid(String previousRetirementFundUid) { + this.previousRetirementFundUid = previousRetirementFundUid; + } + + public String getNewRetirementFundUid() { + return newRetirementFundUid; + } + + public void setNewRetirementFundUid(String newRetirementFundUid) { + this.newRetirementFundUid = newRetirementFundUid; + } + + public LocalDate getCommencementDate() { + return commencementDate; + } + + public void setCommencementDate(LocalDate commencementDate) { + this.commencementDate = commencementDate; + } + + public LocalDate getTerminationDate() { + return terminationDate; + } + + public void setTerminationDate(LocalDate terminationDate) { + this.terminationDate = terminationDate; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + MatchNotification that = (MatchNotification) o; + + return new EqualsBuilder() + .append(encryptedOasiNumber, that.encryptedOasiNumber) + .append(previousRetirementFundUid, that.previousRetirementFundUid) + .append(newRetirementFundUid, that.newRetirementFundUid) + .append(commencementDate, that.commencementDate) + .append(terminationDate, that.terminationDate) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(encryptedOasiNumber) + .append(previousRetirementFundUid) + .append(newRetirementFundUid) + .append(commencementDate) + .append(terminationDate) + .toHashCode(); + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("encryptedOasiNumber", encryptedOasiNumber) + .append("previousRetirementFundUid", previousRetirementFundUid) + .append("newRetirementFundUid", newRetirementFundUid) + .append("commencementDate", commencementDate) + .append("terminationDate", terminationDate) + .toString(); + } +} diff --git a/hub/build.gradle b/hub/build.gradle index c0252ae..d211512 100644 --- a/hub/build.gradle +++ b/hub/build.gradle @@ -14,6 +14,9 @@ dependencies { compile("javax.inject:javax.inject") compile("org.springframework.boot:spring-boot-starter-jetty") compile("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml") + compile("org.springframework.boot:spring-boot-starter-data-jpa") + compile("com.h2database:h2") + compile("org.springframework.boot:spring-boot-devtools") testCompile("org.testcontainers:testcontainers") testCompile("org.springframework.boot:spring-boot-starter-test") diff --git a/hub/src/main/java/ch/prevo/open/hub/match/MatcherService.java b/hub/src/main/java/ch/prevo/open/hub/match/MatcherService.java index dc89897..661f245 100644 --- a/hub/src/main/java/ch/prevo/open/hub/match/MatcherService.java +++ b/hub/src/main/java/ch/prevo/open/hub/match/MatcherService.java @@ -1,16 +1,21 @@ package ch.prevo.open.hub.match; import ch.prevo.open.encrypted.model.InsurantInformation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; @Service public class MatcherService { + private static final Logger LOG = LoggerFactory.getLogger(MatcherService.class); + public List findMatches(Set retirementFundTerminations, Set retirementFundCommencements) { final List matches = new ArrayList<>(); for (InsurantInformation termination : retirementFundTerminations) { @@ -29,7 +34,12 @@ public List findMatches(Set retirementFundTerminatio } private Optional findMatchingEntry(Set retirementFundEntries, InsurantInformation termination) { - return retirementFundEntries.stream().filter(commencement -> isMatching(commencement, termination)).findAny(); + final List result = retirementFundEntries.stream().filter(commencement -> isMatching(commencement, termination)).collect(Collectors.toList()); + if (result.size() > 1) { + LOG.warn("Found more than one commencement for termination " + termination + ". Commencements: " + result); + return Optional.empty(); + } + return result.stream().findAny(); } private boolean isMatching(InsurantInformation entry, InsurantInformation exit) { diff --git a/hub/src/main/java/ch/prevo/open/hub/nodes/NodeCaller.java b/hub/src/main/java/ch/prevo/open/hub/nodes/NodeCaller.java index 2699c88..34777ec 100644 --- a/hub/src/main/java/ch/prevo/open/hub/nodes/NodeCaller.java +++ b/hub/src/main/java/ch/prevo/open/hub/nodes/NodeCaller.java @@ -4,7 +4,7 @@ import ch.prevo.open.encrypted.model.InsurantInformation; import ch.prevo.open.encrypted.model.MatchForCommencement; import ch.prevo.open.encrypted.model.MatchForTermination; -import ch.prevo.open.hub.repository.NotificationRepository; +import ch.prevo.open.hub.repository.NotificationDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.web.client.RestTemplateBuilder; @@ -24,13 +24,13 @@ public class NodeCaller { private final RestTemplate restTemplate; - private final NotificationRepository notificationRepository; + private final NotificationDAO notificationDAO; @Inject public NodeCaller(RestTemplateBuilder restTemplateBuilder, - NotificationRepository notificationRepository) { + NotificationDAO notificationDAO) { this.restTemplate = restTemplateBuilder.build(); - this.notificationRepository = notificationRepository; + this.notificationDAO = notificationDAO; } List getInsurantInformationList(String url) { @@ -45,12 +45,12 @@ List getInsurantInformationList(String url) { EncryptedData postCommencementNotification(String commencementMatchNotifyUrl, MatchForCommencement matchNotification) { try { - if (!notificationRepository.isMatchForCommencementAlreadyNotified(matchNotification)) { + if (!notificationDAO.isMatchForCommencementAlreadyNotified(matchNotification)) { LOGGER.debug("Send termination match notification for match: {}", matchNotification); EncryptedData encryptedCapitalTransferInfo = restTemplate .postForObject(commencementMatchNotifyUrl, matchNotification, EncryptedData.class); - notificationRepository.saveMatchForCommencement(matchNotification); + notificationDAO.saveMatchForCommencement(matchNotification); return encryptedCapitalTransferInfo; } @@ -64,10 +64,10 @@ EncryptedData postCommencementNotification(String commencementMatchNotifyUrl, Ma void postTerminationNotification(String terminationMatchNotifyUrl, MatchForTermination matchNotification) { try { - if (!notificationRepository.isMatchForTerminationAlreadyNotified(matchNotification)) { + if (!notificationDAO.isMatchForTerminationAlreadyNotified(matchNotification)) { LOGGER.debug("Send commencement match notification for match: {}", matchNotification); restTemplate.postForEntity(terminationMatchNotifyUrl, matchNotification, Void.class); - notificationRepository.saveMatchForTermination(matchNotification); + notificationDAO.saveMatchForTermination(matchNotification); } } catch (Exception e) { // TODO persist information that match needs to be notified later diff --git a/hub/src/main/java/ch/prevo/open/hub/nodes/NodeService.java b/hub/src/main/java/ch/prevo/open/hub/nodes/NodeService.java index 27d805b..d2c7db7 100644 --- a/hub/src/main/java/ch/prevo/open/hub/nodes/NodeService.java +++ b/hub/src/main/java/ch/prevo/open/hub/nodes/NodeService.java @@ -1,19 +1,21 @@ package ch.prevo.open.hub.nodes; -import static java.util.stream.Collectors.toList; +import ch.prevo.open.encrypted.model.EncryptedData; +import ch.prevo.open.encrypted.model.InsurantInformation; +import ch.prevo.open.encrypted.model.MatchForCommencement; +import ch.prevo.open.encrypted.model.MatchForTermination; +import ch.prevo.open.hub.match.Match; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import javax.inject.Inject; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.Predicate; -import javax.inject.Inject; -import ch.prevo.open.encrypted.model.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import ch.prevo.open.hub.match.Match; +import static java.util.stream.Collectors.toList; @Service public class NodeService { @@ -100,7 +102,7 @@ public void notifyMatches(List matches) { private EncryptedData tryNotifyNewRetirementFundAboutMatch(NodeConfiguration nodeConfig, Match match) { MatchForCommencement matchNotification = new MatchForCommencement(); matchNotification.setEncryptedOasiNumber(match.getEncryptedOasiNumber()); - matchNotification.setRetirementFundUid(match.getNewRetirementFundUid()); + matchNotification.setNewRetirementFundUid(match.getNewRetirementFundUid()); matchNotification.setPreviousRetirementFundUid(match.getPreviousRetirementFundUid()); matchNotification.setCommencementDate(match.getEntryDate()); matchNotification.setTerminationDate(match.getExitDate()); diff --git a/hub/src/main/java/ch/prevo/open/hub/repository/NotificationDAO.java b/hub/src/main/java/ch/prevo/open/hub/repository/NotificationDAO.java new file mode 100644 index 0000000..00d277a --- /dev/null +++ b/hub/src/main/java/ch/prevo/open/hub/repository/NotificationDAO.java @@ -0,0 +1,60 @@ +package ch.prevo.open.hub.repository; + +import ch.prevo.open.encrypted.model.MatchForCommencement; +import ch.prevo.open.encrypted.model.MatchForTermination; +import ch.prevo.open.encrypted.model.MatchNotification; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; +import java.util.Optional; + +@Service +public class NotificationDAO { + + private final NotificationRepository repository; + + @Inject + public NotificationDAO(NotificationRepository repository) { + this.repository = repository; + } + + public void saveMatchForTermination(MatchForTermination notification) { + final NotificationDTO dto = findByNotification(notification) + .orElseGet(() -> new NotificationDTO(notification)); + + dto.setMatchForTerminationNotified(true); + repository.save(dto); + } + + public void saveMatchForCommencement(MatchForCommencement notification) { + final NotificationDTO dto = findByNotification(notification) + .orElseGet( + () -> new NotificationDTO(notification) + ); + + dto.setMatchForCommencementNotified(true); + repository.save(dto); + } + + public boolean isMatchForTerminationAlreadyNotified(MatchForTermination notification) { + return findByNotification(notification) + .map(NotificationDTO::isMatchForTerminationNotified) + .orElse(false); + } + + public boolean isMatchForCommencementAlreadyNotified(MatchForCommencement notification) { + return findByNotification(notification) + .map(NotificationDTO::isMatchForCommencementNotified) + .orElse(false); + } + + private Optional findByNotification(MatchNotification notification) { + return repository.findByEncryptedOasiNumberAndPreviousRetirementFundUidAndNewRetirementFundUidAndCommencementDateAndTerminationDate( + notification.getEncryptedOasiNumber(), + notification.getPreviousRetirementFundUid(), + notification.getNewRetirementFundUid(), + notification.getCommencementDate(), + notification.getTerminationDate() + ); + } +} diff --git a/hub/src/main/java/ch/prevo/open/hub/repository/NotificationDTO.java b/hub/src/main/java/ch/prevo/open/hub/repository/NotificationDTO.java new file mode 100644 index 0000000..66a2f2a --- /dev/null +++ b/hub/src/main/java/ch/prevo/open/hub/repository/NotificationDTO.java @@ -0,0 +1,129 @@ +package ch.prevo.open.hub.repository; + +import ch.prevo.open.encrypted.model.MatchNotification; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import java.time.LocalDate; + +@Entity(name = "NOTIFICATION") +public class NotificationDTO { + + @Id + @GeneratedValue + @Column(name="ID") + private long id; + + @Column(name="ENCRYPTED_OASI_NUMBER") + private String encryptedOasiNumber; + + @Column(name="PREVIOUS_RETIREMENT_FUND_UID") + private String previousRetirementFundUid; + + @Column(name="NEW_RETIREMENT_FUND_UID") + private String newRetirementFundUid; + + @Column(name="COMMENCEMENT_DATE") + private LocalDate commencementDate; + + @Column(name="TERMINATION_DATE") + private LocalDate terminationDate; + + @Column(name="MATCH_FOR_COMMENCEMENT_NOTIFIED") + private boolean matchForCommencementNotified; + + @Column(name="MATCH_FOR_TERMINATION_NOTIFIED") + private boolean matchForTerminationNotified; + + public NotificationDTO() {} + + public NotificationDTO(MatchNotification notification) { + this.encryptedOasiNumber = notification.getEncryptedOasiNumber(); + this.previousRetirementFundUid = notification.getPreviousRetirementFundUid(); + this.newRetirementFundUid = notification.getNewRetirementFundUid(); + this.commencementDate = notification.getCommencementDate(); + this.terminationDate = notification.getTerminationDate(); + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getEncryptedOasiNumber() { + return encryptedOasiNumber; + } + + public void setEncryptedOasiNumber(String encryptedOasiNumber) { + this.encryptedOasiNumber = encryptedOasiNumber; + } + + public String getPreviousRetirementFundUid() { + return previousRetirementFundUid; + } + + public void setPreviousRetirementFundUid(String previousRetirementFundUid) { + this.previousRetirementFundUid = previousRetirementFundUid; + } + + public String getNewRetirementFundUid() { + return newRetirementFundUid; + } + + public void setNewRetirementFundUid(String newRetirementFundUid) { + this.newRetirementFundUid = newRetirementFundUid; + } + + public LocalDate getCommencementDate() { + return commencementDate; + } + + public void setCommencementDate(LocalDate commencementDate) { + this.commencementDate = commencementDate; + } + + public LocalDate getTerminationDate() { + return terminationDate; + } + + public void setTerminationDate(LocalDate terminationDate) { + this.terminationDate = terminationDate; + } + + public boolean isMatchForCommencementNotified() { + return matchForCommencementNotified; + } + + public void setMatchForCommencementNotified(boolean commencementNotified) { + this.matchForCommencementNotified = commencementNotified; + } + + public boolean isMatchForTerminationNotified() { + return matchForTerminationNotified; + } + + public void setMatchForTerminationNotified(boolean terminationNotified) { + this.matchForTerminationNotified = terminationNotified; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) + .append("id", id) + .append("encryptedOasiNumber", encryptedOasiNumber) + .append("previousRetirementFundUid", previousRetirementFundUid) + .append("newRetirementFundUid", newRetirementFundUid) + .append("commencementDate", commencementDate) + .append("terminationDate", terminationDate) + .append("matchForCommencementNotified", matchForCommencementNotified) + .append("matchForTerminationNotified", matchForTerminationNotified) + .toString(); + } +} diff --git a/hub/src/main/java/ch/prevo/open/hub/repository/NotificationRepository.java b/hub/src/main/java/ch/prevo/open/hub/repository/NotificationRepository.java index 84eeb18..d559c36 100644 --- a/hub/src/main/java/ch/prevo/open/hub/repository/NotificationRepository.java +++ b/hub/src/main/java/ch/prevo/open/hub/repository/NotificationRepository.java @@ -1,35 +1,19 @@ package ch.prevo.open.hub.repository; -import ch.prevo.open.encrypted.model.MatchForCommencement; -import ch.prevo.open.encrypted.model.MatchForTermination; -import org.springframework.stereotype.Repository; +import org.springframework.data.jpa.repository.JpaRepository; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; +import java.time.LocalDate; +import java.util.Optional; -@Repository -public class NotificationRepository { +public interface NotificationRepository extends JpaRepository { - private final List matchesForTerminations = Collections - .synchronizedList(new ArrayList<>()); + Optional findByEncryptedOasiNumberAndPreviousRetirementFundUidAndNewRetirementFundUidAndCommencementDateAndTerminationDate( + String encryptedOasiNumber, + String previousRetirementFundUid, + String newRetirementFundUid, + LocalDate commencementDate, + LocalDate terminationDate + ); - private final List matchesForCommencements = Collections - .synchronizedList(new ArrayList<>()); - public void saveMatchForTermination(MatchForTermination notification) { - this.matchesForTerminations.add(notification); - } - - public void saveMatchForCommencement(MatchForCommencement notification) { - this.matchesForCommencements.add(notification); - } - - public boolean isMatchForTerminationAlreadyNotified(MatchForTermination notification) { - return matchesForTerminations.stream().anyMatch(existing -> existing.isSameMatch(notification)); - } - - public boolean isMatchForCommencementAlreadyNotified(MatchForCommencement notification) { - return matchesForCommencements.contains(notification); - } } diff --git a/hub/src/main/resources/application.properties b/hub/src/main/resources/application.properties index 91a9703..e5ae797 100644 --- a/hub/src/main/resources/application.properties +++ b/hub/src/main/resources/application.properties @@ -1,2 +1,12 @@ +# database configuration +spring.datasource.driverClassName = org.h2.Driver +spring.datasource.url=jdbc:h2:./openprevo +spring.datasource.username = sa +spring.datasource.password = sa + +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.H2Dialect +spring.jpa.hibernate.use-new-id-generator-mappings = true +spring.jpa.hibernate.ddl-auto = update + logging.level.ch.prevo.open=DEBUG open.prevo.hub.config.file=classpath:nodes.yaml \ No newline at end of file diff --git a/hub/src/test/java/ch/prevo/open/hub/HubServiceTest.java b/hub/src/test/java/ch/prevo/open/hub/HubServiceTest.java index b20d40c..4ea742d 100644 --- a/hub/src/test/java/ch/prevo/open/hub/HubServiceTest.java +++ b/hub/src/test/java/ch/prevo/open/hub/HubServiceTest.java @@ -34,8 +34,9 @@ public class HubServiceTest { @Inject private HubService hubService; + @SuppressWarnings("unchecked") @Test - public void matchAndNotify() throws Exception { + public void matchAndNotify() { InsurantInformation entry = new InsurantInformation("123", "1"); InsurantInformation exit = new InsurantInformation("123", "2"); when(nodeService.getCurrentCommencements()).thenReturn(singleton(entry)); @@ -51,6 +52,7 @@ public void matchAndNotify() throws Exception { assertEquals(entry.getRetirementFundUid(), notifiedMatches.get(0).getNewRetirementFundUid()); } + @SuppressWarnings("unchecked") @Test public void matchAndNotifySeveralTerminationsForSingleCommencement() { // given diff --git a/hub/src/test/java/ch/prevo/open/hub/match/MatcherServiceTest.java b/hub/src/test/java/ch/prevo/open/hub/match/MatcherServiceTest.java index a9d13a9..5928ed4 100644 --- a/hub/src/test/java/ch/prevo/open/hub/match/MatcherServiceTest.java +++ b/hub/src/test/java/ch/prevo/open/hub/match/MatcherServiceTest.java @@ -32,7 +32,7 @@ public void setup() { } @Test - public void findMatches() throws Exception { + public void findMatches() { Set terminations = createSet(new InsurantInformation(OASI_1, UID_1)); Set commencements = createSet(new InsurantInformation(OASI_1, UID_2), new InsurantInformation(OASI_2, UID_3)); @@ -46,7 +46,7 @@ public void findMatches() throws Exception { } @Test - public void findMatchesWithinSameRetirementFund() throws Exception { + public void findMatchesWithinSameRetirementFund() { Set terminations = createSet(new InsurantInformation(OASI_1, UID_1, of(2018, 6, 1))); Set commencements = createSet(new InsurantInformation(OASI_1, UID_1, of(2018, 8, 1))); @@ -56,7 +56,7 @@ public void findMatchesWithinSameRetirementFund() throws Exception { } @Test - public void findMatchesWithinSameRetirementFund_entryBeforeExit() throws Exception { + public void findMatchesWithinSameRetirementFund_entryBeforeExit() { Set terminations = createSet(new InsurantInformation(OASI_1, UID_1, of(2018, 6, 1))); Set commencements = createSet(new InsurantInformation(OASI_1, UID_1, of(2018, 1, 1))); @@ -66,21 +66,18 @@ public void findMatchesWithinSameRetirementFund_entryBeforeExit() throws Excepti } @Test - public void findMatchesEmptyInput() throws Exception { + public void findMatchesEmptyInput() { assertTrue(matcherService.findMatches(emptySet(), emptySet()).isEmpty()); } @Test - public void findMatchesWithDuplicates() throws Exception { + public void findMatchesWithDuplicates() { Set terminations = createSet(new InsurantInformation(OASI_1, UID_1)); Set commencements = createSet(new InsurantInformation(OASI_1, UID_2), new InsurantInformation(OASI_1, UID_3)); List matches = matcherService.findMatches(terminations, commencements); - assertThat(matches).containsAnyOf( - new Match(OASI_1, UID_1, UID_2, null, null), - new Match(OASI_1, UID_1, UID_3, null, null) - ); + assertThat(matches).isEmpty(); } @Test diff --git a/hub/src/test/java/ch/prevo/open/hub/nodes/NodeCallerTest.java b/hub/src/test/java/ch/prevo/open/hub/nodes/NodeCallerTest.java index 18aafa2..0f1bdcb 100644 --- a/hub/src/test/java/ch/prevo/open/hub/nodes/NodeCallerTest.java +++ b/hub/src/test/java/ch/prevo/open/hub/nodes/NodeCallerTest.java @@ -4,10 +4,11 @@ import ch.prevo.open.encrypted.model.InsurantInformation; import ch.prevo.open.encrypted.model.MatchForCommencement; import ch.prevo.open.encrypted.model.MatchForTermination; -import ch.prevo.open.hub.repository.NotificationRepository; +import ch.prevo.open.hub.repository.NotificationDAO; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.autoconfigure.web.client.RestClientTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.annotation.DirtiesContext; @@ -22,13 +23,15 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import static org.springframework.test.web.client.match.MockRestRequestMatchers.jsonPath; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; @RunWith(SpringRunner.class) -@RestClientTest({NodeCaller.class, NotificationRepository.class}) +@RestClientTest({ NodeCaller.class }) @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) public class NodeCallerTest { @@ -66,8 +69,11 @@ public class NodeCallerTest { @Inject private NodeCaller nodeCaller; + @MockBean + private NotificationDAO notificationDAO; + @Test - public void getInsurantInformationList() throws Exception { + public void getInsurantInformationList() { server.expect(requestTo(URL1)) .andRespond(withSuccess(INSURANT_INFORMATION_JSON_ARRAY, MediaType.APPLICATION_JSON)); @@ -115,7 +121,7 @@ public void tryGetInsurantInformationListWithUnreachableNode() { public void notifyCommencementMatch() { server.expect(requestTo(URL1)) .andExpect(jsonPath("$.encryptedOasiNumber", is(OASI1))) - .andExpect(jsonPath("$.retirementFundUid", is(UID2))) + .andExpect(jsonPath("$.newRetirementFundUid", is(UID2))) .andRespond(withSuccess(CAPITAL_TRANSFER_INFORMATION, MediaType.APPLICATION_JSON)); MatchForCommencement MatchForCommencement = createMatchForCommencement(); @@ -132,39 +138,41 @@ public void notifyCommencementMatch() { @Test public void notifyCommencementMatchOnlyOnce() { + // given + final MatchForCommencement matchForCommencement = createMatchForCommencement(); server.expect(requestTo(URL1)) .andExpect(jsonPath("$.encryptedOasiNumber", is(OASI1))) - .andExpect(jsonPath("$.retirementFundUid", is(UID2))) + .andExpect(jsonPath("$.newRetirementFundUid", is(UID2))) .andRespond(withSuccess(CAPITAL_TRANSFER_INFORMATION, MediaType.APPLICATION_JSON)); - - MatchForCommencement MatchForCommencement = createMatchForCommencement(); + when(notificationDAO.isMatchForCommencementAlreadyNotified(matchForCommencement)).thenReturn(false).thenReturn(true); // when - EncryptedData capitalTransferInformation = nodeCaller - .postCommencementNotification(URL1, MatchForCommencement); - EncryptedData secondCallTransferInfo = nodeCaller - .postCommencementNotification(URL1, MatchForCommencement); + final EncryptedData capitalTransferInformation = nodeCaller + .postCommencementNotification(URL1, matchForCommencement); + final EncryptedData secondCallTransferInfo = nodeCaller + .postCommencementNotification(URL1, matchForCommencement); // then server.verify(); assertThat(capitalTransferInformation).isNotNull(); assertThat(secondCallTransferInfo).isNull(); + verify(notificationDAO).saveMatchForCommencement(matchForCommencement); } @Test public void notifySingleCommencementMatchForSeveralTerminationMatches() { server.expect(requestTo(URL1)) .andExpect(jsonPath("$.encryptedOasiNumber", is(OASI1))) - .andExpect(jsonPath("$.retirementFundUid", is(UID2))) + .andExpect(jsonPath("$.newRetirementFundUid", is(UID2))) .andRespond(withSuccess(CAPITAL_TRANSFER_INFORMATION, MediaType.APPLICATION_JSON)); server.expect(requestTo(URL1)) .andExpect(jsonPath("$.encryptedOasiNumber", is(OASI1))) - .andExpect(jsonPath("$.retirementFundUid", is(UID3))) + .andExpect(jsonPath("$.newRetirementFundUid", is(UID3))) .andRespond(withSuccess(CAPITAL_TRANSFER_INFORMATION, MediaType.APPLICATION_JSON)); MatchForCommencement matchForCommencement_node2 = createMatchForCommencement(); MatchForCommencement matchForCommencement_node3 = createMatchForCommencement(); - matchForCommencement_node3.setRetirementFundUid(UID3); + matchForCommencement_node3.setNewRetirementFundUid(UID3); // when EncryptedData capitalTransferInformation = nodeCaller @@ -184,7 +192,7 @@ public void verifyNotifyCommencementMatchIsSentInSecondApproachIfFirstWasNotSucc server.expect(requestTo(URL1)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); server.expect(requestTo(URL1)) .andExpect(jsonPath("$.encryptedOasiNumber", is(OASI1))) - .andExpect(jsonPath("$.retirementFundUid", is(UID2))) + .andExpect(jsonPath("$.newRetirementFundUid", is(UID2))) .andRespond(withSuccess(CAPITAL_TRANSFER_INFORMATION, MediaType.APPLICATION_JSON)); MatchForCommencement MatchForCommencement = createMatchForCommencement(); @@ -218,18 +226,20 @@ public void notifyTerminationMatch() { @Test public void notifyTerminationMatchOnlyOnce() { + // given + final MatchForTermination matchForTermination = createMatchForTermination(); server.expect(requestTo(URL2)) .andExpect(jsonPath("$.transferInformation.encryptedSymmetricKeyBase64", is(ENCRYPTED_KEY))) .andRespond(withSuccess()); - - MatchForTermination MatchForTermination = createMatchForTermination(); + when(notificationDAO.isMatchForTerminationAlreadyNotified(matchForTermination)).thenReturn(false).thenReturn(true); // when - nodeCaller.postTerminationNotification(URL2, MatchForTermination); - nodeCaller.postTerminationNotification(URL2, MatchForTermination); + nodeCaller.postTerminationNotification(URL2, matchForTermination); + nodeCaller.postTerminationNotification(URL2, matchForTermination); // then server.verify(); + verify(notificationDAO).saveMatchForTermination(matchForTermination); } @Test @@ -314,7 +324,7 @@ private MatchForCommencement createMatchForCommencement() { MatchForCommencement.setCommencementDate(of(2018, 7, 1)); MatchForCommencement.setTerminationDate(of(2018, 6, 30)); MatchForCommencement.setPreviousRetirementFundUid(UID1); - MatchForCommencement.setRetirementFundUid(UID2); + MatchForCommencement.setNewRetirementFundUid(UID2); return MatchForCommencement; } diff --git a/hub/src/test/java/ch/prevo/open/hub/repository/NotificationRepositoryTest.java b/hub/src/test/java/ch/prevo/open/hub/repository/NotificationDAOTest.java similarity index 70% rename from hub/src/test/java/ch/prevo/open/hub/repository/NotificationRepositoryTest.java rename to hub/src/test/java/ch/prevo/open/hub/repository/NotificationDAOTest.java index 1e8b54c..ee07b31 100644 --- a/hub/src/test/java/ch/prevo/open/hub/repository/NotificationRepositoryTest.java +++ b/hub/src/test/java/ch/prevo/open/hub/repository/NotificationDAOTest.java @@ -3,14 +3,21 @@ import ch.prevo.open.encrypted.model.EncryptedData; import ch.prevo.open.encrypted.model.MatchForCommencement; import ch.prevo.open.encrypted.model.MatchForTermination; -import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.junit4.SpringRunner; +import javax.inject.Inject; import java.time.LocalDate; import static org.assertj.core.api.Assertions.assertThat; -public class NotificationRepositoryTest { +@RunWith(SpringRunner.class) +@DataJpaTest +@ComponentScan +public class NotificationDAOTest { private final String OASI = "756.1335.5778.23"; private final String previousRetirementFundUID = "CHE-109.740.084"; @@ -18,31 +25,26 @@ public class NotificationRepositoryTest { private final LocalDate commencementDate = LocalDate.of(2018, 7, 1); private final LocalDate terminationDate = LocalDate.of(2018, 6, 30); - private NotificationRepository notificationRepository; - - @Before - public void setUp() { - this.notificationRepository = new NotificationRepository(); - } + @Inject + private NotificationDAO notificationDAO; @Test - public void isCommencementMatchAlreadyNotified() { + public void isMatchForTerminationAlreadyNotified() { // given MatchForTermination commencementMatch = getMatchForTermination(); MatchForTermination duplicateCommencementMatch = getMatchForTermination(); // when - notificationRepository = new NotificationRepository(); - boolean initiallyNotMatched = notificationRepository + boolean initiallyNotMatched = notificationDAO .isMatchForTerminationAlreadyNotified(commencementMatch); - notificationRepository.saveMatchForTermination(commencementMatch); + notificationDAO.saveMatchForTermination(commencementMatch); - boolean commencementMatchAlreadyNotified = notificationRepository + boolean commencementMatchAlreadyNotified = notificationDAO .isMatchForTerminationAlreadyNotified(commencementMatch); - boolean duplicateIsAlreadyNotified = notificationRepository + boolean duplicateIsAlreadyNotified = notificationDAO .isMatchForTerminationAlreadyNotified(duplicateCommencementMatch); // then @@ -60,23 +62,22 @@ private MatchForTermination getMatchForTermination() { } @Test - public void isTerminationMatchAlreadyNotified() { + public void isMatchForCommencementAlreadyNotified() { // given MatchForCommencement terminationMatch = getMatchForCommencement(); MatchForCommencement duplicateTerminationMatch = getMatchForCommencement(); // when - notificationRepository = new NotificationRepository(); - boolean initiallyNotMatched = notificationRepository + boolean initiallyNotMatched = notificationDAO .isMatchForCommencementAlreadyNotified(terminationMatch); - notificationRepository.saveMatchForCommencement(terminationMatch); + notificationDAO.saveMatchForCommencement(terminationMatch); - boolean commencementMatchAlreadyNotified = notificationRepository + boolean commencementMatchAlreadyNotified = notificationDAO .isMatchForCommencementAlreadyNotified(terminationMatch); - boolean duplicateIsAlreadyNotified = notificationRepository + boolean duplicateIsAlreadyNotified = notificationDAO .isMatchForCommencementAlreadyNotified(duplicateTerminationMatch); // then diff --git a/node/src/main/java/ch/prevo/open/node/api/MatchNotificationController.java b/node/src/main/java/ch/prevo/open/node/api/MatchNotificationController.java index d130142..e55a5cb 100644 --- a/node/src/main/java/ch/prevo/open/node/api/MatchNotificationController.java +++ b/node/src/main/java/ch/prevo/open/node/api/MatchNotificationController.java @@ -32,7 +32,7 @@ public MatchNotificationController(MatchNotificationService notificationService) @RequestMapping(value = "/commencement-match-notification", method = RequestMethod.POST) public ResponseEntity receiveCommencementMatchNotification(@RequestBody MatchForCommencement matchNotification) { LOGGER.debug("Receive commencement match notification for OASI {}, switching to new retirement fund: {}", - matchNotification.getEncryptedOasiNumber(), matchNotification.getRetirementFundUid()); + matchNotification.getEncryptedOasiNumber(), matchNotification.getNewRetirementFundUid()); try { final Optional transferInformation = notificationService diff --git a/node/src/main/java/ch/prevo/open/node/services/MatchNotificationService.java b/node/src/main/java/ch/prevo/open/node/services/MatchNotificationService.java index 0c4d450..ecc6d11 100644 --- a/node/src/main/java/ch/prevo/open/node/services/MatchNotificationService.java +++ b/node/src/main/java/ch/prevo/open/node/services/MatchNotificationService.java @@ -95,7 +95,7 @@ public Optional handleTerminationMatch(MatchForCommencement notif private boolean isSameAsNotification(EmploymentCommencement employmentCommencement, MatchForCommencement notification) { EmploymentInfo employmentInfo = employmentCommencement.getEmploymentInfo(); return Cryptography.digestOasiNumber(employmentInfo.getOasiNumber()).equals(notification.getEncryptedOasiNumber()) && - employmentInfo.getRetirementFundUid().equals(notification.getRetirementFundUid()) && + employmentInfo.getRetirementFundUid().equals(notification.getNewRetirementFundUid()) && employmentInfo.getDate().equals(notification.getCommencementDate()); } diff --git a/node/src/test/java/ch/prevo/open/node/api/MatchNotificationControllerTest.java b/node/src/test/java/ch/prevo/open/node/api/MatchNotificationControllerTest.java index 4bc32be..cb91aaa 100644 --- a/node/src/test/java/ch/prevo/open/node/api/MatchNotificationControllerTest.java +++ b/node/src/test/java/ch/prevo/open/node/api/MatchNotificationControllerTest.java @@ -79,7 +79,7 @@ public void sendCommencementNotificationToPreviousRetirementFund() throws Except // given MatchForCommencement commencementMatchNotification = new MatchForCommencement(); commencementMatchNotification.setEncryptedOasiNumber(Cryptography.digestOasiNumber("756.1234.5678.97")); - commencementMatchNotification.setRetirementFundUid(OWN_UID); + commencementMatchNotification.setNewRetirementFundUid(OWN_UID); commencementMatchNotification.setPreviousRetirementFundUid(OTHER_UID); commencementMatchNotification.setCommencementDate(LocalDate.of(2018, 7, 1)); commencementMatchNotification.setTerminationDate(LocalDate.of(2018, 6, 30));