BAEL-3777: Fixed formatting

This commit is contained in:
Sorin Zamfir 2020-02-01 11:47:00 +02:00
parent b05d42a6ea
commit 8b49858bfe
12 changed files with 36 additions and 32 deletions

View File

@ -41,13 +41,11 @@ public class Order {
}
private OrderItem getOrderItem(final UUID id) {
return orderItems
.stream()
.filter(orderItem -> orderItem
.getProductId()
.equals(id))
.findFirst()
.orElseThrow(() -> new DomainException("Product with " + id + " doesn't exist."));
return orderItems.stream()
.filter(orderItem -> orderItem.getProductId()
.equals(id))
.findFirst()
.orElseThrow(() -> new DomainException("Product with " + id + " doesn't exist."));
}
private void validateState() {
@ -78,7 +76,6 @@ public class Order {
return Collections.unmodifiableList(orderItems);
}
@Override
public int hashCode() {
return Objects.hash(id, orderItems, price, status);
@ -93,7 +90,7 @@ public class Order {
Order other = (Order) obj;
return Objects.equals(id, other.id) && Objects.equals(orderItems, other.orderItems) && Objects.equals(price, other.price) && status == other.status;
}
private Order() {
}
}

View File

@ -2,7 +2,7 @@ package com.baeldung.dddhexagonalspring.infrastracture.configuration;
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataCassandraOrderRepository;
import com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra.SpringDataCassandraOrderRepository;
@EnableCassandraRepositories(basePackageClasses = SpringDataCassandraOrderRepository.class)
public class CassandraConfiguration {

View File

@ -1,8 +1,9 @@
package com.baeldung.dddhexagonalspring.infrastracture.configuration;
import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataMongoOrderRepository;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import com.baeldung.dddhexagonalspring.infrastracture.repository.mongo.SpringDataMongoOrderRepository;
@EnableMongoRepositories(basePackageClasses = SpringDataMongoOrderRepository.class)
public class MongoDBConfiguration {
}

View File

@ -1,4 +1,4 @@
package com.baeldung.dddhexagonalspring.infrastracture.repository;
package com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra;
import java.util.Optional;
import java.util.UUID;

View File

@ -1,4 +1,4 @@
package com.baeldung.dddhexagonalspring.infrastracture.repository;
package com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra;
import java.math.BigDecimal;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.baeldung.dddhexagonalspring.infrastracture.repository;
package com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra;
import java.math.BigDecimal;
import java.util.UUID;

View File

@ -1,4 +1,4 @@
package com.baeldung.dddhexagonalspring.infrastracture.repository;
package com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra;
import java.util.UUID;

View File

@ -1,4 +1,4 @@
package com.baeldung.dddhexagonalspring.infrastracture.repository;
package com.baeldung.dddhexagonalspring.infrastracture.repository.mongo;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;

View File

@ -1,4 +1,4 @@
package com.baeldung.dddhexagonalspring.infrastracture.repository;
package com.baeldung.dddhexagonalspring.infrastracture.repository.mongo;
import com.baeldung.dddhexagonalspring.domain.Order;
import org.springframework.data.mongodb.repository.MongoRepository;

View File

@ -6,7 +6,7 @@ import java.math.BigDecimal;
import java.util.Optional;
import java.util.UUID;
import org.junit.After;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@ -16,6 +16,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.Product;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
import com.baeldung.dddhexagonalspring.infrastracture.repository.cassandra.SpringDataCassandraOrderRepository;
@SpringJUnitConfig
@SpringBootTest
@ -24,23 +25,24 @@ class CassandraDbOrderRepositoryIntegrationTest {
@Autowired
private SpringDataCassandraOrderRepository cassandraOrderRepository;
@Autowired
private OrderRepository orderRepository;
@After
void cleanUp(){
@AfterEach
void cleanUp() {
cassandraOrderRepository.deleteAll();
}
@Test
void shouldFindById_thenReturnOrder() {
// given
final UUID id = UUID.randomUUID();
final Order order = createOrder(id);
order.addOrder(new Product(UUID.randomUUID(), BigDecimal.TEN, "second"));
order.complete();
// when
orderRepository.save(order);

View File

@ -6,7 +6,7 @@ import java.math.BigDecimal;
import java.util.Optional;
import java.util.UUID;
import org.junit.After;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@ -16,6 +16,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.Product;
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
import com.baeldung.dddhexagonalspring.infrastracture.repository.mongo.SpringDataMongoOrderRepository;
@SpringJUnitConfig
@SpringBootTest
@ -24,22 +25,22 @@ class MongoDbOrderRepositoryIntegrationTest {
@Autowired
private SpringDataMongoOrderRepository mongoOrderRepository;
@Autowired
private OrderRepository orderRepository;
@After
void cleanUp(){
@AfterEach
void cleanUp() {
mongoOrderRepository.deleteAll();
}
@Test
void shouldFindById_thenReturnOrder() {
// given
final UUID id = UUID.randomUUID();
final Order order = createOrder(id);
// when
orderRepository.save(order);

View File

@ -2,6 +2,9 @@ package com.baeldung.dddhexagonalspring.infrastracture.repository;
import com.baeldung.dddhexagonalspring.domain.Order;
import com.baeldung.dddhexagonalspring.domain.Product;
import com.baeldung.dddhexagonalspring.infrastracture.repository.mongo.MongoDbOrderRepository;
import com.baeldung.dddhexagonalspring.infrastracture.repository.mongo.SpringDataMongoOrderRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -18,7 +21,7 @@ class MongoDbOrderRepositoryUnitTest {
private MongoDbOrderRepository tested;
@BeforeEach
void setUp(){
void setUp() {
springDataOrderRepository = mock(SpringDataMongoOrderRepository.class);
tested = new MongoDbOrderRepository(springDataOrderRepository);