From 6f70de47089975f476045d63e560e6ab718603b0 Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 20:01:51 +0700 Subject: [PATCH] Modify AdminSubscriptionTest and FactoryTest --- .../subscriptionadmin/model/AdminSubscription.java | 7 ++++--- .../factory/AdminSubscriptionFactoryTest.java | 2 +- .../subscriptionadmin/model/AdminSubscriptionTest.java | 5 ++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java index 6e971e8..07d25ec 100644 --- a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java +++ b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java @@ -53,11 +53,12 @@ public AdminSubscription(String subscriptionType, String subscriberName, String public void setUniqueCode(String subscriptionType) { String prefix = switch (subscriptionType) { - case "Monthly" -> "MTH-"; - case "Quarterly" -> "QTR-"; - case "Semi-Annual" -> "SAA-"; + case "MONTHLY" -> "MTH-"; + case "QUARTERLY" -> "QTR-"; + case "SEMI-ANNUAL" -> "SAA-"; default -> throw new IllegalArgumentException("Invalid type"); }; + String randomPart = UUID.randomUUID().toString(); randomPart = randomPart.replace("-", "").toUpperCase().substring(0, 16); this.uniqueCode = prefix + randomPart; diff --git a/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java b/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java index 4c4a2f7..61ae273 100644 --- a/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java +++ b/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java @@ -20,7 +20,7 @@ void testCreateAdminSubscriptionComplete() { AdminSubscriptionFactory adminSubscriptionFactory = new AdminSubscriptionFactory(); AdminSubscription adminSubscription = adminSubscriptionFactory.create( - "Monthly", + "MONTHLY", "Hwang Hyunjin", "12345678910", "12345678910" diff --git a/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java b/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java index ee6039e..561bae1 100644 --- a/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java +++ b/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java @@ -15,10 +15,9 @@ void setUp() { this.adminSubscription.setSubscriberName("Hwang Hyunjin"); this.adminSubscription.setSubscriberId("12345678910"); this.adminSubscription.setSubscriptionId("1234567890"); - this.adminSubscription.setSubscriptionType("Monthly"); - this.adminSubscription.setUniqueCode("MTH-1234567890"); + this.adminSubscription.setSubscriptionType("MONTHLY"); + this.adminSubscription.setUniqueCode("MONTHLY"); this.adminSubscription.setSubscriptionBoxId("12345678910"); - this.adminSubscription.setSubscriptionStatus(SubscriptionStatus.PENDING.getValue()); }