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