Merge pull request #14712 from balasr21/master
BAEL-6572: Added mapping for id and test, based on review comment
This commit is contained in:
commit
05b86e4049
@ -15,6 +15,10 @@ public class LicenseDto {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LocalDateTime getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
@ -3,9 +3,7 @@ package com.baeldung.expression.model;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class License {
|
||||
|
||||
private UUID id;
|
||||
@ -18,4 +16,43 @@ public class License {
|
||||
|
||||
private boolean renewalRequired;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public OffsetDateTime getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(OffsetDateTime startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public OffsetDateTime getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(OffsetDateTime endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
public boolean isRenewalRequired() {
|
||||
return renewalRequired;
|
||||
}
|
||||
|
||||
public void setRenewalRequired(boolean renewalRequired) {
|
||||
this.renewalRequired = renewalRequired;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@ -61,4 +62,16 @@ class LicenseMapperUnitTest {
|
||||
assertThat(license.isRenewalRequired()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenLicenseDtoWithoutId_WhenMapperMethodIsInvoked_ThenLicenseShouldBePopulatedWithValidId() {
|
||||
LicenseDto licenseDto = new LicenseDto();
|
||||
UUID id = UUID.randomUUID();
|
||||
licenseDto.setId(id);
|
||||
licenseDto.setEndDate(LocalDateTime.now()
|
||||
.plusDays(10));
|
||||
License license = licenseMapper.toLicense(licenseDto);
|
||||
assertThat(license).isNotNull();
|
||||
assertThat(license.getId()).isSameAs(id);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user