Organizing Layers Using Hexagona

2022-03-30  本文已影响0人  矩形

https://www.baeldung.com/hexagonal-architecture-ddd-spring

class DomainOrderServiceUnitTest {

private OrderRepository orderRepository;
private DomainOrderService tested;
@BeforeEach
void setUp() {
    orderRepository = mock(OrderRepository.class);
    tested = new DomainOrderService(orderRepository);
}

@Test
void shouldCreateOrder_thenSaveIt() {
    final Product product = new Product(UUID.randomUUID(), BigDecimal.TEN, "productName");

    final UUID id = tested.createOrder(product);

    verify(orderRepository).save(any(Order.class));
    assertNotNull(id);
}

}

上一篇 下一篇

猜你喜欢

热点阅读