BAEL-6572: Modified test based on review comments

This commit is contained in:
balasr3 2023-08-22 20:59:17 +01:00
parent 31682be3e3
commit eb4a1d040e
1 changed files with 16 additions and 35 deletions

View File

@ -20,14 +20,10 @@ class LicenseMapperUnitTest {
License license = licenseMapper.toLicense(LicenseDto.builder()
.startDate(LocalDateTime.now())
.build());
assertThat(license).isNotNull()
.satisfies(l -> {
assertThat(l.getStartDate()
.toLocalDate()).isEqualTo(LocalDate.now());
assertThat(l.getEndDate()
.toLocalDate()).isEqualTo(LocalDate.now()
.plusYears(1));
});
assertThat(license).isNotNull();
assertThat(license.getEndDate()
.toLocalDate()).isEqualTo(LocalDate.now()
.plusYears(1));
}
@Test
@ -36,28 +32,21 @@ class LicenseMapperUnitTest {
.endDate(LocalDateTime.now()
.plusYears(2))
.build());
assertThat(license).isNotNull()
.satisfies(l -> {
assertThat(l.getStartDate()
.toLocalDate()).isEqualTo(LocalDate.now());
assertThat(l.getEndDate()
.toLocalDate()).isEqualTo(LocalDate.now()
.plusYears(2));
});
assertThat(license).isNotNull();
assertThat(license.getStartDate()
.toLocalDate()).isEqualTo(LocalDate.now());
}
@Test
void givenLicenseDtoWithoutEndDateAndWithoutStartDate_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithDefaultStartDateAndEndDate() {
License license = licenseMapper.toLicense(LicenseDto.builder()
.build());
assertThat(license).isNotNull()
.satisfies(l -> {
assertThat(l.getStartDate()
.toLocalDate()).isEqualTo(LocalDate.now());
assertThat(l.getEndDate()
.toLocalDate()).isEqualTo(LocalDate.now()
.plusYears(1));
});
assertThat(license).isNotNull();
assertThat(license.getStartDate()
.toLocalDate()).isEqualTo(LocalDate.now());
assertThat(license.getEndDate()
.toLocalDate()).isEqualTo(LocalDate.now()
.plusYears(1));
}
@Test
@ -77,21 +66,13 @@ class LicenseMapperUnitTest {
}
@Test
void givenLicenseDtoWithEndDateInTwoWeeks_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithReminderSetToTrue() {
void givenLicenseDtoWithEndDateInTwoWeeks_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithRenewalRequiredSetToTrue() {
License license = licenseMapper.toLicense(LicenseDto.builder()
.endDate(LocalDateTime.now()
.plusDays(10))
.build());
assertThat(license).isNotNull()
.satisfies(l -> {
assertThat(l.getStartDate()
.toLocalDate()).isEqualTo(LocalDate.now());
assertThat(l.getEndDate()
.toLocalDate()).isEqualTo(LocalDate.now()
.plusDays(10));
assertThat(l.isActive()).isTrue();
assertThat(l.isRenewalRequired()).isTrue();
});
assertThat(license).isNotNull();
assertThat(license.isRenewalRequired()).isTrue();
}
}