diff --git a/payment-service/pom.xml b/payment-service/pom.xml index 480eae5c..d4989b28 100644 --- a/payment-service/pom.xml +++ b/payment-service/pom.xml @@ -64,6 +64,12 @@ spring-boot-test test + + org.axonframework + axon-test + 4.8.0 + test + junit junit @@ -115,6 +121,7 @@ **/*model*/** **/*Application* **/*entity*/** + **/*data*/** **/resources/** @@ -186,6 +193,7 @@ **/*common*/**, **/*constant*/**, **/*model*/**, + **/*data*/**, **/*Application.* diff --git a/payment-service/src/main/java/com.nashtech.payment/PaymentApplication.java b/payment-service/src/main/java/com/nashtech/payment/PaymentApplication.java similarity index 100% rename from payment-service/src/main/java/com.nashtech.payment/PaymentApplication.java rename to payment-service/src/main/java/com/nashtech/payment/PaymentApplication.java diff --git a/payment-service/src/main/java/com.nashtech.payment/aggregate/PaymentAggregate.java b/payment-service/src/main/java/com/nashtech/payment/aggregate/PaymentAggregate.java similarity index 100% rename from payment-service/src/main/java/com.nashtech.payment/aggregate/PaymentAggregate.java rename to payment-service/src/main/java/com/nashtech/payment/aggregate/PaymentAggregate.java diff --git a/payment-service/src/main/java/com.nashtech.payment/config/AxonXStreamConfig.java b/payment-service/src/main/java/com/nashtech/payment/config/AxonXStreamConfig.java similarity index 100% rename from payment-service/src/main/java/com.nashtech.payment/config/AxonXStreamConfig.java rename to payment-service/src/main/java/com/nashtech/payment/config/AxonXStreamConfig.java diff --git a/payment-service/src/main/java/com.nashtech.payment/data/PaymentEntity.java b/payment-service/src/main/java/com/nashtech/payment/data/PaymentEntity.java similarity index 100% rename from payment-service/src/main/java/com.nashtech.payment/data/PaymentEntity.java rename to payment-service/src/main/java/com/nashtech/payment/data/PaymentEntity.java diff --git a/payment-service/src/main/java/com.nashtech.payment/data/PaymentsRepository.java b/payment-service/src/main/java/com/nashtech/payment/data/PaymentsRepository.java similarity index 100% rename from payment-service/src/main/java/com.nashtech.payment/data/PaymentsRepository.java rename to payment-service/src/main/java/com/nashtech/payment/data/PaymentsRepository.java diff --git a/payment-service/src/main/java/com.nashtech.payment/handler/PaymentsEventHandler.java b/payment-service/src/main/java/com/nashtech/payment/handler/PaymentsEventHandler.java similarity index 100% rename from payment-service/src/main/java/com.nashtech.payment/handler/PaymentsEventHandler.java rename to payment-service/src/main/java/com/nashtech/payment/handler/PaymentsEventHandler.java diff --git a/payment-service/src/test/java/com/nashtech/payment/PaymentMircoserviceApplicationTests.java b/payment-service/src/test/java/com/nashtech/payment/PaymentMircoserviceApplicationTests.java index 17f4b631..64faef31 100644 --- a/payment-service/src/test/java/com/nashtech/payment/PaymentMircoserviceApplicationTests.java +++ b/payment-service/src/test/java/com/nashtech/payment/PaymentMircoserviceApplicationTests.java @@ -1,5 +1,3 @@ -package com.nashtech.payment; - /* import org.springframework.boot.test.context.SpringBootTest; diff --git a/payment-service/src/test/java/com/nashtech/payment/aggregate/PaymentAggregateTest.java b/payment-service/src/test/java/com/nashtech/payment/aggregate/PaymentAggregateTest.java index 454a1b8b..2d82d67b 100644 --- a/payment-service/src/test/java/com/nashtech/payment/aggregate/PaymentAggregateTest.java +++ b/payment-service/src/test/java/com/nashtech/payment/aggregate/PaymentAggregateTest.java @@ -8,10 +8,61 @@ import com.nashtech.common.event.PaymentCancelledEvent; import com.nashtech.common.model.PaymentDetails; import com.nashtech.common.model.User; -import org.junit.jupiter.api.Disabled; +import org.axonframework.test.aggregate.AggregateTestFixture; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; class PaymentAggregateTest { + + private AggregateTestFixture fixture; + + @BeforeEach + void setUp() { + fixture = new AggregateTestFixture<>(PaymentAggregate.class); + } + + @Test + void testShipmentAggregateCreation() { + + ProcessPaymentCommand processPaymentCommand = ProcessPaymentCommand.builder() + .basePrice(10.0d) + .brand("Brand") + .orderId("42") + .paymentId("42") + .productId("42") + .quantity(1) + .subTotal(10.0d) + .tax(10.0f) + .total(10.0d) + .totalTax(10.0f) + .userId("1652") + .build(); + + PaymentApprovedEvent paymentApprovedEvent = PaymentApprovedEvent.builder() + .basePrice(10.0d) + .brand("Brand") + .orderId("42") + .paymentId("42") + .productId("42") + .quantity(1) + .subTotal(10.0d) + .tax(10.0f) + .total(10.0d) + .totalTax(10.0f) + .user(User.builder() + .userId("1652") + .firstName("Abid") + .lastName("Khan") + .address("Noida") + .emailId("abid.khan@nashtechglobal.com") + .mobileNumber("9087658765") + .build()).build(); + + fixture.givenNoPriorActivity() + .when(processPaymentCommand) + .expectEvents(paymentApprovedEvent); + } + /** * Method under test: * {@link PaymentAggregate#buildPaymentCancelEvent(ProcessPaymentCommand, String)} diff --git a/payment-service/src/test/java/com/nashtech/payment/config/AxonXStreamConfigTest.java b/payment-service/src/test/java/com/nashtech/payment/config/AxonXStreamConfigTest.java deleted file mode 100644 index 5fa8bcc1..00000000 --- a/payment-service/src/test/java/com/nashtech/payment/config/AxonXStreamConfigTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.nashtech.payment.config; - -import com.thoughtworks.xstream.XStream; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class AxonXStreamConfigTest { - @Test - void testXStreamBeanCreation() { - AxonXStreamConfig axonXStreamConfig = new AxonXStreamConfig(); - XStream xStream = axonXStreamConfig.xStream(); - - assertNotNull(xStream); - } -} diff --git a/payment-service/src/test/java/com/nashtech/payment/data/PaymentEntityTest.java b/payment-service/src/test/java/com/nashtech/payment/data/PaymentEntityTest.java deleted file mode 100644 index 2c889ea1..00000000 --- a/payment-service/src/test/java/com/nashtech/payment/data/PaymentEntityTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.nashtech.payment.data; - -import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -public class PaymentEntityTest { - @Test - void testPaymentEntityCreation() { - // Given - String paymentId = "123"; - String orderId = "456"; - String productId = "789"; - Integer quantity = 2; - Double basePrice = 50.0; - Double subTotal = 100.0; - Double total = 110.0; - Float tax = 5.0f; - Float totalTax = 5.5f; - - // When - PaymentEntity paymentEntity = PaymentEntity.builder() - .paymentId(paymentId) - .orderId(orderId) - .productId(productId) - .quantity(quantity) - .basePrice(basePrice) - .subTotal(subTotal) - .total(total) - .tax(tax) - .totalTax(totalTax) - .build(); - - // Then - assertNotNull(paymentEntity); - assertEquals(paymentId, paymentEntity.getPaymentId()); - assertEquals(orderId, paymentEntity.getOrderId()); - assertEquals(productId, paymentEntity.getProductId()); - assertEquals(quantity, paymentEntity.getQuantity()); - assertEquals(basePrice, paymentEntity.getBasePrice()); - assertEquals(subTotal, paymentEntity.getSubTotal()); - assertEquals(total, paymentEntity.getTotal()); - assertEquals(tax, paymentEntity.getTax()); - assertEquals(totalTax, paymentEntity.getTotalTax()); - } -} diff --git a/payment-service/src/test/java/com/nashtech/payment/handler/PaymentsEventHandlerTest.java b/payment-service/src/test/java/com/nashtech/payment/handler/PaymentsEventHandlerTest.java index 4688c45b..e7e82eff 100644 --- a/payment-service/src/test/java/com/nashtech/payment/handler/PaymentsEventHandlerTest.java +++ b/payment-service/src/test/java/com/nashtech/payment/handler/PaymentsEventHandlerTest.java @@ -11,7 +11,7 @@ import org.mockito.MockitoAnnotations; @Slf4j -public class PaymentsEventHandlerTest { +class PaymentsEventHandlerTest { @Mock private PaymentsRepository paymentsRepository; @@ -24,7 +24,7 @@ public void setUp() { } @Test - public void testPaymentApprovedEventHandling() { + void testPaymentApprovedEventHandling() { // Given PaymentApprovedEvent paymentApprovedEvent = PaymentApprovedEvent.builder().build();