BAEL-3777: First setup
This commit is contained in:
parent
4ec89d5005
commit
a1837550e8
|
@ -20,14 +20,20 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-cassandra</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>5.6.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
<artifactId>junit-jupiter-engine</artifactId>
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>5.6.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- JUnit platform launcher -->
|
<!-- JUnit platform launcher -->
|
||||||
|
@ -35,7 +41,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.platform</groupId>
|
<groupId>org.junit.platform</groupId>
|
||||||
<artifactId>junit-platform-launcher</artifactId>
|
<artifactId>junit-platform-launcher</artifactId>
|
||||||
<version>${junit-platform.version}</version>
|
<version>1.6.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.baeldung.dddhexagonalspring.infrastracture.configuration;
|
||||||
|
|
||||||
|
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
|
||||||
|
|
||||||
|
import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataCassandraOrderRepository;
|
||||||
|
|
||||||
|
@EnableCassandraRepositories(basePackageClasses = SpringDataCassandraOrderRepository.class)
|
||||||
|
public class CassandraConfiguration {
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
package com.baeldung.dddhexagonalspring.infrastracture.configuration;
|
package com.baeldung.dddhexagonalspring.infrastracture.configuration;
|
||||||
|
|
||||||
import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataOrderRepository;
|
import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataMongoOrderRepository;
|
||||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||||
|
|
||||||
@EnableMongoRepositories(basePackageClasses = SpringDataOrderRepository.class)
|
@EnableMongoRepositories(basePackageClasses = SpringDataMongoOrderRepository.class)
|
||||||
public class MongoDBConfiguration {
|
public class MongoDBConfiguration {
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.baeldung.dddhexagonalspring.infrastracture.repository;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import com.baeldung.dddhexagonalspring.domain.Order;
|
||||||
|
import com.baeldung.dddhexagonalspring.domain.repository.OrderRepository;
|
||||||
|
|
||||||
|
public class CassandraDbOrderRepository implements OrderRepository {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<Order> findById(UUID id) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(Order order) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,10 +11,10 @@ import java.util.UUID;
|
||||||
@Component
|
@Component
|
||||||
public class MongoDbOrderRepository implements OrderRepository {
|
public class MongoDbOrderRepository implements OrderRepository {
|
||||||
|
|
||||||
private final SpringDataOrderRepository orderRepository;
|
private final SpringDataMongoOrderRepository orderRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public MongoDbOrderRepository(final SpringDataOrderRepository orderRepository) {
|
public MongoDbOrderRepository(final SpringDataMongoOrderRepository orderRepository) {
|
||||||
this.orderRepository = orderRepository;
|
this.orderRepository = orderRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.baeldung.dddhexagonalspring.infrastracture.repository;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.springframework.data.cassandra.repository.CassandraRepository;
|
||||||
|
|
||||||
|
import com.baeldung.dddhexagonalspring.domain.Order;
|
||||||
|
|
||||||
|
public interface SpringDataCassandraOrderRepository extends CassandraRepository<Order, UUID>{
|
||||||
|
|
||||||
|
}
|
|
@ -7,5 +7,5 @@ import org.springframework.stereotype.Repository;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface SpringDataOrderRepository extends MongoRepository<Order, UUID> {
|
public interface SpringDataMongoOrderRepository extends MongoRepository<Order, UUID> {
|
||||||
}
|
}
|
|
@ -2,4 +2,10 @@ spring.data.mongodb.host=localhost
|
||||||
spring.data.mongodb.port=27017
|
spring.data.mongodb.port=27017
|
||||||
spring.data.mongodb.database=order-database
|
spring.data.mongodb.database=order-database
|
||||||
spring.data.mongodb.username=order
|
spring.data.mongodb.username=order
|
||||||
spring.data.mongodb.password=order
|
spring.data.mongodb.password=order
|
||||||
|
|
||||||
|
spring.data.cassandra.keyspaceName=order-database
|
||||||
|
spring.data.cassandra.username=cassandra
|
||||||
|
spring.data.cassandra.password=cassandra
|
||||||
|
spring.data.cassandra.contactPoints=localhost
|
||||||
|
spring.data.cassandra.port=9042
|
|
@ -14,12 +14,12 @@ import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
class MongoDbOrderRepositoryUnitTest {
|
class MongoDbOrderRepositoryUnitTest {
|
||||||
|
|
||||||
private SpringDataOrderRepository springDataOrderRepository;
|
private SpringDataMongoOrderRepository springDataOrderRepository;
|
||||||
private MongoDbOrderRepository tested;
|
private MongoDbOrderRepository tested;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp(){
|
void setUp(){
|
||||||
springDataOrderRepository = mock(SpringDataOrderRepository.class);
|
springDataOrderRepository = mock(SpringDataMongoOrderRepository.class);
|
||||||
|
|
||||||
tested = new MongoDbOrderRepository(springDataOrderRepository);
|
tested = new MongoDbOrderRepository(springDataOrderRepository);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,9 @@ services:
|
||||||
MONGO_INITDB_ROOT_PASSWORD: admin
|
MONGO_INITDB_ROOT_PASSWORD: admin
|
||||||
MONGO_INITDB_DATABASE: order-database
|
MONGO_INITDB_DATABASE: order-database
|
||||||
volumes:
|
volumes:
|
||||||
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
|
||||||
|
order-cassandra-database:
|
||||||
|
image: cassandra:3.11.5
|
||||||
|
restart: always
|
||||||
|
ports:
|
||||||
|
- 9042:9042
|
Loading…
Reference in New Issue