BAEL-6572: Modified test to validateId mapping
This commit is contained in:
parent
77d1de223b
commit
2a7f3fbc54
|
@ -4,7 +4,6 @@ import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.OffsetDateTime;
|
import java.time.OffsetDateTime;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.mapstruct.AfterMapping;
|
import org.mapstruct.AfterMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
@ -21,7 +20,6 @@ public interface LicenseMapper {
|
||||||
@Mapping(target = "endDate", ignore = true)
|
@Mapping(target = "endDate", ignore = true)
|
||||||
@Mapping(target = "active", constant = "true")
|
@Mapping(target = "active", constant = "true")
|
||||||
@Mapping(target = "renewalRequired", conditionExpression = "java(isEndDateInTwoWeeks(licenseDto))", source = ".")
|
@Mapping(target = "renewalRequired", conditionExpression = "java(isEndDateInTwoWeeks(licenseDto))", source = ".")
|
||||||
@Mapping(target = "id", expression = "java(setId())")
|
|
||||||
License toLicense(LicenseDto licenseDto);
|
License toLicense(LicenseDto licenseDto);
|
||||||
|
|
||||||
@AfterMapping
|
@AfterMapping
|
||||||
|
@ -42,8 +40,4 @@ public interface LicenseMapper {
|
||||||
.toDays() <= 14;
|
.toDays() <= 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
default UUID setId() {
|
|
||||||
return UUID.randomUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,13 +63,15 @@ class LicenseMapperUnitTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenLicenseDtoWithValidDetails_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithValidId() {
|
void givenLicenseDtoWithoutId_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithValidId() {
|
||||||
LicenseDto licenseDto = new LicenseDto();
|
LicenseDto licenseDto = new LicenseDto();
|
||||||
|
UUID id = UUID.randomUUID();
|
||||||
|
licenseDto.setId(id);
|
||||||
licenseDto.setEndDate(LocalDateTime.now()
|
licenseDto.setEndDate(LocalDateTime.now()
|
||||||
.plusDays(10));
|
.plusDays(10));
|
||||||
License license = licenseMapper.toLicense(licenseDto);
|
License license = licenseMapper.toLicense(licenseDto);
|
||||||
assertThat(license).isNotNull();
|
assertThat(license).isNotNull();
|
||||||
assertThat(license.getId()).isNotNull();
|
assertThat(license.getId()).isSameAs(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue