@@ -38,14 +38,13 @@ import java.util.stream.Collectors;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.couchbase.core.query.Query;
|
||||
import org.springframework.data.couchbase.core.query.QueryCriteria;
|
||||
import org.springframework.data.couchbase.domain.Address;
|
||||
import org.springframework.data.couchbase.domain.Airport;
|
||||
import org.springframework.data.couchbase.domain.AssessmentDO;
|
||||
import org.springframework.data.couchbase.domain.Course;
|
||||
import org.springframework.data.couchbase.domain.Config;
|
||||
import org.springframework.data.couchbase.domain.Course;
|
||||
import org.springframework.data.couchbase.domain.NaiveAuditorAware;
|
||||
import org.springframework.data.couchbase.domain.PersonWithMaps;
|
||||
import org.springframework.data.couchbase.domain.Submission;
|
||||
@@ -152,7 +151,7 @@ class CouchbaseTemplateQueryIntegrationTests extends JavaIntegrationTests {
|
||||
person1.setReleaseVersions(releaseVersions);
|
||||
couchbaseTemplate.upsertById(PersonWithMaps.class).one(person1);
|
||||
PersonWithMaps person2 = couchbaseTemplate.findById(PersonWithMaps.class).one(person1.getId());
|
||||
assertEquals(person1, person2);
|
||||
assertEquals(person1, person2);
|
||||
couchbaseTemplate.removeById(PersonWithMaps.class).oneEntity(person1);
|
||||
}
|
||||
|
||||
@@ -184,11 +183,11 @@ class CouchbaseTemplateQueryIntegrationTests extends JavaIntegrationTests {
|
||||
ado = couchbaseTemplate.upsertById(AssessmentDO.class).one(ado);
|
||||
|
||||
Query specialUsers = new Query(QueryCriteria.where(i("id")).is(ado.getId()));
|
||||
final List<AssessmentDO> foundUsers = couchbaseTemplate.findByQuery(AssessmentDO.class)
|
||||
final List<AssessmentDO> assementDOs = couchbaseTemplate.findByQuery(AssessmentDO.class)
|
||||
.withConsistency(REQUEST_PLUS).matching(specialUsers).all();
|
||||
assertEquals("123", foundUsers.get(0).getId(), "id");
|
||||
assertEquals("44444444", foundUsers.get(0).getDocumentId(), "documentId");
|
||||
assertEquals(ado, foundUsers.get(0));
|
||||
assertEquals("123", assementDOs.get(0).getId(), "id");
|
||||
assertEquals("44444444", assementDOs.get(0).getDocumentId(), "documentId");
|
||||
assertEquals(ado, assementDOs.get(0));
|
||||
couchbaseTemplate.removeById(AssessmentDO.class).one(ado.getDocumentId());
|
||||
}
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
import org.springframework.data.couchbase.core.mapping.Field;
|
||||
@@ -30,8 +27,6 @@ import org.springframework.data.couchbase.core.mapping.id.IdAttribute;
|
||||
* @author Michael Reiche
|
||||
*/
|
||||
@Document()
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class AssessmentDO {
|
||||
@Id @GeneratedValue(strategy = GenerationStrategy.USE_ATTRIBUTES) private String documentId;
|
||||
|
||||
@@ -40,4 +35,38 @@ public class AssessmentDO {
|
||||
@Field("docType") private String documentType;
|
||||
|
||||
@Field private String id;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getDocumentId() {
|
||||
return documentId;
|
||||
}
|
||||
|
||||
public void setEventTimestamp(long eventTimestamp) {
|
||||
this.eventTimestamp = eventTimestamp;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (other == null || !(other instanceof AssessmentDO)) {
|
||||
return false;
|
||||
}
|
||||
AssessmentDO that = (AssessmentDO) other;
|
||||
return equals(this.id, that.id) && equals(this.documentId, that.documentId)
|
||||
&& equals(this.eventTimestamp, that.eventTimestamp) && equals(this.documentType, that.documentType);
|
||||
}
|
||||
|
||||
boolean equals(Object s0, Object s1) {
|
||||
if (s0 == null && s1 == null || s0 == s1) {
|
||||
return true;
|
||||
}
|
||||
Object sa = s0 != null ? s0 : s1;
|
||||
Object sb = s0 != null ? s1 : s0;
|
||||
return sa.equals(sb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,42 @@
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
|
||||
@Document
|
||||
public class MutableUser extends User{
|
||||
public MutableUser(String id, String firstname, String lastname) {
|
||||
super(id, firstname, lastname);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
|
||||
private Address address;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private MutableUser subuser;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private List<String> roles;
|
||||
|
||||
|
||||
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setAddress(Address address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setSubuser(MutableUser subuser) {
|
||||
this.subuser = subuser;
|
||||
}
|
||||
|
||||
public MutableUser getSubuser() {
|
||||
return subuser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import lombok.Value;
|
||||
import lombok.With;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
@@ -30,16 +28,13 @@ import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy;
|
||||
* @author Michael Reiche
|
||||
*/
|
||||
|
||||
@Value
|
||||
@Document
|
||||
public class PersonValue {
|
||||
@Id @GeneratedValue(strategy = GenerationStrategy.UNIQUE)
|
||||
@With String id;
|
||||
@Version
|
||||
@With
|
||||
long version;
|
||||
@Field String firstname;
|
||||
@Field String lastname;
|
||||
private final String id;
|
||||
@Version private final long version;
|
||||
@Field private final String firstname;
|
||||
@Field private final String lastname;
|
||||
|
||||
public PersonValue(String id, long version, String firstname, String lastname) {
|
||||
this.id = id;
|
||||
@@ -48,10 +43,26 @@ public class PersonValue {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public PersonValue withId(String id) {
|
||||
return new PersonValue(id, this.version, this.firstname, this.lastname);
|
||||
}
|
||||
|
||||
public PersonValue withVersion(Long version) {
|
||||
return new PersonValue(this.id, version, this.firstname, this.lastname);
|
||||
}
|
||||
|
||||
public PersonValue withFirstname(String firstname) {
|
||||
return new PersonValue(this.id, this.version, firstname, this.lastname);
|
||||
}
|
||||
|
||||
public PersonValue withLastname(String lastname) {
|
||||
return new PersonValue(this.id, this.version, this.firstname, lastname);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("PersonValue : {");
|
||||
sb.append(" id : " + getId());
|
||||
sb.append(" id : " + id);
|
||||
sb.append(", version : " + version);
|
||||
sb.append(", firstname : " + firstname);
|
||||
sb.append(", lastname : " + lastname);
|
||||
@@ -59,4 +70,29 @@ public class PersonValue {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (other == null || !(other instanceof PersonValue)) {
|
||||
return false;
|
||||
}
|
||||
PersonValue that = (PersonValue) other;
|
||||
return equals(this.getId(), that.getId()) && equals(this.version, that.version)
|
||||
&& equals(this.firstname, that.firstname) && equals(this.lastname, that.lastname);
|
||||
}
|
||||
|
||||
boolean equals(Object s0, Object s1) {
|
||||
if (s0 == null && s1 == null || s0 == s1) {
|
||||
return true;
|
||||
}
|
||||
Object sa = s0 != null ? s0 : s1;
|
||||
Object sb = s0 != null ? s1 : s0;
|
||||
return sa.equals(sb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import com.couchbase.client.core.deps.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
import org.springframework.data.couchbase.core.mapping.Field;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
import org.springframework.data.couchbase.core.mapping.Field;
|
||||
|
||||
import com.couchbase.client.core.deps.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Document
|
||||
@@ -24,6 +23,40 @@ public class PersonWithMaps {
|
||||
private Map<String, Map<String,String>> releaseVersions;
|
||||
|
||||
public PersonWithMaps(){
|
||||
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setVersions(Map<String, Set<String>> versions) {
|
||||
this.versions = versions;
|
||||
}
|
||||
|
||||
public void setReleaseVersions(Map<String, Map<String, String>> releaseVersions) {
|
||||
this.releaseVersions = releaseVersions;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean equals(Object other) {
|
||||
if (other == null || !(other instanceof PersonWithMaps)) {
|
||||
return false;
|
||||
}
|
||||
PersonWithMaps that = (PersonWithMaps) other;
|
||||
return equals(this.getId(), that.getId()) && equals(this.versions, that.versions)
|
||||
&& equals(this.releaseVersions, that.releaseVersions);
|
||||
}
|
||||
|
||||
boolean equals(Object s0, Object s1) {
|
||||
if (s0 == null && s1 == null || s0 == s1) {
|
||||
return true;
|
||||
}
|
||||
Object sa = s0 != null ? s0 : s1;
|
||||
Object sb = s0 != null ? s1 : s0;
|
||||
return sa.equals(sb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
@@ -31,9 +28,6 @@ import org.springframework.data.couchbase.core.mapping.id.GenerationStrategy;
|
||||
*
|
||||
* @author Michael Reiche
|
||||
*/
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@Document
|
||||
public class SubscriptionToken {
|
||||
private @Id
|
||||
@@ -72,4 +66,12 @@ public class SubscriptionToken {
|
||||
public void setType(String type) {
|
||||
type = type;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.TypeAlias;
|
||||
@@ -31,7 +29,6 @@ import org.springframework.data.couchbase.core.query.N1qlJoin;
|
||||
*
|
||||
* @author Michael Reiche
|
||||
*/
|
||||
@Data
|
||||
@Document
|
||||
@TypeAlias("user")
|
||||
@CompositeQueryIndex(fields = { "id", "username", "email" })
|
||||
@@ -56,4 +53,43 @@ public class UserSubmission extends ComparableEntity {
|
||||
this.courses = courses;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public List<Course> getCourses() {
|
||||
return courses;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public List<Address> getOtherAddresses() {
|
||||
return otherAddresses;
|
||||
}
|
||||
|
||||
public List<Submission> getSubmissions() {
|
||||
return submissions;
|
||||
}
|
||||
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public void setAddress(Address address) {
|
||||
this.address = address;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,23 +16,20 @@
|
||||
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.TypeAlias;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
import org.springframework.data.couchbase.core.mapping.Field;
|
||||
import org.springframework.data.couchbase.core.query.FetchType;
|
||||
import org.springframework.data.couchbase.core.query.N1qlJoin;
|
||||
import org.springframework.data.couchbase.repository.Collection;
|
||||
import org.springframework.data.couchbase.repository.Scope;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* UserSubmissionAnnotated entity for tests
|
||||
*
|
||||
* @author Michael Reiche
|
||||
*/
|
||||
@Data
|
||||
@Document
|
||||
@TypeAlias("user")
|
||||
@Scope("my_scope")
|
||||
@@ -57,4 +54,23 @@ public class UserSubmissionAnnotated extends ComparableEntity {
|
||||
this.courses = courses;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<AddressAnnotated> getOtherAddresses() {
|
||||
return otherAddresses;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.TypeAlias;
|
||||
@@ -29,7 +27,6 @@ import org.springframework.data.couchbase.core.mapping.Document;
|
||||
*
|
||||
* @author Michael Reiche
|
||||
*/
|
||||
@Data
|
||||
@Document
|
||||
@TypeAlias("user")
|
||||
@CompositeQueryIndex(fields = { "id", "username", "email" })
|
||||
@@ -44,4 +41,19 @@ public class UserSubmissionProjected extends ComparableEntity {
|
||||
this.courses = courses;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public List<Course> getCourses() {
|
||||
return courses;
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.TypeAlias;
|
||||
@@ -31,7 +29,6 @@ import org.springframework.data.couchbase.repository.Collection;
|
||||
*
|
||||
* @author Michael Reiche
|
||||
*/
|
||||
@Data
|
||||
@Document
|
||||
// there is no @Scope annotation on this entity
|
||||
@Collection("my_collection")
|
||||
@@ -56,4 +53,23 @@ public class UserSubmissionUnannotated extends ComparableEntity {
|
||||
this.courses = courses;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public List<AddressAnnotated> getOtherAddresses() {
|
||||
return otherAddresses;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.transactions;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.data.domain.Persistable;
|
||||
|
||||
/**
|
||||
@@ -25,12 +23,16 @@ import org.springframework.data.domain.Persistable;
|
||||
*
|
||||
* @author Michael Reiche
|
||||
*/
|
||||
@Data
|
||||
|
||||
public class AfterTransactionAssertion<T extends Persistable> {
|
||||
|
||||
private final T persistable;
|
||||
private boolean expectToBePresent;
|
||||
|
||||
public AfterTransactionAssertion(T persistable) {
|
||||
this.persistable = persistable;
|
||||
}
|
||||
|
||||
public void isPresent() {
|
||||
expectToBePresent = true;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.List;
|
||||
@@ -52,6 +50,7 @@ import org.springframework.data.couchbase.util.Capabilities;
|
||||
import org.springframework.data.couchbase.util.ClusterType;
|
||||
import org.springframework.data.couchbase.util.IgnoreWhen;
|
||||
import org.springframework.data.couchbase.util.JavaIntegrationTests;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.transaction.reactive.TransactionalOperator;
|
||||
|
||||
@@ -326,7 +325,6 @@ public class CouchbasePersonTransactionIntegrationTests extends JavaIntegrationT
|
||||
assertTrue(tryCount.get() > 1, "should have been more than one try. tries: " + tryCount.get());
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EventLog {
|
||||
|
||||
public EventLog() {}; // don't remove this
|
||||
@@ -346,6 +344,10 @@ public class CouchbasePersonTransactionIntegrationTests extends JavaIntegrationT
|
||||
sb.append(", action: " + action);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.springframework.data.couchbase.transactions;
|
||||
|
||||
import static com.couchbase.client.java.query.QueryScanConsistency.REQUEST_PLUS;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -45,6 +43,7 @@ import org.springframework.data.couchbase.util.Capabilities;
|
||||
import org.springframework.data.couchbase.util.ClusterType;
|
||||
import org.springframework.data.couchbase.util.IgnoreWhen;
|
||||
import org.springframework.data.couchbase.util.JavaIntegrationTests;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.couchbase.client.java.Cluster;
|
||||
@@ -217,8 +216,6 @@ public class CouchbasePersonTransactionReactiveIntegrationTests extends JavaInte
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Data
|
||||
// @AllArgsConstructor
|
||||
static class EventLog {
|
||||
public EventLog() {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user