Skip to content

Commit

Permalink
refactor(engine): split duplicate check method
Browse files Browse the repository at this point in the history
* split method of DRG duplicate check to be more explicit and align with the new check method for decisions
  • Loading branch information
saig0 committed May 31, 2022
1 parent 30c0e73 commit aa5d49d
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ private long appendMetadataToDeploymentEvent(
latestDrg -> {
final int latestVersion = latestDrg.getDecisionRequirementsVersion();
final boolean isDuplicate =
isDuplicate(resource, checksum, latestDrg)
hasSameResourceNameAs(resource, latestDrg)
&& hasSameChecksumAs(checksum, latestDrg)
&& hasSameDecisionRequirementsKeyAs(parsedDrg.getDecisions(), latestDrg);

if (isDuplicate) {
Expand Down Expand Up @@ -236,13 +237,14 @@ private long appendMetadataToDeploymentEvent(
return drgRecord.getDecisionRequirementsKey();
}

private boolean isDuplicate(
final DeploymentResource resource,
final DirectBuffer checksum,
final PersistedDecisionRequirements drg) {
private boolean hasSameResourceNameAs(
final DeploymentResource resource, final PersistedDecisionRequirements drg) {
return drg.getResourceName().equals(resource.getResourceNameBuffer());
}

return drg.getResourceName().equals(resource.getResourceNameBuffer())
&& drg.getChecksum().equals(checksum);
private boolean hasSameChecksumAs(
final DirectBuffer checksum, final PersistedDecisionRequirements drg) {
return drg.getChecksum().equals(checksum);
}

private boolean hasSameDecisionRequirementsKeyAs(
Expand Down

0 comments on commit aa5d49d

Please sign in to comment.