BAEL-5747: added spring modulith test
This commit is contained in:
parent
5e9a5b9b3f
commit
49e66a1a1b
@ -55,6 +55,12 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.modulith</groupId>
|
||||||
|
<artifactId>spring-modulith-starter-test</artifactId>
|
||||||
|
<version>1.1.3</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testcontainers</groupId>
|
<groupId>org.testcontainers</groupId>
|
||||||
<artifactId>kafka</artifactId>
|
<artifactId>kafka</artifactId>
|
||||||
|
@ -2,19 +2,18 @@ package com.baeldung.springmodulith.application.events;
|
|||||||
|
|
||||||
import com.baeldung.springmodulith.application.events.orders.OrderService;
|
import com.baeldung.springmodulith.application.events.orders.OrderService;
|
||||||
import com.baeldung.springmodulith.application.events.rewards.LoyalCustomersRepository;
|
import com.baeldung.springmodulith.application.events.rewards.LoyalCustomersRepository;
|
||||||
import com.baeldung.springmodulith.application.events.rewards.LoyalCustomersRepository.LoyalCustomer;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.modulith.test.ApplicationModuleTest;
|
||||||
import java.util.Optional;
|
import org.springframework.modulith.test.Scenario;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@SpringBootTest
|
@ApplicationModuleTest
|
||||||
@ComponentScan(basePackages = "com.baeldung.springmodulith.application.events")
|
@ComponentScan(basePackages = "com.baeldung.springmodulith.application.events")
|
||||||
public class ApplicationEventsUnitTest {
|
public class SpringModulithScenarioApiUnitTest {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
OrderService orderService;
|
OrderService orderService;
|
||||||
@ -23,15 +22,8 @@ public class ApplicationEventsUnitTest {
|
|||||||
LoyalCustomersRepository loyalCustomers;
|
LoyalCustomersRepository loyalCustomers;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void whenNewCustomerCompletesAnOrder_thenHeReceivesSingUpPointsPlusOrderPoints() {
|
void test(Scenario scenario) {
|
||||||
orderService.placeOrder("customer1", "product1", "product2");
|
|
||||||
|
|
||||||
Optional<LoyalCustomer> customer = loyalCustomers.find("customer1");
|
|
||||||
|
|
||||||
assertThat(customer).isPresent()
|
|
||||||
.get()
|
|
||||||
.extracting(LoyalCustomer::points)
|
|
||||||
.isEqualTo(50 + 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user