Pass source as parent when reading subobject. (#1222)

Closes #1221.

Co-authored-by: mikereiche <michael.reiche@couchbase.com>
This commit is contained in:
Michael Reiche
2021-09-13 11:11:05 -07:00
committed by GitHub
parent da3e8e0e36
commit 345af53930
3 changed files with 21 additions and 16 deletions

View File

@@ -954,7 +954,7 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter implem
return null;
}
return readValue(value, property.getTypeInformation(), parent);
return readValue(value, property.getTypeInformation(), source);
}
}

View File

@@ -40,7 +40,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
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.Bean;
@@ -92,8 +91,6 @@ import com.couchbase.client.java.json.JsonArray;
import com.couchbase.client.java.kv.GetResult;
import com.couchbase.client.java.kv.MutationState;
import com.couchbase.client.java.kv.UpsertOptions;
import com.couchbase.client.java.manager.query.CreatePrimaryQueryIndexOptions;
import com.couchbase.client.java.manager.query.CreateQueryIndexOptions;
import com.couchbase.client.java.query.QueryOptions;
import com.couchbase.client.java.query.QueryScanConsistency;
@@ -121,18 +118,6 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
String scopeName = "_default";
String collectionName = "_default";
@BeforeEach
public void beforeEach() {
clientFactory.getCluster().queryIndexes().createPrimaryIndex(bucketName(),
CreatePrimaryQueryIndexOptions.createPrimaryQueryIndexOptions().ignoreIfExists(true));
// this is for the N1qlJoin test
List<String> fieldList = new ArrayList<>();
fieldList.add("parentId");
clientFactory.getCluster().queryIndexes().createIndex(bucketName(), "parent_idx", fieldList,
CreateQueryIndexOptions.createQueryIndexOptions().ignoreIfExists(true));
// .with("_class", "org.springframework.data.couchbase.domain.Address"));
}
@Test
void shouldSaveAndFindAll() {
Airport vie = null;

View File

@@ -15,9 +15,12 @@
*/
package org.springframework.data.couchbase.util;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -27,10 +30,14 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.data.couchbase.CouchbaseClientFactory;
import org.springframework.data.couchbase.SimpleCouchbaseClientFactory;
import com.couchbase.client.core.env.Authenticator;
import com.couchbase.client.core.env.PasswordAuthenticator;
import com.couchbase.client.core.env.SeedNode;
import com.couchbase.client.java.manager.query.CreatePrimaryQueryIndexOptions;
import com.couchbase.client.java.manager.query.CreateQueryIndexOptions;
/**
* Parent class which drives all dynamic integration tests based on the configured cluster setup.
@@ -45,6 +52,19 @@ public abstract class ClusterAwareIntegrationTests {
@BeforeAll
static void setup(TestClusterConfig config) {
testClusterConfig = config;
try (CouchbaseClientFactory couchbaseClientFactory = new SimpleCouchbaseClientFactory(connectionString(),
authenticator(), bucketName())) {
couchbaseClientFactory.getCluster().queryIndexes().createPrimaryIndex(bucketName(),
CreatePrimaryQueryIndexOptions.createPrimaryQueryIndexOptions().ignoreIfExists(true));
// this is for the N1qlJoin test
List<String> fieldList = new ArrayList<>();
fieldList.add("parentId");
couchbaseClientFactory.getCluster().queryIndexes().createIndex(bucketName(), "parent_idx", fieldList,
CreateQueryIndexOptions.createQueryIndexOptions().ignoreIfExists(true));
// .with("_class", "org.springframework.data.couchbase.domain.Address"));
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
/**