forked from pierront/mylibrary-template
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d5945b48b | |||
| da19dfcbac |
@@ -0,0 +1,4 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
|
||||||
|
|
||||||
|
public record PaymentMethodInfo(String paymentType, Object details) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
|
||||||
|
|
||||||
|
public enum PaymentType {
|
||||||
|
CB,
|
||||||
|
PAYPAL;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
|
||||||
|
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.PaymentMethod;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class SubscriptionDTO {
|
||||||
|
|
||||||
|
private UUID subscriptionId;
|
||||||
|
private UUID customerId;
|
||||||
|
private Integer subscriptionDurationDesired;
|
||||||
|
private PaymentMethod paymentMethod;
|
||||||
|
private LocalDate desiredStartDate;
|
||||||
|
private LocalDate startDate;
|
||||||
|
private LocalDate endDate;
|
||||||
|
private double monthlyAmount;
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
|
||||||
|
|
||||||
|
public enum SubscriptionDurationDesired {
|
||||||
|
THREE(3),
|
||||||
|
SIX(6),
|
||||||
|
TWELVE(12);
|
||||||
|
|
||||||
|
private final Integer value;
|
||||||
|
|
||||||
|
SubscriptionDurationDesired(Integer value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public record SubscriptionInfo(Integer subscriptionDurationDesired, LocalDate desiredStartDate) {
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.converter;
|
||||||
|
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.customer.CustomerDTO;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.PaymentMethodInfo;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.SubscriptionDTO;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.SubscriptionInfo;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.PaymentMethod;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.Subscription;
|
||||||
|
|
||||||
|
public class SubscriptionConverter {
|
||||||
|
|
||||||
|
private SubscriptionConverter(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Subscription toDomain(SubscriptionInfo newSubscription, PaymentMethodInfo newPaymentMethod) {
|
||||||
|
PaymentMethod paymentMethod = PaymentMethod.builder()
|
||||||
|
.paymentType(newPaymentMethod.paymentType())
|
||||||
|
.details(newPaymentMethod.details())
|
||||||
|
.build();
|
||||||
|
return Subscription.builder()
|
||||||
|
.subscriptionDurationDesired(newSubscription.subscriptionDurationDesired())
|
||||||
|
.paymentMethod(paymentMethod)
|
||||||
|
.desiredStartDate(newSubscription.desiredStartDate())
|
||||||
|
.startDate(newSubscription.desiredStartDate())
|
||||||
|
.endDate(newSubscription.desiredStartDate().plusMonths(newSubscription.subscriptionDurationDesired()))
|
||||||
|
.monthlyAmount(0)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SubscriptionDTO toDTO(Subscription subscription) {
|
||||||
|
return SubscriptionDTO.builder()
|
||||||
|
.subscriptionId(subscription.getSubscriptionId())
|
||||||
|
.customerId(subscription.getCustomerId())
|
||||||
|
.subscriptionDurationDesired(subscription.getSubscriptionDurationDesired())
|
||||||
|
.paymentMethod(subscription.getPaymentMethod())
|
||||||
|
.desiredStartDate(subscription.getDesiredStartDate())
|
||||||
|
.startDate(subscription.getStartDate())
|
||||||
|
.endDate(subscription.getEndDate())
|
||||||
|
.monthlyAmount(subscription.getMonthlyAmount())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
+12
@@ -0,0 +1,12 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class PaymentMethod {
|
||||||
|
|
||||||
|
private String paymentType;
|
||||||
|
private Object details;
|
||||||
|
}
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class Subscription {
|
||||||
|
|
||||||
|
private UUID subscriptionId;
|
||||||
|
private UUID customerId;
|
||||||
|
private Integer subscriptionDurationDesired;
|
||||||
|
private PaymentMethod paymentMethod;
|
||||||
|
private LocalDate desiredStartDate;
|
||||||
|
private LocalDate startDate;
|
||||||
|
private LocalDate endDate;
|
||||||
|
private double monthlyAmount;
|
||||||
|
|
||||||
|
public void setRandomSubscriptionUUID() {
|
||||||
|
|
||||||
|
this.subscriptionId = UUID.randomUUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRandomCustomerUUID() {
|
||||||
|
|
||||||
|
this.customerId = UUID.randomUUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartDate(){
|
||||||
|
this.startDate = this.desiredStartDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndDate(){
|
||||||
|
this.endDate = this.desiredStartDate.plusMonths(this.subscriptionDurationDesired);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDateSubscription(){
|
||||||
|
setStartDate();
|
||||||
|
setEndDate();
|
||||||
|
}
|
||||||
|
}
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.converter;
|
||||||
|
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.*;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.PaymentMethod;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity.Subscription;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Nested;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
|
||||||
|
public class SubscriptionConverterTest {
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@DisplayName("toDomain() method tests")
|
||||||
|
class ToDomainTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Should convert SubscriptionInfo to Subscription domain object with monthly amount initialized to 0")
|
||||||
|
void shouldConvertSubscriptionInfoToDomain() {
|
||||||
|
// Given
|
||||||
|
PaymentMethodInfo paymentMethodInfo = new PaymentMethodInfo(PaymentType.CB.name(), "Maxime Lebreton");
|
||||||
|
LocalDate desiredStartDate = LocalDate.of(2026, 3, 24);
|
||||||
|
SubscriptionInfo subscriptionInfo = new SubscriptionInfo(SubscriptionDurationDesired.THREE.getValue(), desiredStartDate);
|
||||||
|
LocalDate estimateEndDate = LocalDate.of(2026, 6, 24);
|
||||||
|
|
||||||
|
// When
|
||||||
|
Subscription result = SubscriptionConverter.toDomain(subscriptionInfo, paymentMethodInfo);
|
||||||
|
|
||||||
|
// Then
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals(subscriptionInfo.subscriptionDurationDesired(), result.getSubscriptionDurationDesired());
|
||||||
|
assertEquals(paymentMethodInfo.paymentType(), result.getPaymentMethod().getPaymentType());
|
||||||
|
assertEquals(paymentMethodInfo.details(), result.getPaymentMethod().getDetails());
|
||||||
|
assertEquals(subscriptionInfo.desiredStartDate(), result.getDesiredStartDate());
|
||||||
|
assertEquals(subscriptionInfo.desiredStartDate(), result.getStartDate());
|
||||||
|
assertEquals(estimateEndDate, result.getEndDate());
|
||||||
|
assertEquals(0, result.getMonthlyAmount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@DisplayName("toDTO() method tests")
|
||||||
|
class ToDTOTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Should convert Subscription domain object to SubscriptionDTO with all fields mapped correctly")
|
||||||
|
void shouldConvertSubscriptionToDTO() {
|
||||||
|
PaymentMethod paymentMethod = PaymentMethod.builder()
|
||||||
|
.paymentType(PaymentType.CB.name())
|
||||||
|
.details("Maxime Lebreton")
|
||||||
|
.build();
|
||||||
|
LocalDate desiredStartDate = LocalDate.of(2026, 3, 24);
|
||||||
|
LocalDate estimateEndDate = LocalDate.of(2026, 6, 24);
|
||||||
|
Subscription subscription = Subscription.builder()
|
||||||
|
.subscriptionId(UUID.randomUUID())
|
||||||
|
.customerId(UUID.randomUUID())
|
||||||
|
.subscriptionDurationDesired(SubscriptionDurationDesired.THREE.getValue())
|
||||||
|
.paymentMethod(paymentMethod)
|
||||||
|
.desiredStartDate(desiredStartDate)
|
||||||
|
.startDate(desiredStartDate)
|
||||||
|
.endDate(estimateEndDate)
|
||||||
|
.monthlyAmount(12.03)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SubscriptionDTO result = SubscriptionConverter.toDTO(subscription);
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
assertEquals(subscription.getSubscriptionId(), result.getSubscriptionId());
|
||||||
|
assertEquals(subscription.getCustomerId(), result.getCustomerId());
|
||||||
|
assertEquals(subscription.getSubscriptionDurationDesired(), result.getSubscriptionDurationDesired());
|
||||||
|
assertEquals(subscription.getPaymentMethod().getPaymentType(), result.getPaymentMethod().getPaymentType());
|
||||||
|
assertEquals(subscription.getPaymentMethod().getDetails(), result.getPaymentMethod().getDetails());
|
||||||
|
assertEquals(subscription.getDesiredStartDate(), result.getDesiredStartDate());
|
||||||
|
assertEquals(subscription.getStartDate(), result.getStartDate());
|
||||||
|
assertEquals(subscription.getEndDate(), result.getEndDate());
|
||||||
|
assertEquals(12.03, result.getMonthlyAmount());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Should handle null values properly when converting between objects")
|
||||||
|
void shouldHandleNullValuesGracefully() {
|
||||||
|
PaymentMethod paymentMethod = PaymentMethod.builder()
|
||||||
|
.paymentType(PaymentType.CB.name())
|
||||||
|
.details(null)
|
||||||
|
.build();
|
||||||
|
LocalDate desiredStartDate = LocalDate.of(2026, 3, 24);
|
||||||
|
LocalDate estimateEndDate = LocalDate.of(2026, 6, 24);
|
||||||
|
Subscription subscription = Subscription.builder()
|
||||||
|
.subscriptionId(UUID.randomUUID())
|
||||||
|
.customerId(UUID.randomUUID())
|
||||||
|
.subscriptionDurationDesired(SubscriptionDurationDesired.THREE.getValue())
|
||||||
|
.paymentMethod(paymentMethod)
|
||||||
|
.desiredStartDate(desiredStartDate)
|
||||||
|
.startDate(desiredStartDate)
|
||||||
|
.endDate(estimateEndDate)
|
||||||
|
.monthlyAmount(12.03)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SubscriptionDTO result = SubscriptionConverter.toDTO(subscription);
|
||||||
|
|
||||||
|
assertNotNull(result);
|
||||||
|
assertNull(result.getPaymentMethod().getDetails());
|
||||||
|
assertEquals(desiredStartDate, result.getDesiredStartDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Should preserve empty string values during conversion")
|
||||||
|
void shouldPreserveEmptyStrings() {
|
||||||
|
PaymentMethodInfo paymentMethodInfo = new PaymentMethodInfo(PaymentType.CB.name(), "");
|
||||||
|
LocalDate desiredStartDate = LocalDate.of(2026, 3, 24);
|
||||||
|
SubscriptionInfo subscriptionInfo = new SubscriptionInfo(SubscriptionDurationDesired.THREE.getValue(), desiredStartDate);
|
||||||
|
|
||||||
|
Subscription domainResult = SubscriptionConverter.toDomain(subscriptionInfo, paymentMethodInfo);
|
||||||
|
SubscriptionDTO dtoResult = SubscriptionConverter.toDTO(domainResult);
|
||||||
|
|
||||||
|
assertEquals("", dtoResult.getPaymentMethod().getDetails());
|
||||||
|
}
|
||||||
|
}
|
||||||
+58
@@ -0,0 +1,58 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity;
|
||||||
|
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.PaymentType;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class PaymentMethodTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Builder should create a valid PaymentMethod instance")
|
||||||
|
void testPaymentMethodBuilder() {
|
||||||
|
String paymentType = PaymentType.CB.name();
|
||||||
|
Object details = new Object();
|
||||||
|
details = "Maxime Lebreton";
|
||||||
|
|
||||||
|
PaymentMethod paymentMethod = PaymentMethod.builder()
|
||||||
|
.paymentType(paymentType)
|
||||||
|
.details(details)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(paymentType, paymentMethod.getPaymentType());
|
||||||
|
assertEquals(details, paymentMethod.getDetails());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Builder should create a valid PaymentMethod instance with details as an Integer")
|
||||||
|
void testPaymentMethodDetailsInteger() {
|
||||||
|
String paymentType = PaymentType.CB.name();
|
||||||
|
Object details = new Object();
|
||||||
|
details = 10;
|
||||||
|
|
||||||
|
PaymentMethod paymentMethod = PaymentMethod.builder()
|
||||||
|
.paymentType(paymentType)
|
||||||
|
.details(details)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(paymentType, paymentMethod.getPaymentType());
|
||||||
|
assertEquals(details, paymentMethod.getDetails());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Builder should create a valid PaymentMethod instance with details as an boolean")
|
||||||
|
void testPaymentMethodDetailsBoolean() {
|
||||||
|
String paymentType = PaymentType.CB.name();
|
||||||
|
Object details = new Object();
|
||||||
|
details = true;
|
||||||
|
|
||||||
|
PaymentMethod paymentMethod = PaymentMethod.builder()
|
||||||
|
.paymentType(paymentType)
|
||||||
|
.details(details)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(paymentType, paymentMethod.getPaymentType());
|
||||||
|
assertEquals(details, paymentMethod.getDetails());
|
||||||
|
}
|
||||||
|
}
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
package fr.iut_fbleau.but3.dev62.mylibrary.subscription.entity;
|
||||||
|
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.PaymentType;
|
||||||
|
import fr.iut_fbleau.but3.dev62.mylibrary.subscription.SubscriptionDurationDesired;
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
public class SubscriptionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Builder should create a valid Subscription instance")
|
||||||
|
void testSubscriptionBuilder() {
|
||||||
|
UUID subscriptionId = UUID.randomUUID();
|
||||||
|
UUID customerId = UUID.randomUUID();
|
||||||
|
Integer subscriptionDurationDesired = SubscriptionDurationDesired.THREE.getValue();
|
||||||
|
String paymentType = PaymentType.CB.name();
|
||||||
|
Object details = new Object();
|
||||||
|
details = "Maxime Lebreton";
|
||||||
|
LocalDate desiredStartDate = LocalDate.of(2026, 3, 24);
|
||||||
|
LocalDate startDate = desiredStartDate;
|
||||||
|
LocalDate estimateEndDate = LocalDate.of(2026, 6, 24);
|
||||||
|
double monthlyAmount = 17.99;
|
||||||
|
|
||||||
|
PaymentMethod paymentMethod = PaymentMethod.builder()
|
||||||
|
.paymentType(paymentType)
|
||||||
|
.details(details)
|
||||||
|
.build();
|
||||||
|
Subscription subscription = Subscription.builder()
|
||||||
|
.subscriptionId(subscriptionId)
|
||||||
|
.customerId(customerId)
|
||||||
|
.subscriptionDurationDesired(subscriptionDurationDesired)
|
||||||
|
.paymentMethod(paymentMethod)
|
||||||
|
.desiredStartDate(desiredStartDate)
|
||||||
|
.startDate(startDate)
|
||||||
|
.endDate(estimateEndDate)
|
||||||
|
.monthlyAmount(monthlyAmount)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(subscriptionId, subscription.getSubscriptionId());
|
||||||
|
assertEquals(customerId, subscription.getCustomerId());
|
||||||
|
assertEquals(subscriptionDurationDesired, subscription.getSubscriptionDurationDesired());
|
||||||
|
assertEquals(paymentType, paymentMethod.getPaymentType());
|
||||||
|
assertEquals(details, paymentMethod.getDetails());
|
||||||
|
assertEquals(desiredStartDate, subscription.getDesiredStartDate());
|
||||||
|
assertEquals(startDate, subscription.getStartDate());
|
||||||
|
assertEquals(estimateEndDate, subscription.getEndDate());
|
||||||
|
assertEquals(monthlyAmount, subscription.getMonthlyAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("setRandomSubscriptionUUID should change the ID to a new random UUID")
|
||||||
|
void testSetRandomSubscriptionUUID() {
|
||||||
|
Subscription subscription = Subscription.builder().build();
|
||||||
|
UUID originalId = subscription.getSubscriptionId();
|
||||||
|
|
||||||
|
subscription.setRandomSubscriptionUUID();
|
||||||
|
|
||||||
|
assertNotNull(subscription.getSubscriptionId());
|
||||||
|
assertNotEquals(originalId, subscription.getSubscriptionId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("setRandomCustomerUUID should change the ID to a new random UUID")
|
||||||
|
void testSetRandomCustomerUUID() {
|
||||||
|
Subscription subscription = Subscription.builder().build();
|
||||||
|
UUID originalId = subscription.getCustomerId();
|
||||||
|
|
||||||
|
subscription.setRandomCustomerUUID();
|
||||||
|
|
||||||
|
assertNotNull(subscription.getCustomerId());
|
||||||
|
assertNotEquals(originalId, subscription.getCustomerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("setStartDate should instantiate StartDate as the same value as the variable desiredStartDate")
|
||||||
|
void testSetStartDate() {
|
||||||
|
LocalDate desiredStartDate = LocalDate.of(2026, 3, 24);
|
||||||
|
Subscription subscription = Subscription.builder()
|
||||||
|
.desiredStartDate(desiredStartDate)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
subscription.setStartDate();
|
||||||
|
|
||||||
|
assertNotNull(subscription.getStartDate());
|
||||||
|
assertEquals(desiredStartDate, subscription.getStartDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("setEndDate should instantiate EndDate as the same value as the variable desiredStartDate + subscriptionDurationDesired")
|
||||||
|
void testSetEndDate() {
|
||||||
|
LocalDate desiredStartDate = LocalDate.of(2026, 3, 24);
|
||||||
|
LocalDate estimateEndDate = LocalDate.of(2026, 6, 24);
|
||||||
|
Subscription subscription = Subscription.builder()
|
||||||
|
.subscriptionDurationDesired(SubscriptionDurationDesired.THREE.getValue())
|
||||||
|
.desiredStartDate(desiredStartDate)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
subscription.setEndDate();
|
||||||
|
|
||||||
|
assertNotNull(subscription.getEndDate());
|
||||||
|
assertEquals(estimateEndDate, subscription.getEndDate());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("setDateSubscription should instantiate StartDate and EndDate ")
|
||||||
|
void testSetDateSubscription() {
|
||||||
|
LocalDate desiredStartDate = LocalDate.of(2026, 3, 24);
|
||||||
|
LocalDate estimateEndDate = LocalDate.of(2026, 6, 24);
|
||||||
|
Subscription subscription = Subscription.builder()
|
||||||
|
.subscriptionDurationDesired(SubscriptionDurationDesired.THREE.getValue())
|
||||||
|
.desiredStartDate(desiredStartDate)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
subscription.setDateSubscription();
|
||||||
|
|
||||||
|
assertNotNull(subscription.getEndDate());
|
||||||
|
assertEquals(estimateEndDate, subscription.getEndDate());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user