Feature/bael 5040 cassandra testcontainers (#11124)
* BAEL-5040: initial commit - spring data cassandra using boot-2 * BAEL-5040: update test example * BAEL-5040: add brackets * BAEL-5040: use singleton container * BAEL-5040: switch from singleton to nested classes approach * BAEL-5040: package private methods in junit5 * BAEL-5040: Move SpringBootTest annotation to parent class
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
package org.baeldung.springcassandra;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableCassandraRepositories(basePackages = "org.baeldung.springcassandra.repository")
|
||||
public class SpringCassandraApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringCassandraApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package org.baeldung.springcassandra.model;
|
||||
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Table
|
||||
public class Car {
|
||||
|
||||
@PrimaryKey
|
||||
private UUID id;
|
||||
|
||||
private String make;
|
||||
|
||||
private String model;
|
||||
|
||||
private int year;
|
||||
|
||||
public Car(UUID id, String make, String model, int year) {
|
||||
this.id = id;
|
||||
this.make = make;
|
||||
this.model = model;
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMake() {
|
||||
return make;
|
||||
}
|
||||
|
||||
public void setMake(String make) {
|
||||
this.make = make;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public int getYear() {
|
||||
return year;
|
||||
}
|
||||
|
||||
public void setYear(int year) {
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Car car = (Car) o;
|
||||
return year == car.year && Objects.equals(id, car.id) && Objects.equals(make, car.make) && Objects.equals(model, car.model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, make, model, year);
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.baeldung.springcassandra.repository;
|
||||
|
||||
import org.baeldung.springcassandra.model.Car;
|
||||
import org.springframework.data.cassandra.repository.CassandraRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Repository
|
||||
public interface CarRepository extends CassandraRepository<Car, UUID> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
spring.data.cassandra.keyspace-name=${CASSANDRA_KEYSPACE_NAME}
|
||||
spring.data.cassandra.contact-points=${CASSANDRA_CONTACT_POINTS}
|
||||
spring.data.cassandra.port=${CASSANDRA_PORT}
|
||||
spring.data.cassandra.local-datacenter=datacenter1
|
||||
Reference in New Issue
Block a user