From fde8fd2137f11e0f6d8966b918c8c4a0008308a0 Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 24 Apr 2024 20:57:00 +0700 Subject: [PATCH 1/9] Model TDD and Refactor Skeleton --- .../enums/SubscriptionStatus.java | 25 ++++++ .../model/AdminSubscription.java | 43 ++++++++-- .../model/AdminSubscriptionTest.java | 47 +++++++--- .../repository/AdminRepositoryTest.java | 85 ------------------- 4 files changed, 97 insertions(+), 103 deletions(-) create mode 100644 src/main/java/snackscription/subscriptionadmin/enums/SubscriptionStatus.java delete mode 100644 src/test/java/snackscription/subscriptionadmin/repository/AdminRepositoryTest.java diff --git a/src/main/java/snackscription/subscriptionadmin/enums/SubscriptionStatus.java b/src/main/java/snackscription/subscriptionadmin/enums/SubscriptionStatus.java new file mode 100644 index 0000000..f7c1717 --- /dev/null +++ b/src/main/java/snackscription/subscriptionadmin/enums/SubscriptionStatus.java @@ -0,0 +1,25 @@ +package snackscription.subscriptionadmin.enums; + +import lombok.Getter; + +@Getter +public enum SubscriptionStatus { + PENDING("PENDING"), + REJECTED("REJECTED"), + SUBSCRIBED("SUBSCRIBED"); + + private final String value; + + private SubscriptionStatus(String value) { + this.value = value; + } + + public static boolean contains(String param) { + for (SubscriptionStatus subscriptionStatus : SubscriptionStatus.values()) { + if (subscriptionStatus.name().equals(param)) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java index af30a4a..9c3352a 100644 --- a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java +++ b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java @@ -2,12 +2,45 @@ import lombok.Getter; import lombok.Setter; +import snackscription.subscriptionadmin.enums.SubscriptionStatus; + +import java.time.LocalDateTime; +import java.util.UUID; @Getter @Setter public class AdminSubscription { - private String subscriberName; - private int subscriberId; - private String subscriptionUniqueCode; - private String subscriptionType; - private String subscribtionStatus; + String subscriberName; + String subscriberId; + String uniqueCode; + String subscriptionId; + String subscriptionBoxId; + String subscriptionStatus; + + public AdminSubscription() { + this.subscriptionId = UUID.randomUUID().toString(); + } + + public AdminSubscription(String subscriberName, String subscriberId, String uniqueCode, String subscriptionBoxId, String subscriptionStatus) { + this.subscriptionId = UUID.randomUUID().toString(); + + this.subscriberName = subscriberName; + this.subscriberId = subscriberId; + + if (!uniqueCode.startsWith("MTH-") && !uniqueCode.startsWith("QTR-") && !uniqueCode.startsWith("SAA-")) { + throw new IllegalArgumentException("Invalid unique code"); + } + + this.uniqueCode = uniqueCode; + this.subscriptionBoxId = subscriptionBoxId; + this.setSubscriptionStatus(subscriptionStatus); + } + + public void setSubscriptionStatus(String subscriptionStatus) { + if (SubscriptionStatus.contains(subscriptionStatus)) { + this.subscriptionStatus = subscriptionStatus; + } else { + throw new IllegalArgumentException("Invalid subscription status"); + } + } + } \ No newline at end of file diff --git a/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java b/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java index 985a552..7ad5cca 100644 --- a/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java +++ b/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java @@ -2,6 +2,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import snackscription.subscriptionadmin.enums.SubscriptionStatus; import static org.junit.jupiter.api.Assertions.*; @@ -11,35 +12,55 @@ class AdminSubscriptionTest { @BeforeEach void setUp() { this.adminSubscription = new AdminSubscription(); - this.adminSubscription.setSubscriberId(1); this.adminSubscription.setSubscriberName("Hwang Hyunjin"); - this.adminSubscription.setSubscriptionType("Monthly"); - this.adminSubscription.setSubscriptionUniqueCode("123456"); - this.adminSubscription.setSubscribtionStatus("Pending"); + this.adminSubscription.setSubscriberId("12345678910"); + this.adminSubscription.setSubscriptionId("12345678910"); + this.adminSubscription.setUniqueCode("MTH-12345678910"); + this.adminSubscription.setSubscriptionBoxId("12345678910"); + + this.adminSubscription.setSubscriptionStatus(SubscriptionStatus.PENDING.getValue()); + } + + @Test + void testGetSubscriberName() { + assertEquals("Hwang Hyunjin", this.adminSubscription.getSubscriberName()); } @Test void testGetSubscriberId() { - assertEquals(1, this.adminSubscription.getSubscriberId()); + assertEquals("12345678910", this.adminSubscription.getSubscriberId()); } @Test - void testGetSubscriberName() { - assertEquals("Hwang Hyunjin", this.adminSubscription.getSubscriberName()); + void testGetSubscriptionId() { + assertEquals("12345678910", this.adminSubscription.getSubscriptionId()); + } + + @Test + void testGetUniqueCode() { + assertEquals("MTH-12345678910", this.adminSubscription.getUniqueCode()); + } + + @Test + void testGetSubscriptionBoxId() { + assertEquals("12345678910", this.adminSubscription.getSubscriptionBoxId()); } @Test - void testGetSubscriptionType() { - assertEquals("Monthly", this.adminSubscription.getSubscriptionType()); + void testGetSubscriptionStatus() { + assertEquals("PENDING", this.adminSubscription.getSubscriptionStatus()); } @Test - void testGetSubscriptionUniqueCode() { - assertEquals("123456", this.adminSubscription.getSubscriptionUniqueCode()); + void testSetStatus() { + this.adminSubscription.setSubscriptionStatus(SubscriptionStatus.SUBSCRIBED.getValue()); + assertEquals("SUBSCRIBED", this.adminSubscription.getSubscriptionStatus()); } @Test - void testGetSubscribtionStatus() { - assertEquals("Pending", this.adminSubscription.getSubscribtionStatus()); + void testSetInvalidStatus() { + assertThrows(IllegalArgumentException.class, () -> { + this.adminSubscription.setSubscriptionStatus("INVALID"); + }); } } diff --git a/src/test/java/snackscription/subscriptionadmin/repository/AdminRepositoryTest.java b/src/test/java/snackscription/subscriptionadmin/repository/AdminRepositoryTest.java deleted file mode 100644 index b8b84b7..0000000 --- a/src/test/java/snackscription/subscriptionadmin/repository/AdminRepositoryTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package snackscription.subscriptionadmin.repository; - -import snackscription.subscriptionadmin.model.AdminSubscription; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.Iterator; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class AdminRepositoryTest { - @InjectMocks - AdminRepository adminRepository; - - @BeforeEach - void setUp() {} - - @Test - void testCreateAndFind() { - AdminSubscription adminSubscription = new AdminSubscription(); - adminSubscription.setSubscriberId(1); - adminSubscription.setSubscriberName("Hwang Hyunjin"); - adminSubscription.setSubscriptionType("Monthly"); - adminSubscription.setSubscriptionUniqueCode("123456"); - adminSubscription.setSubscribtionStatus("Pending"); - - adminRepository.create(adminSubscription); - - Iterator subscriptionIterator = adminRepository.findAll(); - assertTrue(subscriptionIterator.hasNext()); - - AdminSubscription foundSubscription = subscriptionIterator.next(); - assertEquals(adminSubscription.getSubscriberId(), foundSubscription.getSubscriberId()); - assertEquals(adminSubscription.getSubscriberName(), foundSubscription.getSubscriberName()); - assertEquals(adminSubscription.getSubscriptionType(), foundSubscription.getSubscriptionType()); - assertEquals(adminSubscription.getSubscriptionUniqueCode(), foundSubscription.getSubscriptionUniqueCode()); - assertEquals(adminSubscription.getSubscribtionStatus(), foundSubscription.getSubscribtionStatus()); - } - - @Test - void testFindEmpty() { - Iterator subscriptionIterator = adminRepository.findAll(); - assertFalse(subscriptionIterator.hasNext()); - } - - @Test - void testFindMultiple() { - AdminSubscription adminSubscription1 = new AdminSubscription(); - adminSubscription1.setSubscriberId(1); - adminSubscription1.setSubscriberName("Hwang Hyunjin"); - adminSubscription1.setSubscriptionType("Monthly"); - adminSubscription1.setSubscriptionUniqueCode("123456"); - adminSubscription1.setSubscribtionStatus("Pending"); - - AdminSubscription adminSubscription2 = new AdminSubscription(); - adminSubscription2.setSubscriberId(2); - adminSubscription2.setSubscriberName("Bang Chan"); - adminSubscription2.setSubscriptionType("Weekly"); - adminSubscription2.setSubscriptionUniqueCode("654321"); - adminSubscription2.setSubscribtionStatus("Active"); - - adminRepository.create(adminSubscription1); - adminRepository.create(adminSubscription2); - - Iterator subscriptionIterator = adminRepository.findAll(); - assertTrue(subscriptionIterator.hasNext()); - AdminSubscription foundSubscription = subscriptionIterator.next(); - assertEquals(adminSubscription1.getSubscriberId(), foundSubscription.getSubscriberId()); - assertEquals(adminSubscription1.getSubscriberName(), foundSubscription.getSubscriberName()); - assertEquals(adminSubscription1.getSubscriptionType(), foundSubscription.getSubscriptionType()); - assertEquals(adminSubscription1.getSubscriptionUniqueCode(), foundSubscription.getSubscriptionUniqueCode()); - assertEquals(adminSubscription1.getSubscribtionStatus(), foundSubscription.getSubscribtionStatus()); - foundSubscription = subscriptionIterator.next(); - assertEquals(adminSubscription2.getSubscriberId(), foundSubscription.getSubscriberId()); - assertEquals(adminSubscription2.getSubscriberName(), foundSubscription.getSubscriberName()); - assertEquals(adminSubscription2.getSubscriptionType(), foundSubscription.getSubscriptionType()); - assertEquals(adminSubscription2.getSubscriptionUniqueCode(), foundSubscription.getSubscriptionUniqueCode()); - assertEquals(adminSubscription2.getSubscribtionStatus(), foundSubscription.getSubscribtionStatus()); - assertFalse(subscriptionIterator.hasNext()); - } -} From 6df70f9376026a9d783350484e06aeee0851ed2f Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 10:51:28 +0700 Subject: [PATCH 2/9] Model TDD and Refactor Skeleton --- .../subscriptionadmin/model/AdminSubscription.java | 1 + .../subscriptionadmin/model/AdminSubscriptionTest.java | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java index 9c3352a..7645040 100644 --- a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java +++ b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java @@ -32,6 +32,7 @@ public AdminSubscription(String subscriberName, String subscriberId, String uniq this.uniqueCode = uniqueCode; this.subscriptionBoxId = subscriptionBoxId; + this.getSubscriptionStatus(); this.setSubscriptionStatus(subscriptionStatus); } diff --git a/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java b/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java index 7ad5cca..09c8abb 100644 --- a/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java +++ b/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java @@ -48,19 +48,20 @@ void testGetSubscriptionBoxId() { @Test void testGetSubscriptionStatus() { - assertEquals("PENDING", this.adminSubscription.getSubscriptionStatus()); + assertEquals(SubscriptionStatus.PENDING.getValue(), adminSubscription.getSubscriptionStatus()); } @Test - void testSetStatus() { + void testSetSubscriptionStatus() { this.adminSubscription.setSubscriptionStatus(SubscriptionStatus.SUBSCRIBED.getValue()); - assertEquals("SUBSCRIBED", this.adminSubscription.getSubscriptionStatus()); + assertEquals(SubscriptionStatus.SUBSCRIBED.getValue(), this.adminSubscription.getSubscriptionStatus()); } @Test - void testSetInvalidStatus() { + void testSetIvalidSubscriptionStatus() { assertThrows(IllegalArgumentException.class, () -> { this.adminSubscription.setSubscriptionStatus("INVALID"); }); } + } From 7094b36fbe02508312e757cc9664c1b1ebdfa39a Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 10:57:32 +0700 Subject: [PATCH 3/9] Model TDD and Refactor Skeleton --- .../subscriptionadmin/model/AdminSubscriptionTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java b/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java index 09c8abb..fdc7dba 100644 --- a/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java +++ b/src/test/java/snackscription/subscriptionadmin/model/AdminSubscriptionTest.java @@ -58,7 +58,7 @@ void testSetSubscriptionStatus() { } @Test - void testSetIvalidSubscriptionStatus() { + void testSetInvalidSubscriptionStatus() { assertThrows(IllegalArgumentException.class, () -> { this.adminSubscription.setSubscriptionStatus("INVALID"); }); From 788f1d6d3555688e836c6c32b5e97549bf6bde1f Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 11:05:51 +0700 Subject: [PATCH 4/9] Add Factory Skeleton --- .../factory/AdminRepositoryFactory.java | 10 ++++++++++ .../factory/AdminSubscriptionFactory.java | 10 ++++++++++ .../subscriptionadmin/factory/Factory.java | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java create mode 100644 src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java create mode 100644 src/main/java/snackscription/subscriptionadmin/factory/Factory.java diff --git a/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java b/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java new file mode 100644 index 0000000..62bcd3e --- /dev/null +++ b/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java @@ -0,0 +1,10 @@ +package snackscription.subscriptionadmin.factory; + +import snackscription.subscriptionadmin.repository.AdminRepository; + +public class AdminRepositoryFactory implements Factory { + @Override + public AdminRepository create() { + return null; + } +} diff --git a/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java b/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java new file mode 100644 index 0000000..28ca22d --- /dev/null +++ b/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java @@ -0,0 +1,10 @@ +package snackscription.subscriptionadmin.factory; + +import snackscription.subscriptionadmin.model.AdminSubscription; + +public class AdminSubscriptionFactory implements Factory { + @Override + public AdminSubscription create() { + return null; + } +} \ No newline at end of file diff --git a/src/main/java/snackscription/subscriptionadmin/factory/Factory.java b/src/main/java/snackscription/subscriptionadmin/factory/Factory.java new file mode 100644 index 0000000..3381165 --- /dev/null +++ b/src/main/java/snackscription/subscriptionadmin/factory/Factory.java @@ -0,0 +1,5 @@ +package snackscription.subscriptionadmin.factory; + +public interface Factory { + F create(); +} From 92fa99e51496ad25d48c2d0998b2b82041602cdf Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 11:10:50 +0700 Subject: [PATCH 5/9] Edit Factory Skeleton --- .../subscriptionadmin/factory/AdminRepositoryFactory.java | 4 ++++ .../subscriptionadmin/factory/AdminSubscriptionFactory.java | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java b/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java index 62bcd3e..0c3a28f 100644 --- a/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java +++ b/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java @@ -7,4 +7,8 @@ public class AdminRepositoryFactory implements Factory { public AdminRepository create() { return null; } + + public AdminRepository create(String subscriberName, String subscriberId, String uniqueCode, String subscriptionBoxId, String subscriptionStatus) { + return null; + } } diff --git a/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java b/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java index 28ca22d..d04c699 100644 --- a/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java +++ b/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java @@ -7,4 +7,8 @@ public class AdminSubscriptionFactory implements Factory { public AdminSubscription create() { return null; } + + public AdminSubscription create(String subscriberName, String subscriberId, String uniqueCode, String subscriptionBoxId, String subscriptionStatus) { + return null; + } } \ No newline at end of file From 2e9093885ff7cad46e7294d87b3f59dcaf1f1162 Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 11:24:52 +0700 Subject: [PATCH 6/9] Add Tests for Factory --- .../model/AdminSubscription.java | 2 +- .../factory/AdminSubscriptionFactoryTest.java | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java diff --git a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java index 7645040..46b13a4 100644 --- a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java +++ b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java @@ -1,10 +1,10 @@ package snackscription.subscriptionadmin.model; +import lombok.Builder; import lombok.Getter; import lombok.Setter; import snackscription.subscriptionadmin.enums.SubscriptionStatus; -import java.time.LocalDateTime; import java.util.UUID; @Getter @Setter diff --git a/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java b/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java new file mode 100644 index 0000000..b3f3421 --- /dev/null +++ b/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java @@ -0,0 +1,37 @@ +package snackscription.subscriptionadmin.factory; + +import org.junit.jupiter.api.Test; +import snackscription.subscriptionadmin.enums.SubscriptionStatus; +import snackscription.subscriptionadmin.model.AdminSubscription; + +import static org.junit.jupiter.api.Assertions.*; + +public class AdminSubscriptionFactoryTest { + @Test + void testCreateAdminSubscription() { + AdminSubscriptionFactory adminSubscriptionFactory = new AdminSubscriptionFactory(); + AdminSubscription adminSubscription = adminSubscriptionFactory.create(); + + assertNotNull(adminSubscription); + } + + @Test + void testCreateAdminSubscriptionComplete() { + AdminSubscriptionFactory adminSubscriptionFactory = new AdminSubscriptionFactory(); + + AdminSubscription adminSubscription = adminSubscriptionFactory.create( + "Hwang Hyunjin", + "12345678910", + "MTH-12345678910", + "12345678910", + SubscriptionStatus.PENDING.getValue() + ); + + assertNotNull(adminSubscription.getSubscriptionId()); + assertEquals("Hwang Hyunjin", adminSubscription.getSubscriberName()); + assertEquals("12345678910", adminSubscription.getSubscriberId()); + assertEquals("MTH-12345678910", adminSubscription.getUniqueCode()); + assertEquals("12345678910", adminSubscription.getSubscriptionBoxId()); + assertEquals(SubscriptionStatus.PENDING.getValue(), adminSubscription.getSubscriptionStatus()); + } +} From 266e8f3892c6fea7329c925606b1c432060e8630 Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 11:32:46 +0700 Subject: [PATCH 7/9] Add Tests for Factory --- .../factory/AdminRepositoryFactory.java | 4 ++-- .../factory/AdminSubscriptionFactory.java | 4 ++-- .../factory/AdminRepositoryFactoryTest.java | 17 +++++++++++++++++ .../factory/AdminSubscriptionFactoryTest.java | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 src/test/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactoryTest.java diff --git a/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java b/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java index 0c3a28f..2b86322 100644 --- a/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java +++ b/src/main/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactory.java @@ -5,10 +5,10 @@ public class AdminRepositoryFactory implements Factory { @Override public AdminRepository create() { - return null; + return new AdminRepository(); } public AdminRepository create(String subscriberName, String subscriberId, String uniqueCode, String subscriptionBoxId, String subscriptionStatus) { - return null; + throw new UnsupportedOperationException(); } } diff --git a/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java b/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java index d04c699..25f3142 100644 --- a/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java +++ b/src/main/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactory.java @@ -5,10 +5,10 @@ public class AdminSubscriptionFactory implements Factory { @Override public AdminSubscription create() { - return null; + return new AdminSubscription(); } public AdminSubscription create(String subscriberName, String subscriberId, String uniqueCode, String subscriptionBoxId, String subscriptionStatus) { - return null; + return new AdminSubscription(subscriberName, subscriberId, uniqueCode, subscriptionBoxId, subscriptionStatus); } } \ No newline at end of file diff --git a/src/test/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactoryTest.java b/src/test/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactoryTest.java new file mode 100644 index 0000000..cf9802b --- /dev/null +++ b/src/test/java/snackscription/subscriptionadmin/factory/AdminRepositoryFactoryTest.java @@ -0,0 +1,17 @@ +package snackscription.subscriptionadmin.factory; + +import org.junit.jupiter.api.Test; +import snackscription.subscriptionadmin.repository.AdminRepository; + +import static org.junit.jupiter.api.Assertions.*; + +public class AdminRepositoryFactoryTest { + @Test + void testCreateAdminRepository() { + AdminRepositoryFactory adminRepositoryFactory = new AdminRepositoryFactory(); + AdminRepository adminRepository = adminRepositoryFactory.create(); + + assertNotNull(adminRepository); + assertInstanceOf(AdminRepository.class, adminRepository); + } +} diff --git a/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java b/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java index b3f3421..29c92ec 100644 --- a/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java +++ b/src/test/java/snackscription/subscriptionadmin/factory/AdminSubscriptionFactoryTest.java @@ -26,7 +26,7 @@ void testCreateAdminSubscriptionComplete() { "12345678910", SubscriptionStatus.PENDING.getValue() ); - + assertNotNull(adminSubscription.getSubscriptionId()); assertEquals("Hwang Hyunjin", adminSubscription.getSubscriberName()); assertEquals("12345678910", adminSubscription.getSubscriberId()); From cf66206415dcadc39dc93480fb4689089f23782d Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 11:36:27 +0700 Subject: [PATCH 8/9] Add JPA and PostgreSQL dependencies --- build.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index fe2dec7..f58ad8c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,10 +28,12 @@ val webdrivermanagerVersion = "5.6.3" val junitJupiterVersion = "5.9.1" dependencies { + implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation("org.springframework.boot:spring-boot-starter-thymeleaf") implementation("org.springframework.boot:spring-boot-starter-web") compileOnly("org.projectlombok:lombok") developmentOnly("org.springframework.boot:spring-boot-devtools") + runtimeOnly("org.postgresql:postgresql") annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") annotationProcessor("org.projectlombok:lombok") testImplementation("org.springframework.boot:spring-boot-starter-test") From 0ebbd926ee344a712539ca25c765855845aeb3cd Mon Sep 17 00:00:00 2001 From: sdikyarts Date: Wed, 8 May 2024 12:32:10 +0700 Subject: [PATCH 9/9] Setting Database --- .../subscriptionadmin/model/AdminSubscription.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java index 46b13a4..3a1d179 100644 --- a/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java +++ b/src/main/java/snackscription/subscriptionadmin/model/AdminSubscription.java @@ -1,6 +1,6 @@ package snackscription.subscriptionadmin.model; -import lombok.Builder; +import jakarta.persistence.*; import lombok.Getter; import lombok.Setter; import snackscription.subscriptionadmin.enums.SubscriptionStatus;