diff --git a/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java b/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java index bc8da6a1a..65ee20c62 100644 --- a/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java +++ b/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java @@ -954,7 +954,7 @@ public R getPropertyValue(final CouchbasePersistentProperty property) { return null; } - return readValue(value, property.getTypeInformation(), parent); + return readValue(value, property.getTypeInformation(), source); } } diff --git a/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java index ff289e757..197c0b602 100644 --- a/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java @@ -40,7 +40,6 @@ 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.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 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; diff --git a/src/test/java/org/springframework/data/couchbase/util/ClusterAwareIntegrationTests.java b/src/test/java/org/springframework/data/couchbase/util/ClusterAwareIntegrationTests.java index 1301d5d03..beef6a980 100644 --- a/src/test/java/org/springframework/data/couchbase/util/ClusterAwareIntegrationTests.java +++ b/src/test/java/org/springframework/data/couchbase/util/ClusterAwareIntegrationTests.java @@ -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.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 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); + } } /**