BAEL-3777: First setup
This commit is contained in:
parent
4ec89d5005
commit
a1837550e8
|
@ -20,14 +20,20 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-cassandra</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.6.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.6.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- JUnit platform launcher -->
|
||||
|
@ -35,7 +41,7 @@
|
|||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-launcher</artifactId>
|
||||
<version>${junit-platform.version}</version>
|
||||
<version>1.6.0</version>
|
||||
<scope>test</scope>
|
||||
</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;
|
||||
|
||||
import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataOrderRepository;
|
||||
import com.baeldung.dddhexagonalspring.infrastracture.repository.SpringDataMongoOrderRepository;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
@EnableMongoRepositories(basePackageClasses = SpringDataOrderRepository.class)
|
||||
@EnableMongoRepositories(basePackageClasses = SpringDataMongoOrderRepository.class)
|
||||
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
|
||||
public class MongoDbOrderRepository implements OrderRepository {
|
||||
|
||||
private final SpringDataOrderRepository orderRepository;
|
||||
private final SpringDataMongoOrderRepository orderRepository;
|
||||
|
||||
@Autowired
|
||||
public MongoDbOrderRepository(final SpringDataOrderRepository orderRepository) {
|
||||
public MongoDbOrderRepository(final SpringDataMongoOrderRepository 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;
|
||||
|
||||
@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.database=order-database
|
||||
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 {
|
||||
|
||||
private SpringDataOrderRepository springDataOrderRepository;
|
||||
private SpringDataMongoOrderRepository springDataOrderRepository;
|
||||
private MongoDbOrderRepository tested;
|
||||
|
||||
@BeforeEach
|
||||
void setUp(){
|
||||
springDataOrderRepository = mock(SpringDataOrderRepository.class);
|
||||
springDataOrderRepository = mock(SpringDataMongoOrderRepository.class);
|
||||
|
||||
tested = new MongoDbOrderRepository(springDataOrderRepository);
|
||||
}
|
||||
|
|
|
@ -11,4 +11,9 @@ services:
|
|||
MONGO_INITDB_ROOT_PASSWORD: admin
|
||||
MONGO_INITDB_DATABASE: order-database
|
||||
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