BAEL-2275: Fill the test. Rename package.

This commit is contained in:
Lukasz Rys 2019-12-07 17:40:17 +01:00
parent b7c0761241
commit 6d1caf8026
22 changed files with 94 additions and 68 deletions

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers;
package com.baeldung.dddhexagonalspring;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,9 +1,9 @@
package com.baeldung.ddd.layers.application.controller;
package com.baeldung.dddhexagonalspring.application.controller;
import com.baeldung.ddd.layers.application.request.AddProductRequest;
import com.baeldung.ddd.layers.application.request.CreateOrderRequest;
import com.baeldung.ddd.layers.application.response.CreateOrderResponse;
import com.baeldung.ddd.layers.domain.service.OrderService;
import com.baeldung.dddhexagonalspring.application.request.AddProductRequest;
import com.baeldung.dddhexagonalspring.application.request.CreateOrderRequest;
import com.baeldung.dddhexagonalspring.application.response.CreateOrderResponse;
import com.baeldung.dddhexagonalspring.domain.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

View File

@ -1,6 +1,6 @@
package com.baeldung.ddd.layers.application.request;
package com.baeldung.dddhexagonalspring.application.request;
import com.baeldung.ddd.layers.domain.Product;
import com.baeldung.dddhexagonalspring.domain.Product;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

View File

@ -1,6 +1,6 @@
package com.baeldung.ddd.layers.application.request;
package com.baeldung.dddhexagonalspring.application.request;
import com.baeldung.ddd.layers.domain.Product;
import com.baeldung.dddhexagonalspring.domain.Product;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers.application.response;
package com.baeldung.dddhexagonalspring.application.response;
import java.util.UUID;

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers.domain;
package com.baeldung.dddhexagonalspring.domain;
class DomainException extends RuntimeException {
DomainException(final String message) {

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers.domain;
package com.baeldung.dddhexagonalspring.domain;
import java.math.BigDecimal;
import java.util.ArrayList;

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers.domain;
package com.baeldung.dddhexagonalspring.domain;
import java.math.BigDecimal;
import java.util.Objects;

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers.domain;
package com.baeldung.dddhexagonalspring.domain;
public enum OrderStatus {
CREATED, COMPLETED

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers.domain;
package com.baeldung.dddhexagonalspring.domain;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

View File

@ -1,6 +1,6 @@
package com.baeldung.ddd.layers.domain.repository;
package com.baeldung.dddhexagonalspring.domain.repository;
import com.baeldung.ddd.layers.domain.Order;
import com.baeldung.dddhexagonalspring.domain.Order;
import java.util.Optional;
import java.util.UUID;

View File

@ -1,8 +1,8 @@
package com.baeldung.ddd.layers.domain.service;
package com.baeldung.dddhexagonalspring.domain.service;
import com.baeldung.ddd.layers.domain.Order;
import com.baeldung.ddd.layers.domain.Product;
import com.baeldung.ddd.layers.domain.repository.OrderRepository;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.Product;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
import java.util.UUID;

View File

@ -1,6 +1,6 @@
package com.baeldung.ddd.layers.domain.service;
package com.baeldung.dddhexagonalspring.domain.service;
import com.baeldung.ddd.layers.domain.Product;
import com.baeldung.dddhexagonalspring.domain.Product;
import java.util.UUID;

View File

@ -1,9 +1,9 @@
package com.baeldung.ddd.layers.infrastracture.configuration;
package com.baeldung.dddhexagonalspring.infrastracture.configuration;
import com.baeldung.ddd.layers.DomainLayerApplication;
import com.baeldung.ddd.layers.domain.repository.OrderRepository;
import com.baeldung.ddd.layers.domain.service.DomainOrderService;
import com.baeldung.ddd.layers.domain.service.OrderService;
import com.baeldung.dddhexagonalspring.DomainLayerApplication;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
import com.baeldung.dddhexagonalspring.domain.service.DomainOrderService;
import com.baeldung.dddhexagonalspring.domain.service.OrderService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

View File

@ -1,6 +1,6 @@
package com.baeldung.ddd.layers.infrastracture.configuration;
package com.baeldung.dddhexagonalspring.infrastracture.configuration;
import com.baeldung.ddd.layers.infrastracture.repository.SpringDataOrderRepository;
import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataOrderRepository;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
@EnableMongoRepositories(basePackageClasses = SpringDataOrderRepository.class)

View File

@ -1,7 +1,7 @@
package com.baeldung.ddd.layers.infrastracture.repository;
package com.baeldung.dddhexagonalspring.infrastracture.repository;
import com.baeldung.ddd.layers.domain.Order;
import com.baeldung.ddd.layers.domain.repository.OrderRepository;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

View File

@ -1,6 +1,6 @@
package com.baeldung.ddd.layers.infrastracture.repository;
package com.baeldung.dddhexagonalspring.infrastracture.repository;
import com.baeldung.ddd.layers.domain.Order;
import com.baeldung.dddhexagonalspring.domain.Order;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;

View File

@ -1,25 +0,0 @@
package com.baeldung.ddd.layers.infrastracture.repository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class MongoDbOrderRepositoryUnitTest {
private SpringDataOrderRepository springDataOrderRepository;
private MongoDbOrderRepository tested;
@BeforeEach
void setUp(){
}
@Test
void findById() {
}
@Test
void save() {
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers.domain;
package com.baeldung.dddhexagonalspring.domain;
import java.math.BigDecimal;
import java.util.UUID;

View File

@ -1,4 +1,4 @@
package com.baeldung.ddd.layers.domain;
package com.baeldung.dddhexagonalspring.domain;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

View File

@ -1,9 +1,9 @@
package com.baeldung.ddd.layers.domain.service;
package com.baeldung.dddhexagonalspring.domain.service;
import com.baeldung.ddd.layers.domain.Order;
import com.baeldung.ddd.layers.domain.OrderProvider;
import com.baeldung.ddd.layers.domain.Product;
import com.baeldung.ddd.layers.domain.repository.OrderRepository;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.OrderProvider;
import com.baeldung.dddhexagonalspring.domain.Product;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;

View File

@ -0,0 +1,51 @@
package com.baeldung.dddhexagonalspring.infrastracture.repository;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.Product;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.math.BigDecimal;
import java.util.Optional;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
class MongoDbOrderRepositoryUnitTest {
private SpringDataOrderRepository springDataOrderRepository;
private MongoDbOrderRepository tested;
@BeforeEach
void setUp(){
springDataOrderRepository = mock(SpringDataOrderRepository.class);
tested = new MongoDbOrderRepository(springDataOrderRepository);
}
@Test
void shouldFindById_thenReturnOrder() {
final UUID id = UUID.randomUUID();
final Order order = createOrder(id);
when(springDataOrderRepository.findById(id)).thenReturn(Optional.of(order));
final Optional<Order> result = tested.findById(id);
assertEquals(order, result.get());
}
@Test
void shouldSaveOrder_viaSpringDataOrderRepository() {
final UUID id = UUID.randomUUID();
final Order order = createOrder(id);
tested.save(order);
verify(springDataOrderRepository).save(order);
}
private Order createOrder(UUID id) {
return new Order(id, new Product(UUID.randomUUID(), BigDecimal.TEN, "product"));
}
}