Skip to content

Commit

Permalink
K1J-146: Updated logic in IntegratedUnitNotificationEvaluator so that…
Browse files Browse the repository at this point in the history
… it complies with business logic. (#1110)
  • Loading branch information
ChrilleSigerhed authored Sep 10, 2024
1 parent 3690a60 commit 4eaa03d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ private boolean evaluateMailNotification(List<String> unitIds, List<String> care
return false;
}

return activateFrom.isBefore(issuingDate);
return issuingDate.isBefore(activateFrom);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void shallReturnFalseIfNotificationConfigDoesNotContainAnyMatchingUnitOrCareUnit
}

@Test
void shallReturnFalseIfDateInConfigurationIsAfterActivationDate() {
void shallReturnTrueIfDateOfIssuingUnitIsBeforeConfigurationDateTime() {
final var regionNotificationConfig = RegionNotificationConfig.builder()
.region(REGION)
.configuration(
Expand All @@ -91,11 +91,11 @@ void shallReturnFalseIfDateInConfigurationIsAfterActivationDate() {
doReturn(List.of(regionNotificationConfig)).when(getUnitNotificationConfig).get();
final var result = integratedUnitNotificationEvaluator.mailNotification(CARE_PROVIDER_ID, ISSUED_ON_UNIT_ID, CERTIFICATE_ID,
ISSUING_DATE);
assertFalse(result);
assertTrue(result);
}

@Test
void shallReturnTrueIfDateInConfigurationIsBeforeActivationDateAndCareProviderMatch() {
void shallReturnFalseIfDateOfIssuingUnitIsBeforeConfigurationDateTimeButDoesNotMatchAnyUnitId() {
final var regionNotificationConfig = RegionNotificationConfig.builder()
.region(REGION)
.configuration(
Expand All @@ -111,27 +111,7 @@ void shallReturnTrueIfDateInConfigurationIsBeforeActivationDateAndCareProviderMa
doReturn(List.of(regionNotificationConfig)).when(getUnitNotificationConfig).get();
final var result = integratedUnitNotificationEvaluator.mailNotification(CARE_PROVIDER_ID, ISSUED_ON_UNIT_ID, CERTIFICATE_ID,
ISSUING_DATE);
assertTrue(result);
}

@Test
void shallReturnTrueIfDateInConfigurationIsBeforeActivationDateAndUnitIdMatch() {
final var regionNotificationConfig = RegionNotificationConfig.builder()
.region(REGION)
.configuration(
List.of(
IntegratedUnitNotificationConfig.builder()
.careProviders(List.of(NOT_MATCHING_ID))
.issuedOnUnit(List.of(ISSUED_ON_UNIT_ID))
.datetime(LocalDateTime.now().minusDays(1))
.build()
))
.build();

doReturn(List.of(regionNotificationConfig)).when(getUnitNotificationConfig).get();
final var result = integratedUnitNotificationEvaluator.mailNotification(CARE_PROVIDER_ID, ISSUED_ON_UNIT_ID, CERTIFICATE_ID,
ISSUING_DATE);
assertTrue(result);
assertFalse(result);
}

@Nested
Expand All @@ -145,7 +125,7 @@ void shallHandleMatchingValuesWithNullValuesForCareProviderIds() {
List.of(
IntegratedUnitNotificationConfig.builder()
.issuedOnUnit(List.of(ISSUED_ON_UNIT_ID))
.datetime(LocalDateTime.now().minusDays(1))
.datetime(LocalDateTime.now().plusDays(1))
.build()
))
.build();
Expand All @@ -157,14 +137,14 @@ void shallHandleMatchingValuesWithNullValuesForCareProviderIds() {
}

@Test
void shallHandleMatchingValuesWithNullValuesForUnitIds() {
void shallHandleMatchingValuesWithNullValuesForIssuedOnUnitId() {
final var regionNotificationConfig = RegionNotificationConfig.builder()
.region(REGION)
.configuration(
List.of(
IntegratedUnitNotificationConfig.builder()
.careProviders(List.of(NOT_MATCHING_ID))
.datetime(LocalDateTime.now().minusDays(1))
.careProviders(List.of(CARE_PROVIDER_ID))
.datetime(LocalDateTime.now().plusDays(1))
.build()
))
.build();
Expand All @@ -175,5 +155,4 @@ void shallHandleMatchingValuesWithNullValuesForUnitIds() {
assertTrue(result);
}
}

}

0 comments on commit 4eaa03d

Please sign in to comment.