DATACOUCH-485 - Migrate tests to AssertJ.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package org.springframework.data.couchbase.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import com.couchbase.client.java.Bucket;
|
||||
import com.couchbase.client.java.Cluster;
|
||||
import com.couchbase.client.java.CouchbaseCluster;
|
||||
@@ -22,6 +20,8 @@ import org.springframework.data.couchbase.repository.config.EnableCouchbaseRepos
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* This test case demonstrates that the {@link AbstractCouchbaseDataConfiguration} can take its SDK beans
|
||||
* from a sibling {@link Configuration}.
|
||||
@@ -97,13 +97,13 @@ public class AbstractCouchbaseDataConfigurationIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testInjectedBucketIsFromAdditionalConfig() {
|
||||
assertSame(client, SdkConfig.bucket);
|
||||
assertThat(SdkConfig.bucket).isSameAs(client);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateIsUsable() {
|
||||
String key = "simpleConfigTest";
|
||||
assertNotNull(repository);
|
||||
assertThat(repository).isNotNull();
|
||||
|
||||
Item item = new Item();
|
||||
item.id = key;
|
||||
@@ -112,9 +112,9 @@ public class AbstractCouchbaseDataConfigurationIntegrationTests {
|
||||
repository.save(item);
|
||||
JsonDocument testDoc = client.get(key);
|
||||
|
||||
assertNotNull(testDoc);
|
||||
assertNotNull(testDoc.content());
|
||||
assertEquals(item.value, testDoc.content().getString("value"));
|
||||
assertThat(testDoc).isNotNull();
|
||||
assertThat(testDoc.content()).isNotNull();
|
||||
assertThat(testDoc.content().getString("value")).isEqualTo(item.value);
|
||||
}
|
||||
|
||||
private static class Item {
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -31,8 +27,9 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
public class CouchbaseBucketParserTest {
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CouchbaseBucketParserTest {
|
||||
|
||||
private static DefaultListableBeanFactory factory;
|
||||
|
||||
@@ -52,87 +49,87 @@ public class CouchbaseBucketParserTest {
|
||||
public void testDefaultBucketNoCluster() {
|
||||
BeanDefinition def = factory.getBeanDefinition("bucketDefaultNoCluster");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(1)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(1);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(0, Object.class);
|
||||
assertThat(holder.getValue(), is(instanceOf(RuntimeBeanReference.class)));
|
||||
assertThat(holder.getValue()).isInstanceOf(RuntimeBeanReference.class);
|
||||
|
||||
RuntimeBeanReference clusterRef = (RuntimeBeanReference) holder.getValue();
|
||||
|
||||
assertThat(clusterRef.getBeanName(), is(equalTo(BeanNames.COUCHBASE_CLUSTER)));
|
||||
assertThat(clusterRef.getBeanName()).isEqualTo(BeanNames.COUCHBASE_CLUSTER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultBucket() throws Exception {
|
||||
BeanDefinition def = factory.getBeanDefinition("bucketDefault");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(1)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(1);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(0, Object.class);
|
||||
assertThat(holder.getValue(), is(instanceOf(RuntimeBeanReference.class)));
|
||||
assertThat(holder.getValue()).isInstanceOf(RuntimeBeanReference.class);
|
||||
|
||||
RuntimeBeanReference clusterRef = (RuntimeBeanReference) holder.getValue();
|
||||
|
||||
assertThat(clusterRef.getBeanName(), is(equalTo("clusterDefault")));
|
||||
assertThat(clusterRef.getBeanName()).isEqualTo("clusterDefault");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBucketWithName() throws Exception {
|
||||
BeanDefinition def = factory.getBeanDefinition("bucketWithName");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(2)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(2);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(0, Object.class);
|
||||
assertThat(holder.getValue(), is(instanceOf(RuntimeBeanReference.class)));
|
||||
assertThat(holder.getValue()).isInstanceOf(RuntimeBeanReference.class);
|
||||
|
||||
RuntimeBeanReference clusterRef = (RuntimeBeanReference) holder.getValue();
|
||||
assertThat(clusterRef.getBeanName(), is(equalTo("clusterDefault")));
|
||||
assertThat(clusterRef.getBeanName()).isEqualTo("clusterDefault");
|
||||
|
||||
ConstructorArgumentValues.ValueHolder nameHolder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(1, Object.class);
|
||||
assertThat(nameHolder.getValue(), is(instanceOf(String.class)));
|
||||
assertThat(nameHolder.getValue().toString(), is((equalTo("toto"))));
|
||||
assertThat(nameHolder.getValue()).isInstanceOf(String.class);
|
||||
assertThat(nameHolder.getValue()).hasToString("toto");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBucketWithNameAndPassword() throws Exception {
|
||||
BeanDefinition def = factory.getBeanDefinition("bucketWithNameAndPassword");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(4)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(4);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(0, Object.class);
|
||||
assertThat(holder.getValue(), is(instanceOf(RuntimeBeanReference.class)));
|
||||
assertThat(holder.getValue()).isInstanceOf(RuntimeBeanReference.class);
|
||||
|
||||
RuntimeBeanReference clusterRef = (RuntimeBeanReference) holder.getValue();
|
||||
assertThat(clusterRef.getBeanName(), is(equalTo("clusterDefault")));
|
||||
assertThat(clusterRef.getBeanName()).isEqualTo("clusterDefault");
|
||||
|
||||
ConstructorArgumentValues.ValueHolder nameHolder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(1, Object.class);
|
||||
assertThat(nameHolder.getValue(), is(instanceOf(String.class)));
|
||||
assertThat(nameHolder.getValue().toString(), is((equalTo("test"))));
|
||||
assertThat(nameHolder.getValue()).isInstanceOf(String.class);
|
||||
assertThat(nameHolder.getValue()).hasToString("test");
|
||||
|
||||
|
||||
ConstructorArgumentValues.ValueHolder usernameHolder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(2, Object.class);
|
||||
assertThat(usernameHolder.getValue(), is(instanceOf(String.class)));
|
||||
assertThat(usernameHolder.getValue().toString(), is((equalTo("testuser"))));
|
||||
assertThat(usernameHolder.getValue()).isInstanceOf(String.class);
|
||||
assertThat(usernameHolder.getValue()).hasToString("testuser");
|
||||
|
||||
|
||||
ConstructorArgumentValues.ValueHolder passwordHolder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(3, Object.class);
|
||||
assertThat(passwordHolder.getValue(), is(instanceOf(String.class)));
|
||||
assertThat(passwordHolder.getValue().toString(), is((equalTo("123"))));
|
||||
assertThat(passwordHolder.getValue()).isInstanceOf(String.class);
|
||||
assertThat(passwordHolder.getValue()).hasToString("123");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
@@ -36,6 +32,8 @@ import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CouchbaseClusterParserTest {
|
||||
|
||||
|
||||
@@ -57,98 +55,102 @@ public class CouchbaseClusterParserTest {
|
||||
public void testClusterWithoutSpecificEnv() {
|
||||
BeanDefinition def = factory.getBeanDefinition("clusterDefault");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(1)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def.getFactoryMethodName(), is(equalTo("create")));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(1);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
assertThat(def.getFactoryMethodName()).isEqualTo("create");
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(0, CouchbaseEnvironment.class);
|
||||
|
||||
assertThat(holder.getValue(), instanceOf(RuntimeBeanReference.class));
|
||||
assertThat(holder.getValue()).isInstanceOf(RuntimeBeanReference.class);
|
||||
RuntimeBeanReference envRef = (RuntimeBeanReference) holder.getValue();
|
||||
|
||||
assertThat(envRef.getBeanName(), is(equalTo("couchbaseEnv")));
|
||||
assertThat(envRef.getBeanName()).isEqualTo("couchbaseEnv");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClusterWithNodes() {
|
||||
BeanDefinition def = factory.getBeanDefinition("clusterWithNodes");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(2)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def.getFactoryMethodName(), is(equalTo("create")));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(2);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
assertThat(def.getFactoryMethodName()).isEqualTo("create");
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(1, List.class);
|
||||
assertThat(holder.getValue(), is(instanceOf(List.class)));
|
||||
assertThat(holder.getValue()).isInstanceOf(List.class);
|
||||
List nodes = (List<String>) holder.getValue();
|
||||
|
||||
assertThat(nodes.size(), is(equalTo(2)));
|
||||
assertThat((String) nodes.get(0), is(equalTo("192.1.2.3")));
|
||||
assertThat((String) nodes.get(1), is(equalTo("192.4.5.6")));
|
||||
assertThat(nodes.size()).isEqualTo(2);
|
||||
assertThat((String) nodes.get(0)).isEqualTo("192.1.2.3");
|
||||
assertThat((String) nodes.get(1)).isEqualTo("192.4.5.6");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClusterWithEnvInline() {
|
||||
BeanDefinition def = factory.getBeanDefinition("clusterWithEnvInline");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(1)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(1);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(0, CouchbaseEnvironment.class);
|
||||
GenericBeanDefinition envDef = (GenericBeanDefinition) holder.getValue();
|
||||
|
||||
assertThat(envDef.getBeanClassName(), is(equalTo(CouchbaseEnvironmentFactoryBean.class.getName())));
|
||||
assertThat("unexpected attribute", envDef.getPropertyValues().contains("managementTimeout"));
|
||||
assertThat(envDef.getBeanClassName())
|
||||
.isEqualTo(CouchbaseEnvironmentFactoryBean.class.getName());
|
||||
assertThat(envDef.getPropertyValues().contains("managementTimeout"))
|
||||
.as("unexpected attribute").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClusterWithEnvRef() {
|
||||
BeanDefinition def = factory.getBeanDefinition("clusterWithEnvRef");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(1)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(1);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holder = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(0, CouchbaseEnvironment.class);
|
||||
|
||||
assertThat(holder.getValue(), instanceOf(RuntimeBeanReference.class));
|
||||
assertThat(holder.getValue()).isInstanceOf(RuntimeBeanReference.class);
|
||||
RuntimeBeanReference envRef = (RuntimeBeanReference) holder.getValue();
|
||||
|
||||
assertThat(envRef.getBeanName(), is(equalTo("someEnv")));
|
||||
assertThat(envRef.getBeanName()).isEqualTo("someEnv");
|
||||
}
|
||||
@Test
|
||||
public void testClusterConfigurationPrecedence() {
|
||||
BeanDefinition def = factory.getBeanDefinition("clusterWithAll");
|
||||
|
||||
assertThat(def, is(notNullValue()));
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount(), is(equalTo(2)));
|
||||
assertThat(def.getPropertyValues().size(), is(equalTo(0)));
|
||||
assertThat(def.getFactoryMethodName(), is(equalTo("create")));
|
||||
assertThat(def).isNotNull();
|
||||
assertThat(def.getConstructorArgumentValues().getArgumentCount()).isEqualTo(2);
|
||||
assertThat(def.getPropertyValues().size()).isEqualTo(0);
|
||||
assertThat(def.getFactoryMethodName()).isEqualTo("create");
|
||||
|
||||
assertThat(def.getConstructorArgumentValues().getIndexedArgumentValues().get(0).getValue(),
|
||||
instanceOf(GenericBeanDefinition.class));
|
||||
assertThat(def.getConstructorArgumentValues().getIndexedArgumentValues().get(1).getValue(),
|
||||
instanceOf(List.class));
|
||||
assertThat(def.getConstructorArgumentValues().getIndexedArgumentValues().get(0)
|
||||
.getValue()).isInstanceOf(GenericBeanDefinition.class);
|
||||
assertThat(def.getConstructorArgumentValues().getIndexedArgumentValues().get(1)
|
||||
.getValue()).isInstanceOf(List.class);
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holderEnv = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(0, CouchbaseEnvironment.class);
|
||||
GenericBeanDefinition envDef = (GenericBeanDefinition) holderEnv.getValue();
|
||||
|
||||
assertThat(envDef.getBeanClassName(), is(equalTo(CouchbaseEnvironmentFactoryBean.class.getName())));
|
||||
assertThat("unexpected attribute", envDef.getPropertyValues().contains("autoreleaseAfter"));
|
||||
assertThat(envDef.getBeanClassName())
|
||||
.isEqualTo(CouchbaseEnvironmentFactoryBean.class.getName());
|
||||
assertThat(envDef.getPropertyValues().contains("autoreleaseAfter"))
|
||||
.as("unexpected attribute").isTrue();
|
||||
|
||||
ConstructorArgumentValues.ValueHolder holderNodes = def.getConstructorArgumentValues()
|
||||
.getArgumentValue(1, List.class);
|
||||
List nodes = (List<String>) holderNodes.getValue();
|
||||
|
||||
assertThat(nodes.size(), is(equalTo(2)));
|
||||
assertThat((String) nodes.get(0), is(equalTo("2.2.2.2")));
|
||||
assertThat((String) nodes.get(1), is(equalTo("4.4.4.4")));
|
||||
assertThat(nodes.size()).isEqualTo(2);
|
||||
assertThat((String) nodes.get(0)).isEqualTo("2.2.2.2");
|
||||
assertThat((String) nodes.get(1)).isEqualTo("4.4.4.4");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.springframework.data.couchbase.config;
|
||||
|
||||
import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -9,6 +8,8 @@ import org.springframework.data.couchbase.ContainerResourceRunner;
|
||||
import org.springframework.data.couchbase.IntegrationTestNoShutdownApplicationConfig;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Simple test to make sure that environment is not shutdown if not life cycle managed by Spring.
|
||||
*/
|
||||
@@ -21,6 +22,6 @@ public class CouchbaseEnvironmentNoShutdownProxyIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testEnvironmentShutDown() {
|
||||
Assert.assertEquals("Should return false", false, environment.shutdown());
|
||||
assertThat(environment.shutdown()).as("Should return false").isEqualTo(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
@@ -33,6 +30,8 @@ import com.couchbase.client.core.retry.FailFastRetryStrategy;
|
||||
import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CouchbaseEnvironmentParserTest {
|
||||
|
||||
private static GenericApplicationContext context;
|
||||
@@ -50,14 +49,14 @@ public class CouchbaseEnvironmentParserTest {
|
||||
public void testParsingRetryStrategyFailFast() throws Exception {
|
||||
CouchbaseEnvironment env = context.getBean("envWithFailFast", CouchbaseEnvironment.class);
|
||||
|
||||
assertThat(env.retryStrategy(), is(instanceOf(FailFastRetryStrategy.class)));
|
||||
assertThat(env.retryStrategy()).isInstanceOf(FailFastRetryStrategy.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParsingRetryStrategyBestEffort() throws Exception {
|
||||
CouchbaseEnvironment env = context.getBean("envWithBestEffort", CouchbaseEnvironment.class);
|
||||
|
||||
assertThat(env.retryStrategy(), is(instanceOf(BestEffortRetryStrategy.class)));
|
||||
assertThat(env.retryStrategy()).isInstanceOf(BestEffortRetryStrategy.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -65,47 +64,55 @@ public class CouchbaseEnvironmentParserTest {
|
||||
CouchbaseEnvironment env = context.getBean("envWithNoDefault", CouchbaseEnvironment.class);
|
||||
CouchbaseEnvironment defaultEnv = DefaultCouchbaseEnvironment.create();
|
||||
|
||||
assertThat(env, is(instanceOf(DefaultCouchbaseEnvironment.class)));
|
||||
assertThat(env).isInstanceOf(DefaultCouchbaseEnvironment.class);
|
||||
|
||||
assertThat(env.managementTimeout(), is(equalTo(1L)));
|
||||
assertThat(env.queryTimeout(), is(equalTo(2L)));
|
||||
assertThat(env.viewTimeout(), is(equalTo(3L)));
|
||||
assertThat(env.kvTimeout(), is(equalTo(4L)));
|
||||
assertThat(env.connectTimeout(), is(equalTo(5L)));
|
||||
assertThat(env.disconnectTimeout(), is(equalTo(6L)));
|
||||
assertThat(env.dnsSrvEnabled(), allOf(equalTo(true), not(defaultEnv.dnsSrvEnabled())));
|
||||
assertThat(env.managementTimeout()).isEqualTo(1L);
|
||||
assertThat(env.queryTimeout()).isEqualTo(2L);
|
||||
assertThat(env.viewTimeout()).isEqualTo(3L);
|
||||
assertThat(env.kvTimeout()).isEqualTo(4L);
|
||||
assertThat(env.connectTimeout()).isEqualTo(5L);
|
||||
assertThat(env.disconnectTimeout()).isEqualTo(6L);
|
||||
assertThat(env.dnsSrvEnabled()).isTrue().isNotEqualTo(defaultEnv.dnsSrvEnabled());
|
||||
|
||||
assertThat(env.sslEnabled(), allOf(equalTo(true), not(defaultEnv.sslEnabled())));
|
||||
assertThat(env.sslKeystoreFile(), is(equalTo("test")));
|
||||
assertThat(env.sslKeystorePassword(), is(equalTo("test")));
|
||||
assertThat(env.bootstrapHttpEnabled(), allOf(equalTo(false), not(defaultEnv.bootstrapHttpEnabled())));
|
||||
assertThat(env.bootstrapCarrierEnabled(), allOf(equalTo(false), not(defaultEnv.bootstrapCarrierEnabled())));
|
||||
assertThat(env.bootstrapHttpDirectPort(), is(equalTo(8)));
|
||||
assertThat(env.bootstrapHttpSslPort(), is(equalTo(9)));
|
||||
assertThat(env.bootstrapCarrierDirectPort(), is(equalTo(10)));
|
||||
assertThat(env.bootstrapCarrierSslPort(), is(equalTo(11)));
|
||||
assertThat(env.ioPoolSize(), is(equalTo(12)));
|
||||
assertThat(env.computationPoolSize(), is(equalTo(13)));
|
||||
assertThat(env.responseBufferSize(), is(equalTo(14)));
|
||||
assertThat(env.requestBufferSize(), is(equalTo(15)));
|
||||
assertThat(env.kvEndpoints(), is(equalTo(16)));
|
||||
assertThat(env.viewEndpoints(), is(equalTo(17)));
|
||||
assertThat(env.queryEndpoints(), is(equalTo(18)));
|
||||
assertThat(env.retryStrategy(), is(instanceOf(FailFastRetryStrategy.class)));
|
||||
assertThat(env.maxRequestLifetime(), is(equalTo(19L)));
|
||||
assertThat(env.keepAliveInterval(), is(equalTo(20L)));
|
||||
assertThat(env.autoreleaseAfter(), is(equalTo(21L)));
|
||||
assertThat(env.bufferPoolingEnabled(), allOf(equalTo(false), not(defaultEnv.bufferPoolingEnabled())));
|
||||
assertThat(env.tcpNodelayEnabled(), allOf(equalTo(false), not(defaultEnv.tcpNodelayEnabled())));
|
||||
assertThat(env.mutationTokensEnabled(), allOf(equalTo(true), not(defaultEnv.mutationTokensEnabled())));
|
||||
assertThat(env.analyticsTimeout(), is(equalTo(30L)));
|
||||
assertThat(env.configPollInterval(), is(equalTo(50L)));
|
||||
assertThat(env.configPollFloorInterval(), is(equalTo(30L)));
|
||||
assertThat(env.operationTracingEnabled(), allOf(equalTo(false), not(defaultEnv.operationTracingEnabled())));
|
||||
assertThat(env.operationTracingServerDurationEnabled(), allOf(equalTo(false), not(defaultEnv.operationTracingServerDurationEnabled())));
|
||||
assertThat(env.orphanResponseReportingEnabled(), allOf(equalTo(false), not(defaultEnv.orphanResponseReportingEnabled())));
|
||||
assertThat(env.compressionMinSize(), is(equalTo(100)));
|
||||
assertThat(env.compressionMinRatio(), is(equalTo(0.90)));
|
||||
assertThat(env.sslEnabled()).isTrue().isNotEqualTo(defaultEnv.sslEnabled());
|
||||
assertThat(env.sslKeystoreFile()).isEqualTo("test");
|
||||
assertThat(env.sslKeystorePassword()).isEqualTo("test");
|
||||
assertThat(env.bootstrapHttpEnabled()).isFalse()
|
||||
.isNotEqualTo(defaultEnv.bootstrapHttpEnabled());
|
||||
assertThat(env.bootstrapCarrierEnabled()).isFalse()
|
||||
.isNotEqualTo(defaultEnv.bootstrapCarrierEnabled());
|
||||
assertThat(env.bootstrapHttpDirectPort()).isEqualTo(8);
|
||||
assertThat(env.bootstrapHttpSslPort()).isEqualTo(9);
|
||||
assertThat(env.bootstrapCarrierDirectPort()).isEqualTo(10);
|
||||
assertThat(env.bootstrapCarrierSslPort()).isEqualTo(11);
|
||||
assertThat(env.ioPoolSize()).isEqualTo(12);
|
||||
assertThat(env.computationPoolSize()).isEqualTo(13);
|
||||
assertThat(env.responseBufferSize()).isEqualTo(14);
|
||||
assertThat(env.requestBufferSize()).isEqualTo(15);
|
||||
assertThat(env.kvEndpoints()).isEqualTo(16);
|
||||
assertThat(env.viewEndpoints()).isEqualTo(17);
|
||||
assertThat(env.queryEndpoints()).isEqualTo(18);
|
||||
assertThat(env.retryStrategy()).isInstanceOf(FailFastRetryStrategy.class);
|
||||
assertThat(env.maxRequestLifetime()).isEqualTo(19L);
|
||||
assertThat(env.keepAliveInterval()).isEqualTo(20L);
|
||||
assertThat(env.autoreleaseAfter()).isEqualTo(21L);
|
||||
assertThat(env.bufferPoolingEnabled()).isFalse()
|
||||
.isNotEqualTo(defaultEnv.bufferPoolingEnabled());
|
||||
assertThat(env.tcpNodelayEnabled()).isFalse()
|
||||
.isNotEqualTo(defaultEnv.tcpNodelayEnabled());
|
||||
assertThat(env.mutationTokensEnabled()).isTrue()
|
||||
.isNotEqualTo(defaultEnv.mutationTokensEnabled());
|
||||
assertThat(env.analyticsTimeout()).isEqualTo(30L);
|
||||
assertThat(env.configPollInterval()).isEqualTo(50L);
|
||||
assertThat(env.configPollFloorInterval()).isEqualTo(30L);
|
||||
assertThat(env.operationTracingEnabled()).isFalse()
|
||||
.isNotEqualTo(defaultEnv.operationTracingEnabled());
|
||||
assertThat(env.operationTracingServerDurationEnabled()).isFalse()
|
||||
.isNotEqualTo(defaultEnv.operationTracingServerDurationEnabled());
|
||||
assertThat(env.orphanResponseReportingEnabled()).isFalse()
|
||||
.isNotEqualTo(defaultEnv.orphanResponseReportingEnabled());
|
||||
assertThat(env.compressionMinSize()).isEqualTo(100);
|
||||
assertThat(env.compressionMinRatio()).isEqualTo(0.90);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
@@ -30,6 +27,8 @@ import com.couchbase.client.core.env.DefaultCoreEnvironment;
|
||||
import com.couchbase.client.java.env.CouchbaseEnvironment;
|
||||
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Simon Bland
|
||||
*/
|
||||
@@ -53,7 +52,7 @@ public class CouchbaseSingleEnvironmentParserTest {
|
||||
|
||||
int instanceCounterAfter = DefaultCoreEnvironment.instanceCounter();
|
||||
|
||||
assertThat(env, is(instanceOf(DefaultCouchbaseEnvironment.class)));
|
||||
assertThat(instanceCounterAfter, is(instanceCounterBefore + 1));
|
||||
assertThat(env).isInstanceOf(DefaultCouchbaseEnvironment.class);
|
||||
assertThat(instanceCounterAfter).isEqualTo(instanceCounterBefore + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import com.couchbase.client.java.document.JsonDocument;
|
||||
import com.couchbase.client.java.document.json.JsonObject;
|
||||
import org.junit.Before;
|
||||
@@ -36,6 +34,8 @@ import org.springframework.data.couchbase.core.query.Consistency;
|
||||
import org.springframework.data.couchbase.repository.User;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Michael Nitschinger
|
||||
* @author Simon Baslé
|
||||
@@ -58,7 +58,7 @@ public class CouchbaseTemplateParserIntegrationTests {
|
||||
reader.loadBeanDefinitions(new ClassPathResource("configurations/couchbase-template-bean.xml"));
|
||||
|
||||
BeanDefinition definition = factory.getBeanDefinition(BeanNames.COUCHBASE_TEMPLATE);
|
||||
assertEquals(2, definition.getConstructorArgumentValues().getArgumentCount());
|
||||
assertThat(definition.getConstructorArgumentValues().getArgumentCount()).isEqualTo(2);
|
||||
|
||||
factory.getBean(BeanNames.COUCHBASE_TEMPLATE);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class CouchbaseTemplateParserIntegrationTests {
|
||||
reader.loadBeanDefinitions(new ClassPathResource("configurations/couchbase-template-with-translation-service-bean.xml"));
|
||||
|
||||
BeanDefinition definition = factory.getBeanDefinition(BeanNames.COUCHBASE_TEMPLATE);
|
||||
assertEquals(3, definition.getConstructorArgumentValues().getArgumentCount());
|
||||
assertThat(definition.getConstructorArgumentValues().getArgumentCount()).isEqualTo(3);
|
||||
|
||||
factory.getBean(BeanNames.COUCHBASE_TEMPLATE);
|
||||
}
|
||||
@@ -92,20 +92,21 @@ public class CouchbaseTemplateParserIntegrationTests {
|
||||
reader.loadBeanDefinitions(new ClassPathResource("configurations/couchbase-typekey.xml"));
|
||||
CouchbaseTemplate template = factory.getBean(BeanNames.COUCHBASE_TEMPLATE, CouchbaseTemplate.class);
|
||||
|
||||
assertTrue(template.getConverter() instanceof MappingCouchbaseConverter);
|
||||
assertThat(template.getConverter() instanceof MappingCouchbaseConverter).isTrue();
|
||||
MappingCouchbaseConverter converter = ((MappingCouchbaseConverter) template.getConverter());
|
||||
|
||||
assertEquals("javaXmlClass", converter.getTypeKey());
|
||||
assertThat(converter.getTypeKey()).isEqualTo("javaXmlClass");
|
||||
|
||||
User u = new User("specialSaveUser", "John Locke", 46);
|
||||
template.save(u);
|
||||
JsonDocument uJsonDoc = template.getCouchbaseBucket().get("specialSaveUser");
|
||||
template.getCouchbaseBucket().remove("specialSaveUser");
|
||||
assertNotNull(uJsonDoc);
|
||||
assertThat(uJsonDoc).isNotNull();
|
||||
JsonObject uJson = uJsonDoc.content();
|
||||
assertNull(uJson.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT));
|
||||
assertEquals("org.springframework.data.couchbase.repository.User", uJson.getString("javaXmlClass"));
|
||||
assertEquals("John Locke", uJson.getString("username"));
|
||||
assertThat(uJson.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT)).isNull();
|
||||
assertThat(uJson.getString("javaXmlClass"))
|
||||
.isEqualTo("org.springframework.data.couchbase.repository.User");
|
||||
assertThat(uJson.getString("username")).isEqualTo("John Locke");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,8 +117,10 @@ public class CouchbaseTemplateParserIntegrationTests {
|
||||
reader.loadBeanDefinitions(new ClassPathResource("configurations/couchbase-consistency.xml"));
|
||||
CouchbaseTemplate template = factory.getBean("template", CouchbaseTemplate.class);
|
||||
|
||||
assertEquals(Consistency.EVENTUALLY_CONSISTENT, template.getDefaultConsistency());
|
||||
assertNotEquals(Consistency.DEFAULT_CONSISTENCY, template.getDefaultConsistency());
|
||||
assertThat(template.getDefaultConsistency())
|
||||
.isEqualTo(Consistency.EVENTUALLY_CONSISTENT);
|
||||
assertThat(template.getDefaultConsistency())
|
||||
.isNotEqualTo(Consistency.DEFAULT_CONSISTENCY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +131,8 @@ public class CouchbaseTemplateParserIntegrationTests {
|
||||
reader.loadBeanDefinitions(new ClassPathResource("configurations/couchbase-consistency.xml"));
|
||||
CouchbaseTemplate template = factory.getBean("templateBad", CouchbaseTemplate.class);
|
||||
|
||||
assertEquals(Consistency.DEFAULT_CONSISTENCY, template.getDefaultConsistency());
|
||||
assertThat(template.getDefaultConsistency())
|
||||
.isEqualTo(Consistency.DEFAULT_CONSISTENCY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,6 +141,7 @@ public class CouchbaseTemplateParserIntegrationTests {
|
||||
reader.loadBeanDefinitions(new ClassPathResource("configurations/couchbase-template-with-translation-service-bean.xml"));
|
||||
CouchbaseTemplate template = factory.getBean(BeanNames.COUCHBASE_TEMPLATE, CouchbaseTemplate.class);
|
||||
|
||||
assertEquals(Consistency.DEFAULT_CONSISTENCY, template.getDefaultConsistency());
|
||||
assertThat(template.getDefaultConsistency())
|
||||
.isEqualTo(Consistency.DEFAULT_CONSISTENCY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.data.couchbase.core;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.couchbase.core.mapping.id.GenerationStrategy.*;
|
||||
|
||||
import com.couchbase.client.java.Bucket;
|
||||
@@ -52,21 +52,25 @@ public class CouchbaseTemplateIdGenerationIntegrationTests {
|
||||
String generatedId = template.getGeneratedId(simpleClass);
|
||||
|
||||
removeIfExist(generatedId);
|
||||
assertEquals("Id generation should be correct", generatedId,
|
||||
"prefix1::prefix2::0::1::2.0::3.0::4::Simple::Nested{value:simple}::suffix1::suffix2");
|
||||
assertThat("prefix1::prefix2::0::1::2.0::3.0::4::Simple::Nested{value:simple}::suffix1::suffix2")
|
||||
.as("Id generation should be correct").isEqualTo(generatedId);
|
||||
template.insert(simpleClass);
|
||||
assertEquals("Exists after insert", true, template.exists(generatedId));
|
||||
assertThat(template.exists(generatedId)).as("Exists after insert")
|
||||
.isEqualTo(true);
|
||||
simpleClass.value = "modified";
|
||||
template.save(simpleClass);
|
||||
SimpleClassWithGeneratedIdValueUsingAttributes modifiedClass = template.findById(generatedId,
|
||||
SimpleClassWithGeneratedIdValueUsingAttributes.class);
|
||||
assertEquals("Get after save id should be correct", generatedId, modifiedClass.id);
|
||||
assertThat(modifiedClass.id).as("Get after save id should be correct")
|
||||
.isEqualTo(generatedId);
|
||||
template.update(simpleClass);
|
||||
SimpleClassWithGeneratedIdValueUsingAttributes updatedClass = template.findById(generatedId,
|
||||
SimpleClassWithGeneratedIdValueUsingAttributes.class);
|
||||
assertEquals("Get after update id should be correct", generatedId, updatedClass.id);
|
||||
assertThat(updatedClass.id).as("Get after update id should be correct")
|
||||
.isEqualTo(generatedId);
|
||||
template.remove(generatedId);
|
||||
assertEquals("Exists after remove", false, template.exists(generatedId));
|
||||
assertThat(template.exists(generatedId)).as("Exists after remove")
|
||||
.isEqualTo(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -75,9 +79,10 @@ public class CouchbaseTemplateIdGenerationIntegrationTests {
|
||||
String generatedId = template.getGeneratedId(simpleClass);
|
||||
simpleClass.id = generatedId;
|
||||
template.insert(simpleClass);
|
||||
assertEquals("Should not regenerate id", generatedId, simpleClass.id);
|
||||
assertThat(simpleClass.id).as("Should not regenerate id").isEqualTo(generatedId);
|
||||
template.remove(generatedId);
|
||||
assertEquals("Exists after remove", false, template.exists(generatedId));
|
||||
assertThat(template.exists(generatedId)).as("Exists after remove")
|
||||
.isEqualTo(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,9 +18,7 @@ package org.springframework.data.couchbase.core;
|
||||
|
||||
import static com.couchbase.client.java.query.Select.select;
|
||||
import static com.couchbase.client.java.query.dsl.Expression.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -65,7 +63,8 @@ import org.springframework.test.context.TestExecutionListeners;
|
||||
/**
|
||||
* @author Michael Nitschinger
|
||||
* @author Simon Baslé
|
||||
* @author Anastasiia Smirnova */
|
||||
* @author Anastasiia Smirnova
|
||||
*/
|
||||
@RunWith(ContainerResourceRunner.class)
|
||||
@ContextConfiguration(classes = IntegrationTestApplicationConfig.class)
|
||||
@TestExecutionListeners(CouchbaseTemplateQueryListener.class)
|
||||
@@ -101,16 +100,17 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
|
||||
template.save(beer);
|
||||
RawJsonDocument resultDoc = client.get(id, RawJsonDocument.class);
|
||||
assertNotNull(resultDoc);
|
||||
assertThat(resultDoc).isNotNull();
|
||||
String result = resultDoc.content();
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
Map<String, Object> resultConv = MAPPER.readValue(result, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
assertNotNull(resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT));
|
||||
assertNull(resultConv.get("javaClass"));
|
||||
assertEquals("org.springframework.data.couchbase.core.Beer", resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT));
|
||||
assertEquals(false, resultConv.get("is_active"));
|
||||
assertEquals("The Awesome Stout", resultConv.get("name"));
|
||||
assertThat(resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT)).isNotNull();
|
||||
assertThat(resultConv.get("javaClass")).isNull();
|
||||
assertThat(resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT))
|
||||
.isEqualTo("org.springframework.data.couchbase.core.Beer");
|
||||
assertThat(resultConv.get("is_active")).isEqualTo(false);
|
||||
assertThat(resultConv.get("name")).isEqualTo("The Awesome Stout");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,9 +118,9 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
String id = "simple-doc-with-expiry";
|
||||
DocumentWithExpiry doc = new DocumentWithExpiry(id);
|
||||
template.save(doc);
|
||||
assertNotNull(client.get(id));
|
||||
assertThat(client.get(id)).isNotNull();
|
||||
Thread.sleep(3000);
|
||||
assertNull(client.get(id));
|
||||
assertThat(client.get(id)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,11 +131,11 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
SimplePerson doc = new SimplePerson(id, "Mr. A");
|
||||
template.insert(doc);
|
||||
RawJsonDocument resultDoc = client.get(id, RawJsonDocument.class);
|
||||
assertNotNull(resultDoc);
|
||||
assertThat(resultDoc).isNotNull();
|
||||
String result = resultDoc.content();
|
||||
|
||||
Map<String, String> resultConv = MAPPER.readValue(result, new TypeReference<Map<String, String>>() {});
|
||||
assertEquals("Mr. A", resultConv.get("name"));
|
||||
assertThat(resultConv.get("name")).isEqualTo("Mr. A");
|
||||
|
||||
doc = new SimplePerson(id, "Mr. B");
|
||||
try {
|
||||
@@ -145,11 +145,11 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
}
|
||||
|
||||
resultDoc = client.get(id, RawJsonDocument.class);
|
||||
assertNotNull(resultDoc);
|
||||
assertThat(resultDoc).isNotNull();
|
||||
result = resultDoc.content();
|
||||
|
||||
resultConv = MAPPER.readValue(result, new TypeReference<Map<String, String>>() {});
|
||||
assertEquals("Mr. A", resultConv.get("name"));
|
||||
assertThat(resultConv.get("name")).isEqualTo("Mr. A");
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
String id = "update-does-not-insert";
|
||||
SimplePerson doc = new SimplePerson(id, "Nice Guy");
|
||||
template.update(doc);
|
||||
assertNull(client.get(id));
|
||||
assertThat(client.get(id)).isNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -169,11 +169,11 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
|
||||
template.save(beer);
|
||||
Object result = client.get(id);
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
|
||||
template.remove(beer);
|
||||
result = client.get(id);
|
||||
assertNull(result);
|
||||
assertThat(result).isNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -194,14 +194,14 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
ComplexPerson complex = new ComplexPerson(id, names, votes, info1, info2);
|
||||
|
||||
template.save(complex);
|
||||
assertNotNull(client.get(id));
|
||||
assertThat(client.get(id)).isNotNull();
|
||||
|
||||
ComplexPerson response = template.findById(id, ComplexPerson.class);
|
||||
assertEquals(names, response.getFirstnames());
|
||||
assertEquals(votes, response.getVotes());
|
||||
assertEquals(id, response.getId());
|
||||
assertEquals(info1, response.getInfo1());
|
||||
assertEquals(info2, response.getInfo2());
|
||||
assertThat(response.getFirstnames()).isEqualTo(names);
|
||||
assertThat(response.getVotes()).isEqualTo(votes);
|
||||
assertThat(response.getId()).isEqualTo(id);
|
||||
assertThat(response.getInfo1()).isEqualTo(info1);
|
||||
assertThat(response.getInfo2()).isEqualTo(info2);
|
||||
}
|
||||
|
||||
|
||||
@@ -215,10 +215,10 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
|
||||
Beer found = template.findById(id, Beer.class);
|
||||
|
||||
assertNotNull(found);
|
||||
assertEquals(id, found.getId());
|
||||
assertEquals(name, found.getName());
|
||||
assertEquals(active, found.getActive());
|
||||
assertThat(found).isNotNull();
|
||||
assertThat(found.getId()).isEqualTo(id);
|
||||
assertThat(found.getName()).isEqualTo(name);
|
||||
assertThat(found.getActive()).isEqualTo(active);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -227,12 +227,12 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
query.stale(Stale.FALSE);
|
||||
|
||||
final List<Beer> beers = template.findByView(query, Beer.class);
|
||||
assertTrue(beers.size() > 0);
|
||||
assertThat(beers.size() > 0).isTrue();
|
||||
|
||||
for (Beer beer : beers) {
|
||||
assertNotNull(beer.getId());
|
||||
assertNotNull(beer.getName());
|
||||
assertNotNull(beer.getActive());
|
||||
assertThat(beer.getId()).isNotNull();
|
||||
assertThat(beer.getName()).isNotNull();
|
||||
assertThat(beer.getActive()).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,9 +242,10 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
.where(x("name").isNotMissing()));
|
||||
|
||||
N1qlQueryResult queryResult = template.queryN1QL(query);
|
||||
assertNotNull(queryResult);
|
||||
assertTrue(queryResult.errors().toString(), queryResult.finalSuccess());
|
||||
assertFalse(queryResult.allRows().isEmpty());
|
||||
assertThat(queryResult).isNotNull();
|
||||
assertThat(queryResult.finalSuccess()).as(queryResult.errors().toString())
|
||||
.isTrue();
|
||||
assertThat(queryResult.allRows().isEmpty()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -261,10 +262,10 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
N1qlParams.build().consistency(ScanConsistency.REQUEST_PLUS));
|
||||
|
||||
List<Fragment> fragments = template.findByN1QLProjection(query, Fragment.class);
|
||||
assertNotNull(fragments);
|
||||
assertFalse(fragments.isEmpty());
|
||||
assertEquals(1, fragments.size());
|
||||
assertEquals("test2", fragments.get(0).value);
|
||||
assertThat(fragments).isNotNull();
|
||||
assertThat(fragments.isEmpty()).isFalse();
|
||||
assertThat(fragments.size()).isEqualTo(1);
|
||||
assertThat(fragments.get(0).value).isEqualTo("test2");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,15 +278,15 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
|
||||
template.save(new SimpleWithLongAndInt("simpleWithLong:simple", longValue, intValue));
|
||||
SimpleWithLongAndInt document = template.findById("simpleWithLong:simple", SimpleWithLongAndInt.class);
|
||||
assertNotNull(document);
|
||||
assertEquals(longValue, document.getLongValue());
|
||||
assertEquals(intValue, document.getIntValue());
|
||||
assertThat(document).isNotNull();
|
||||
assertThat(document.getLongValue()).isEqualTo(longValue);
|
||||
assertThat(document.getIntValue()).isEqualTo(intValue);
|
||||
|
||||
template.save(new SimpleWithLongAndInt("simpleWithLong:simple:other", intValue, intValue));
|
||||
document = template.findById("simpleWithLong:simple:other", SimpleWithLongAndInt.class);
|
||||
assertNotNull(document);
|
||||
assertEquals(intValue, document.getLongValue());
|
||||
assertEquals(intValue, document.getIntValue());
|
||||
assertThat(document).isNotNull();
|
||||
assertThat(document.getLongValue()).isEqualTo(intValue);
|
||||
assertThat(document.getIntValue()).isEqualTo(intValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -293,8 +294,8 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
SimpleWithEnum simpleWithEnum = new SimpleWithEnum("simpleWithEnum:enum", SimpleWithEnum.Type.BIG);
|
||||
template.save(simpleWithEnum);
|
||||
simpleWithEnum = template.findById("simpleWithEnum:enum", SimpleWithEnum.class);
|
||||
assertNotNull(simpleWithEnum);
|
||||
assertEquals(simpleWithEnum.getType(), SimpleWithEnum.Type.BIG);
|
||||
assertThat(simpleWithEnum).isNotNull();
|
||||
assertThat(SimpleWithEnum.Type.BIG).isEqualTo(simpleWithEnum.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -303,8 +304,9 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
simpleWithClass.setValue("The dish ran away with the spoon.");
|
||||
template.save(simpleWithClass);
|
||||
simpleWithClass = template.findById("simpleWithClass:class", SimpleWithClass.class);
|
||||
assertNotNull(simpleWithClass);
|
||||
assertThat(simpleWithClass.getValue(), equalTo("The dish ran away with the spoon."));
|
||||
assertThat(simpleWithClass).isNotNull();
|
||||
assertThat(simpleWithClass.getValue())
|
||||
.isEqualTo("The dish ran away with the spoon.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -312,10 +314,10 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
removeIfExist("versionedClass:1");
|
||||
|
||||
VersionedClass versionedClass = new VersionedClass("versionedClass:1", "foobar");
|
||||
assertEquals(0, versionedClass.getVersion());
|
||||
assertThat(versionedClass.getVersion()).isEqualTo(0);
|
||||
template.insert(versionedClass);
|
||||
RawJsonDocument rawStored = client.get("versionedClass:1", RawJsonDocument.class);
|
||||
assertEquals(rawStored.cas(), versionedClass.getVersion());
|
||||
assertThat(versionedClass.getVersion()).isEqualTo(rawStored.cas());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -332,9 +334,9 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
}
|
||||
long version2 = versionedClass.getVersion();
|
||||
|
||||
assertTrue(version1 > 0);
|
||||
assertTrue(version2 > 0);
|
||||
assertEquals(version1, version2);
|
||||
assertThat(version1 > 0).isTrue();
|
||||
assertThat(version2 > 0).isTrue();
|
||||
assertThat(version2).isEqualTo(version1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -349,11 +351,12 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
template.save(versionedClass);
|
||||
long version2 = versionedClass.getVersion();
|
||||
|
||||
assertTrue(version1 > 0);
|
||||
assertTrue(version2 > 0);
|
||||
assertNotEquals(version1, version2);
|
||||
assertThat(version1 > 0).isTrue();
|
||||
assertThat(version2 > 0).isTrue();
|
||||
assertThat(version2).isNotEqualTo(version1);
|
||||
|
||||
assertEquals("foobar2", template.findById("versionedClass:3", VersionedClass.class).getField());
|
||||
assertThat(template.findById("versionedClass:3", VersionedClass.class).getField())
|
||||
.isEqualTo("foobar2");
|
||||
}
|
||||
|
||||
@Test(expected = OptimisticLockingFailureException.class)
|
||||
@@ -364,7 +367,7 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
template.insert(versionedClass);
|
||||
|
||||
RawJsonDocument toCompare = RawJsonDocument.create("versionedClass:4", "different");
|
||||
assertNotNull(client.upsert(toCompare));
|
||||
assertThat(client.upsert(toCompare)).isNotNull();
|
||||
|
||||
versionedClass.setField("foobar2");
|
||||
//save (aka upsert) won't error in case of CAS mismatch anymore
|
||||
@@ -383,11 +386,12 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
template.update(versionedClass);
|
||||
long version2 = versionedClass.getVersion();
|
||||
|
||||
assertTrue(version1 > 0);
|
||||
assertTrue(version2 > 0);
|
||||
assertNotEquals(version1, version2);
|
||||
assertThat(version1 > 0).isTrue();
|
||||
assertThat(version2 > 0).isTrue();
|
||||
assertThat(version2).isNotEqualTo(version1);
|
||||
|
||||
assertEquals("foobar2", template.findById("versionedClass:5", VersionedClass.class).getField());
|
||||
assertThat(template.findById("versionedClass:5", VersionedClass.class).getField())
|
||||
.isEqualTo("foobar2");
|
||||
}
|
||||
|
||||
@Test(expected = OptimisticLockingFailureException.class)
|
||||
@@ -398,7 +402,7 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
template.insert(versionedClass);
|
||||
|
||||
RawJsonDocument toCompare = RawJsonDocument.create("versionedClass:6", "different");
|
||||
assertNotNull(client.upsert(toCompare));
|
||||
assertThat(client.upsert(toCompare)).isNotNull();
|
||||
|
||||
versionedClass.setField("foobar2");
|
||||
template.update(versionedClass);
|
||||
@@ -410,10 +414,10 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
|
||||
VersionedClass versionedClass = new VersionedClass("versionedClass:7", "foobar");
|
||||
template.insert(versionedClass);
|
||||
assertTrue(versionedClass.getVersion() > 0);
|
||||
assertThat(versionedClass.getVersion() > 0).isTrue();
|
||||
|
||||
VersionedClass foundClass = template.findById("versionedClass:7", VersionedClass.class);
|
||||
assertEquals(versionedClass.getVersion(), foundClass.getVersion());
|
||||
assertThat(foundClass.getVersion()).isEqualTo(versionedClass.getVersion());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -446,8 +450,8 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
|
||||
VersionedClass actual = template.findById(key, VersionedClass.class);
|
||||
|
||||
assertNotEquals(initial.field, actual.field);
|
||||
assertNotEquals(initial.version, actual.version);
|
||||
assertThat(actual.field).isNotEqualTo(initial.field);
|
||||
assertThat(actual.version).isNotEqualTo(initial.version);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -474,7 +478,7 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
});
|
||||
|
||||
|
||||
assertEquals(4, optimisticLockCounter.intValue());
|
||||
assertThat(optimisticLockCounter.intValue()).isEqualTo(4);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -486,11 +490,11 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
DocumentWithTouchOnRead doc = new DocumentWithTouchOnRead(id);
|
||||
template.save(doc);
|
||||
Thread.sleep(1000);
|
||||
assertNotNull(template.findById(id, DocumentWithTouchOnRead.class));
|
||||
assertThat(template.findById(id, DocumentWithTouchOnRead.class)).isNotNull();
|
||||
Thread.sleep(1000);
|
||||
assertNotNull(template.findById(id, DocumentWithTouchOnRead.class));
|
||||
assertThat(template.findById(id, DocumentWithTouchOnRead.class)).isNotNull();
|
||||
Thread.sleep(3000);
|
||||
assertNull(template.findById(id, DocumentWithTouchOnRead.class));
|
||||
assertThat(template.findById(id, DocumentWithTouchOnRead.class)).isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,12 +507,12 @@ public class CouchbaseTemplateIntegrationTests {
|
||||
|
||||
String prev = null;
|
||||
List<Beer> beers = template.findByView(q, Beer.class);
|
||||
assertTrue(q.isIncludeDocs());
|
||||
assertTrue(q.isOrderRetained());
|
||||
assertEquals(RawJsonDocument.class, q.includeDocsTarget());
|
||||
assertThat(q.isIncludeDocs()).isTrue();
|
||||
assertThat(q.isOrderRetained()).isTrue();
|
||||
assertThat(q.includeDocsTarget()).isEqualTo(RawJsonDocument.class);
|
||||
for (Beer beer : beers) {
|
||||
if (prev != null) {
|
||||
assertThat(beer.getName() + " not alphabetically < to " + prev, beer.getName().compareTo(prev) < 0);
|
||||
assertThat(beer.getName().compareTo(prev) < 0).describedAs(beer.getName() + " not alphabetically < to " + prev).isTrue();
|
||||
}
|
||||
prev = beer.getName();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.springframework.data.couchbase.core;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import com.couchbase.client.java.repository.annotation.Id;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -15,6 +14,9 @@ import org.springframework.data.couchbase.core.mapping.Document;
|
||||
import org.springframework.data.couchbase.core.mapping.KeySettings;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Subhashni Balakrishnan
|
||||
*/
|
||||
@@ -40,7 +42,8 @@ public class CouchbaseTemplateKeySettingsIntegrationTests {
|
||||
public void shouldAddCustomKeySettings() throws Exception {
|
||||
SimpleClass simpleClass = new SimpleClass();
|
||||
String generatedId = template.getGeneratedId(simpleClass);
|
||||
assertEquals("Id generated should include custom key settings", "MyAppPrefix::myId::MyAppSuffix", generatedId);
|
||||
assertThat(generatedId).as("Id generated should include custom key settings")
|
||||
.isEqualTo("MyAppPrefix::myId::MyAppSuffix");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -18,9 +18,7 @@ package org.springframework.data.couchbase.core;
|
||||
|
||||
import static com.couchbase.client.java.query.Select.select;
|
||||
import static com.couchbase.client.java.query.dsl.Expression.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
@@ -123,11 +121,11 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
VersionedReactiveBeer secondBeer = new VersionedReactiveBeer(DEFAULT_ID, newName, DEFAULT_ACTIVE, DEFAULT_DESCRIPTION);
|
||||
|
||||
long version = template.save(firstBeer).toBlocking().single().getVersion();
|
||||
assertTrue(version > 0);
|
||||
assertThat(version > 0).isTrue();
|
||||
secondBeer.setVersion(version);
|
||||
long newVersion = template.save(secondBeer).toBlocking().single().getVersion();
|
||||
assertTrue(newVersion > 0);
|
||||
assertNotEquals(version, newVersion);
|
||||
assertThat(newVersion > 0).isTrue();
|
||||
assertThat(newVersion).isNotEqualTo(version);
|
||||
|
||||
validateBeer(DEFAULT_ID, newName, DEFAULT_ACTIVE, DEFAULT_DESCRIPTION, VersionedReactiveBeer.class);
|
||||
}
|
||||
@@ -140,7 +138,7 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
TestSubscriber<VersionedReactiveBeer> secondSaveSubscriber = TestSubscriber.create();
|
||||
|
||||
long version = template.save(firstBeer).toBlocking().single().getVersion();
|
||||
assertTrue(version > 0);
|
||||
assertThat(version > 0).isTrue();
|
||||
secondBeer.setVersion(version + 1234);
|
||||
template.save(secondBeer).subscribe(secondSaveSubscriber);
|
||||
AsyncUtils.awaitError(secondSaveSubscriber, OptimisticLockingFailureException.class);
|
||||
@@ -156,7 +154,7 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
TestSubscriber<VersionedReactiveBeer> secondSaveSubscriber = TestSubscriber.create();
|
||||
|
||||
long version = template.save(firstBeer).toBlocking().single().getVersion();
|
||||
assertTrue(version > 0);
|
||||
assertThat(version > 0).isTrue();
|
||||
template.save(secondBeer).subscribe(secondSaveSubscriber);
|
||||
AsyncUtils.awaitError(secondSaveSubscriber, OptimisticLockingFailureException.class);
|
||||
|
||||
@@ -286,14 +284,14 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
ComplexPerson complex = new ComplexPerson(id, names, votes, info1, info2);
|
||||
|
||||
template.save(complex).subscribe();
|
||||
assertNotNull(client.get(id));
|
||||
assertThat(client.get(id)).isNotNull();
|
||||
|
||||
ComplexPerson response = template.findById(id, ComplexPerson.class).toBlocking().single();
|
||||
assertEquals(names, response.getFirstnames());
|
||||
assertEquals(votes, response.getVotes());
|
||||
assertEquals(id, response.getId());
|
||||
assertEquals(info1, response.getInfo1());
|
||||
assertEquals(info2, response.getInfo2());
|
||||
assertThat(response.getFirstnames()).isEqualTo(names);
|
||||
assertThat(response.getVotes()).isEqualTo(votes);
|
||||
assertThat(response.getId()).isEqualTo(id);
|
||||
assertThat(response.getInfo1()).isEqualTo(info1);
|
||||
assertThat(response.getInfo2()).isEqualTo(info2);
|
||||
}
|
||||
|
||||
|
||||
@@ -317,12 +315,12 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
query.stale(Stale.FALSE);
|
||||
|
||||
final List<ReactiveBeer> beers = template.findByView(query, ReactiveBeer.class).toList().toBlocking().single();
|
||||
assertTrue(beers.size() > 0);
|
||||
assertThat(beers.size() > 0).isTrue();
|
||||
|
||||
for (ReactiveBeer beer : beers) {
|
||||
assertNotNull(beer.getId());
|
||||
assertNotNull(beer.getName());
|
||||
assertNotNull(beer.getActive());
|
||||
assertThat(beer.getId()).isNotNull();
|
||||
assertThat(beer.getName()).isNotNull();
|
||||
assertThat(beer.getActive()).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,8 +329,8 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
N1qlQuery query = N1qlQuery.simple(select("name").from(i(client.name())).limit(1));
|
||||
|
||||
AsyncN1qlQueryResult queryResult = template.queryN1QL(query).toBlocking().single();
|
||||
assertTrue(queryResult.finalSuccess().toBlocking().single());
|
||||
assertFalse(queryResult.rows().toList().toBlocking().single().isEmpty());
|
||||
assertThat(queryResult.finalSuccess().toBlocking().single()).isTrue();
|
||||
assertThat(queryResult.rows().toList().toBlocking().single().isEmpty()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -349,10 +347,10 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
N1qlParams.build().consistency(ScanConsistency.REQUEST_PLUS));
|
||||
|
||||
List<Fragment> fragments = template.findByN1QLProjection(query, Fragment.class).toList().toBlocking().single();
|
||||
assertNotNull(fragments);
|
||||
assertFalse(fragments.isEmpty());
|
||||
assertEquals(1, fragments.size());
|
||||
assertEquals("test2", fragments.get(0).value);
|
||||
assertThat(fragments).isNotNull();
|
||||
assertThat(fragments.isEmpty()).isFalse();
|
||||
assertThat(fragments.size()).isEqualTo(1);
|
||||
assertThat(fragments.get(0).value).isEqualTo("test2");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -362,15 +360,15 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
|
||||
template.save(new SimpleWithLongAndInt("simpleWithLong:simple", longValue, intValue)).toBlocking().single();
|
||||
SimpleWithLongAndInt document = template.findById("simpleWithLong:simple", SimpleWithLongAndInt.class).toBlocking().single();
|
||||
assertNotNull(document);
|
||||
assertEquals(longValue, document.getLongValue());
|
||||
assertEquals(intValue, document.getIntValue());
|
||||
assertThat(document).isNotNull();
|
||||
assertThat(document.getLongValue()).isEqualTo(longValue);
|
||||
assertThat(document.getIntValue()).isEqualTo(intValue);
|
||||
|
||||
template.save(new SimpleWithLongAndInt("simpleWithLong:simple:other", intValue, intValue)).toBlocking().single();
|
||||
document = template.findById("simpleWithLong:simple:other", SimpleWithLongAndInt.class).toBlocking().single();
|
||||
assertNotNull(document);
|
||||
assertEquals(intValue, document.getLongValue());
|
||||
assertEquals(intValue, document.getIntValue());
|
||||
assertThat(document).isNotNull();
|
||||
assertThat(document.getLongValue()).isEqualTo(intValue);
|
||||
assertThat(document.getIntValue()).isEqualTo(intValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -378,8 +376,8 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
SimpleWithEnum simpleWithEnum = new SimpleWithEnum("simpleWithEnum:enum", SimpleWithEnum.Type.BIG);
|
||||
template.save(simpleWithEnum).toBlocking().single();
|
||||
simpleWithEnum = template.findById("simpleWithEnum:enum", SimpleWithEnum.class).toBlocking().single();
|
||||
assertNotNull(simpleWithEnum);
|
||||
assertEquals(simpleWithEnum.getType(), SimpleWithEnum.Type.BIG);
|
||||
assertThat(simpleWithEnum).isNotNull();
|
||||
assertThat(SimpleWithEnum.Type.BIG).isEqualTo(simpleWithEnum.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -388,8 +386,9 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
simpleWithClass.setValue("The dish ran away with the spoon.");
|
||||
template.save(simpleWithClass).toBlocking().single();
|
||||
simpleWithClass = template.findById("simpleWithClass:class", SimpleWithClass.class).toBlocking().single();
|
||||
assertNotNull(simpleWithClass);
|
||||
assertThat(simpleWithClass.getValue(), equalTo("The dish ran away with the spoon."));
|
||||
assertThat(simpleWithClass).isNotNull();
|
||||
assertThat(simpleWithClass.getValue())
|
||||
.isEqualTo("The dish ran away with the spoon.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -398,11 +397,14 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
DocumentWithTouchOnRead doc = new DocumentWithTouchOnRead(id);
|
||||
template.save(doc).subscribe();
|
||||
Thread.sleep(1000);
|
||||
assertNotNull(template.findById(id, DocumentWithTouchOnRead.class).toBlocking().single());
|
||||
assertThat(template.findById(id, DocumentWithTouchOnRead.class).toBlocking()
|
||||
.single()).isNotNull();
|
||||
Thread.sleep(1000);
|
||||
assertNotNull(template.findById(id, DocumentWithTouchOnRead.class).toBlocking().single());
|
||||
assertThat(template.findById(id, DocumentWithTouchOnRead.class).toBlocking()
|
||||
.single()).isNotNull();
|
||||
Thread.sleep(3000);
|
||||
assertNull(template.findById(id, DocumentWithTouchOnRead.class).toBlocking().single());
|
||||
assertThat(template.findById(id, DocumentWithTouchOnRead.class).toBlocking()
|
||||
.single()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -412,12 +414,12 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
|
||||
String prev = null;
|
||||
List<ReactiveBeer> beers = template.findByView(q, ReactiveBeer.class).toList().toBlocking().single();
|
||||
assertTrue(q.isIncludeDocs());
|
||||
assertTrue(q.isOrderRetained());
|
||||
assertEquals(RawJsonDocument.class, q.includeDocsTarget());
|
||||
assertThat(q.isIncludeDocs()).isTrue();
|
||||
assertThat(q.isOrderRetained()).isTrue();
|
||||
assertThat(q.includeDocsTarget()).isEqualTo(RawJsonDocument.class);
|
||||
for (ReactiveBeer beer : beers) {
|
||||
if (prev != null) {
|
||||
assertThat(beer.getName() + " not alphabetically < to " + prev, beer.getName().compareTo(prev) < 0);
|
||||
assertThat(beer.getName().compareTo(prev) < 0).describedAs(beer.getName() + " not alphabetically < to " + prev).isTrue();
|
||||
}
|
||||
prev = beer.getName();
|
||||
}
|
||||
@@ -425,17 +427,18 @@ public class RxJavaCouchbaseTemplateIntegrationTests {
|
||||
|
||||
private void validateBeer(String id, String name, boolean active, String description, Class<?> clazz) throws IOException {
|
||||
RawJsonDocument resultDoc = client.get(id, RawJsonDocument.class);
|
||||
assertNotNull(resultDoc);
|
||||
assertThat(resultDoc).isNotNull();
|
||||
String result = resultDoc.content();
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
Map<String, Object> resultConv = MAPPER.readValue(result, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
assertNotNull(resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT));
|
||||
assertNull(resultConv.get("javaClass"));
|
||||
assertEquals(clazz.getCanonicalName(), resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT));
|
||||
assertEquals(active, resultConv.get("is_active"));
|
||||
assertEquals(name, resultConv.get("name"));
|
||||
assertEquals(description, resultConv.get("desc"));
|
||||
assertThat(resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT)).isNotNull();
|
||||
assertThat(resultConv.get("javaClass")).isNull();
|
||||
assertThat(resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT))
|
||||
.isEqualTo(clazz.getCanonicalName());
|
||||
assertThat(resultConv.get("is_active")).isEqualTo(active);
|
||||
assertThat(resultConv.get("name")).isEqualTo(name);
|
||||
assertThat(resultConv.get("desc")).isEqualTo(description);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.core;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.couchbase.client.java.Bucket;
|
||||
@@ -34,6 +32,8 @@ import org.springframework.data.couchbase.IntegrationTestCustomTypeKeyConfig;
|
||||
import org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests the Java Config template around type key modification (DATACOUCH-134)
|
||||
*
|
||||
@@ -63,15 +63,16 @@ public class TypeKeyIntegrationTests {
|
||||
|
||||
template.save(beer);
|
||||
RawJsonDocument resultDoc = client.get(id, RawJsonDocument.class);
|
||||
assertNotNull(resultDoc);
|
||||
assertThat(resultDoc).isNotNull();
|
||||
String result = resultDoc.content();
|
||||
assertNotNull(result);
|
||||
assertThat(result).isNotNull();
|
||||
Map<String, Object> resultConv = MAPPER.readValue(result, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
assertNull(resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT));
|
||||
assertNotNull(resultConv.get("javaClass"));
|
||||
assertEquals("org.springframework.data.couchbase.core.Beer", resultConv.get("javaClass"));
|
||||
assertEquals(false, resultConv.get("is_active"));
|
||||
assertEquals("The Awesome Stout", resultConv.get("name"));
|
||||
assertThat(resultConv.get(MappingCouchbaseConverter.TYPEKEY_DEFAULT)).isNull();
|
||||
assertThat(resultConv.get("javaClass")).isNotNull();
|
||||
assertThat(resultConv.get("javaClass"))
|
||||
.isEqualTo("org.springframework.data.couchbase.core.Beer");
|
||||
assertThat(resultConv.get("is_active")).isEqualTo(false);
|
||||
assertThat(resultConv.get("name")).isEqualTo("The Awesome Stout");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.data.couchbase.core.convert.join;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
@@ -98,7 +98,7 @@ public class N1qlJoinResolverTest {
|
||||
String expected = "SELECT META(rks).id AS _ID, META(rks).cas AS _CAS, (rks).* FROM `B` lks USE INDEX(leftIndex) JOIN B rks ON A=B" +
|
||||
" AND lks._class = \"" + entityClassName + "\"" + " AND " +
|
||||
"rks._class = \"" + entityClassName + "\" WHERE META(lks).id=\"mydoc\"";
|
||||
assertEquals(statement, expected);
|
||||
assertThat(expected).isEqualTo(statement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,7 +109,7 @@ public class N1qlJoinResolverTest {
|
||||
String expected = "SELECT META(rks).id AS _ID, META(rks).cas AS _CAS, (rks).* FROM `B` lks JOIN B rks USE INDEX(rightIndex) ON A=B" +
|
||||
" AND lks._class = \"" + entityClassName + "\"" + " AND " +
|
||||
"rks._class = \"" + entityClassName + "\" WHERE META(lks).id=\"mydoc\"";
|
||||
assertEquals(statement, expected);
|
||||
assertThat(expected).isEqualTo(statement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,7 +120,7 @@ public class N1qlJoinResolverTest {
|
||||
String expected = "SELECT META(rks).id AS _ID, META(rks).cas AS _CAS, (rks).* FROM `B` lks JOIN B rks USE HASH(probe) ON A=B" +
|
||||
" AND lks._class = \"" + entityClassName + "\"" + " AND " +
|
||||
"rks._class = \"" + entityClassName + "\" WHERE META(lks).id=\"mydoc\"";
|
||||
assertEquals(statement, expected);
|
||||
assertThat(expected).isEqualTo(statement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,7 +131,7 @@ public class N1qlJoinResolverTest {
|
||||
String expected = "SELECT META(rks).id AS _ID, META(rks).cas AS _CAS, (rks).* FROM `B` lks JOIN B rks USE HASH(build) ON A=B" +
|
||||
" AND lks._class = \"" + entityClassName + "\"" + " AND " +
|
||||
"rks._class = \"" + entityClassName + "\" WHERE META(lks).id=\"mydoc\"";
|
||||
assertEquals(statement, expected);
|
||||
assertThat(expected).isEqualTo(statement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -142,7 +142,7 @@ public class N1qlJoinResolverTest {
|
||||
String expected = "SELECT META(rks).id AS _ID, META(rks).cas AS _CAS, (rks).* FROM `B` lks JOIN B rks USE KEYS [\"x\",\"y\"] ON A=B" +
|
||||
" AND lks._class = \"" + entityClassName + "\"" + " AND " +
|
||||
"rks._class = \"" + entityClassName + "\" WHERE META(lks).id=\"mydoc\"";
|
||||
assertEquals(statement, expected);
|
||||
assertThat(expected).isEqualTo(statement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -153,7 +153,7 @@ public class N1qlJoinResolverTest {
|
||||
String expected = "SELECT META(rks).id AS _ID, META(rks).cas AS _CAS, (rks).* FROM `B` lks JOIN B rks ON A=B" +
|
||||
" AND lks._class = \"" + entityClassName + "\"" + " AND " +
|
||||
"rks._class = \"" + entityClassName + "\" WHERE META(lks).id=\"mydoc\" AND C=D";
|
||||
assertEquals(statement, expected);
|
||||
assertThat(expected).isEqualTo(statement);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -164,6 +164,6 @@ public class N1qlJoinResolverTest {
|
||||
String expected = "SELECT META(rks).id AS _ID, META(rks).cas AS _CAS, (rks).* FROM `B` lks USE INDEX(leftIndex) JOIN B rks USE INDEX(rightIndex)" +
|
||||
" HASH(build) KEYS [\"x\"] ON A=B AND lks._class = \"" + entityClassName + "\"" + " AND " +
|
||||
"rks._class = \"" + entityClassName + "\" WHERE META(lks).id=\"mydoc\"";
|
||||
assertEquals(statement, expected);
|
||||
assertThat(expected).isEqualTo(statement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
package org.springframework.data.couchbase.core.convert.translation;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbaseDocument;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Verifies the functionality of a {@link JacksonTranslationService}.
|
||||
*
|
||||
@@ -42,7 +42,7 @@ public class JacksonTranslationServiceTests {
|
||||
CouchbaseDocument doc = new CouchbaseDocument("key");
|
||||
doc.put("language", "русский");
|
||||
String expected = "{\"language\":\"русский\"}";
|
||||
assertEquals(expected, service.encode(doc));
|
||||
assertThat(service.encode(doc)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -50,15 +50,15 @@ public class JacksonTranslationServiceTests {
|
||||
String source = "{\"language\":\"русский\"}";
|
||||
CouchbaseDocument target = new CouchbaseDocument();
|
||||
service.decode(source, target);
|
||||
assertEquals("русский", target.get("language"));
|
||||
assertThat(target.get("language")).isEqualTo("русский");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDecodeAdHocFragment() {
|
||||
String source = "{\"language\":\"french\"}";
|
||||
LanguageFragment f = service.decodeFragment(source, LanguageFragment.class);
|
||||
assertNotNull(f);
|
||||
assertEquals("french", f.language);
|
||||
assertThat(f).isNotNull();
|
||||
assertThat(f.language).isEqualTo("french");
|
||||
}
|
||||
|
||||
private static class LanguageFragment {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.core.mapping;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
@@ -35,6 +33,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Verifies the correct behavior of annotation at the class level on persistable objects.
|
||||
*
|
||||
@@ -59,7 +59,7 @@ public class BasicCouchbasePersistentEntityTests {
|
||||
CouchbasePersistentEntity<DefaultExpiry> entity = new BasicCouchbasePersistentEntity<DefaultExpiry>(
|
||||
ClassTypeInformation.from(DefaultExpiry.class));
|
||||
|
||||
assertEquals(0, entity.getExpiry());
|
||||
assertThat(entity.getExpiry()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -67,14 +67,14 @@ public class BasicCouchbasePersistentEntityTests {
|
||||
CouchbasePersistentEntity<DefaultExpiryUnit> entity = new BasicCouchbasePersistentEntity<DefaultExpiryUnit>(
|
||||
ClassTypeInformation.from(DefaultExpiryUnit.class));
|
||||
|
||||
assertEquals(78, entity.getExpiry());
|
||||
assertThat(entity.getExpiry()).isEqualTo(78);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLargeExpiry30DaysStillInSeconds() {
|
||||
CouchbasePersistentEntity<LimitDaysExpiry> entityUnder = new BasicCouchbasePersistentEntity<LimitDaysExpiry>(
|
||||
ClassTypeInformation.from(LimitDaysExpiry.class));
|
||||
assertEquals(30 * 24 * 60 * 60, entityUnder.getExpiry());
|
||||
assertThat(entityUnder.getExpiry()).isEqualTo(30 * 24 * 60 * 60);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -92,14 +92,16 @@ public class BasicCouchbasePersistentEntityTests {
|
||||
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||
calendar.clear();
|
||||
calendar.add(Calendar.SECOND, expiryOver);
|
||||
assertEquals(expected.get(Calendar.YEAR), calendar.get(Calendar.YEAR));
|
||||
assertEquals(expected.get(Calendar.MONTH), calendar.get(Calendar.MONTH));
|
||||
assertEquals(expected.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(expected.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(expected.get(Calendar.MINUTE), calendar.get(Calendar.MINUTE));
|
||||
assertEquals(expected.get(Calendar.SECOND), calendar.get(Calendar.SECOND));
|
||||
assertThat(calendar.get(Calendar.YEAR)).isEqualTo(expected.get(Calendar.YEAR));
|
||||
assertThat(calendar.get(Calendar.MONTH)).isEqualTo(expected.get(Calendar.MONTH));
|
||||
assertThat(calendar.get(Calendar.DAY_OF_MONTH))
|
||||
.isEqualTo(expected.get(Calendar.DAY_OF_MONTH));
|
||||
assertThat(calendar.get(Calendar.HOUR_OF_DAY))
|
||||
.isEqualTo(expected.get(Calendar.HOUR_OF_DAY));
|
||||
assertThat(calendar.get(Calendar.MINUTE)).isEqualTo(expected.get(Calendar.MINUTE));
|
||||
assertThat(calendar.get(Calendar.SECOND)).isEqualTo(expected.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLargeExpiryExpression31DaysIsConvertedToUnixUtcTime() {
|
||||
BasicCouchbasePersistentEntity<OverLimitDaysExpiryExpression> entityOver = new BasicCouchbasePersistentEntity<OverLimitDaysExpiryExpression>(
|
||||
@@ -116,12 +118,14 @@ public class BasicCouchbasePersistentEntityTests {
|
||||
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||
calendar.clear();
|
||||
calendar.add(Calendar.SECOND, expiryOver);
|
||||
assertEquals(expected.get(Calendar.YEAR), calendar.get(Calendar.YEAR));
|
||||
assertEquals(expected.get(Calendar.MONTH), calendar.get(Calendar.MONTH));
|
||||
assertEquals(expected.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(expected.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(expected.get(Calendar.MINUTE), calendar.get(Calendar.MINUTE));
|
||||
assertEquals(expected.get(Calendar.SECOND), calendar.get(Calendar.SECOND));
|
||||
assertThat(calendar.get(Calendar.YEAR)).isEqualTo(expected.get(Calendar.YEAR));
|
||||
assertThat(calendar.get(Calendar.MONTH)).isEqualTo(expected.get(Calendar.MONTH));
|
||||
assertThat(calendar.get(Calendar.DAY_OF_MONTH))
|
||||
.isEqualTo(expected.get(Calendar.DAY_OF_MONTH));
|
||||
assertThat(calendar.get(Calendar.HOUR_OF_DAY))
|
||||
.isEqualTo(expected.get(Calendar.HOUR_OF_DAY));
|
||||
assertThat(calendar.get(Calendar.MINUTE)).isEqualTo(expected.get(Calendar.MINUTE));
|
||||
assertThat(calendar.get(Calendar.SECOND)).isEqualTo(expected.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,59 +143,69 @@ public class BasicCouchbasePersistentEntityTests {
|
||||
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
|
||||
calendar.clear();
|
||||
calendar.add(Calendar.SECOND, expiryOver);
|
||||
assertEquals(expected.get(Calendar.YEAR), calendar.get(Calendar.YEAR));
|
||||
assertEquals(expected.get(Calendar.MONTH), calendar.get(Calendar.MONTH));
|
||||
assertEquals(expected.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.DAY_OF_MONTH));
|
||||
assertEquals(expected.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.HOUR_OF_DAY));
|
||||
assertEquals(expected.get(Calendar.MINUTE), calendar.get(Calendar.MINUTE));
|
||||
assertEquals(expected.get(Calendar.SECOND), calendar.get(Calendar.SECOND));
|
||||
assertThat(calendar.get(Calendar.YEAR)).isEqualTo(expected.get(Calendar.YEAR));
|
||||
assertThat(calendar.get(Calendar.MONTH)).isEqualTo(expected.get(Calendar.MONTH));
|
||||
assertThat(calendar.get(Calendar.DAY_OF_MONTH))
|
||||
.isEqualTo(expected.get(Calendar.DAY_OF_MONTH));
|
||||
assertThat(calendar.get(Calendar.HOUR_OF_DAY))
|
||||
.isEqualTo(expected.get(Calendar.HOUR_OF_DAY));
|
||||
assertThat(calendar.get(Calendar.MINUTE)).isEqualTo(expected.get(Calendar.MINUTE));
|
||||
assertThat(calendar.get(Calendar.SECOND)).isEqualTo(expected.get(Calendar.SECOND));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotUseGetExpiry() throws Exception {
|
||||
assertEquals(0, getBasicCouchbasePersistentEntity(SimpleDocument.class).getExpiry());
|
||||
assertThat(getBasicCouchbasePersistentEntity(SimpleDocument.class).getExpiry())
|
||||
.isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usesGetExpiry() throws Exception {
|
||||
assertEquals(10, getBasicCouchbasePersistentEntity(SimpleDocumentWithExpiry.class).getExpiry());
|
||||
assertThat(getBasicCouchbasePersistentEntity(SimpleDocumentWithExpiry.class)
|
||||
.getExpiry()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotUseIsUpdateExpiryForRead() throws Exception {
|
||||
assertFalse(getBasicCouchbasePersistentEntity(SimpleDocument.class).isTouchOnRead());
|
||||
assertFalse(getBasicCouchbasePersistentEntity(SimpleDocumentWithExpiry.class).isTouchOnRead());
|
||||
assertThat(getBasicCouchbasePersistentEntity(SimpleDocument.class).isTouchOnRead())
|
||||
.isFalse();
|
||||
assertThat(getBasicCouchbasePersistentEntity(SimpleDocumentWithExpiry.class)
|
||||
.isTouchOnRead()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usesTouchOnRead() throws Exception {
|
||||
assertTrue(getBasicCouchbasePersistentEntity(SimpleDocumentWithTouchOnRead.class).isTouchOnRead());
|
||||
assertThat(getBasicCouchbasePersistentEntity(SimpleDocumentWithTouchOnRead.class)
|
||||
.isTouchOnRead()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usesGetExpiryExpression() throws Exception {
|
||||
assertEquals(10, getBasicCouchbasePersistentEntity(ConstantExpiryExpression.class).getExpiry());
|
||||
assertThat(getBasicCouchbasePersistentEntity(ConstantExpiryExpression.class)
|
||||
.getExpiry()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usesGetExpiryFromValidExpression() throws Exception {
|
||||
assertEquals(10, getBasicCouchbasePersistentEntity(ExpiryWithValidExpression.class).getExpiry());
|
||||
assertThat(getBasicCouchbasePersistentEntity(ExpiryWithValidExpression.class)
|
||||
.getExpiry()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotAllowUseExpiryFromInvalidExpression() throws Exception {
|
||||
expectedException.expect(IllegalArgumentException.class);
|
||||
expectedException.expectMessage("Invalid Integer value for expiry expression: abc");
|
||||
assertEquals(10, getBasicCouchbasePersistentEntity(ExpiryWithInvalidExpression.class).getExpiry());
|
||||
assertThat(getBasicCouchbasePersistentEntity(ExpiryWithInvalidExpression.class)
|
||||
.getExpiry()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void usesGetExpiryExpressionAndRespectsPropertyUpdates() throws Exception {
|
||||
BasicCouchbasePersistentEntity entity = getBasicCouchbasePersistentEntity(ExpiryWithValidExpression.class);
|
||||
assertEquals(10, entity.getExpiry());
|
||||
assertThat(entity.getExpiry()).isEqualTo(10);
|
||||
|
||||
environment.getPropertySources().addFirst(new MockPropertySource().withProperty("valid.document.expiry", "20"));
|
||||
assertEquals(20, entity.getExpiry());
|
||||
assertThat(entity.getExpiry()).isEqualTo(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -253,7 +267,7 @@ public class BasicCouchbasePersistentEntityTests {
|
||||
@Document(expiry = 31, expiryUnit = TimeUnit.DAYS)
|
||||
public class OverLimitDaysExpiry {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Simple POJO to test larger than 30 days expiry defined as an expression
|
||||
*/
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.core.mapping;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -30,6 +28,8 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Verifies the correct behavior of properties on persistable objects.
|
||||
*
|
||||
@@ -58,7 +58,7 @@ public class BasicCouchbasePersistentPropertyTests {
|
||||
@Test
|
||||
public void usesPropertyFieldName() {
|
||||
Field field = ReflectionUtils.findField(Beer.class, "description");
|
||||
assertEquals("description", getPropertyFor(field).getFieldName());
|
||||
assertThat(getPropertyFor(field).getFieldName()).isEqualTo("description");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ public class BasicCouchbasePersistentPropertyTests {
|
||||
@Test
|
||||
public void usesAnnotatedFieldName() {
|
||||
Field field = ReflectionUtils.findField(Beer.class, "name");
|
||||
assertEquals("foobar", getPropertyFor(field).getFieldName());
|
||||
assertThat(getPropertyFor(field).getFieldName()).isEqualTo("foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,14 +82,14 @@ public class BasicCouchbasePersistentPropertyTests {
|
||||
test.addPersistentProperty(sdkIdProperty);
|
||||
test.addPersistentProperty(springIdProperty);
|
||||
|
||||
assertEquals("sdkId", sdkIdProperty.getFieldName());
|
||||
assertEquals("springId", springIdProperty.getFieldName());
|
||||
assertThat(sdkIdProperty.getFieldName()).isEqualTo("sdkId");
|
||||
assertThat(springIdProperty.getFieldName()).isEqualTo("springId");
|
||||
|
||||
assertTrue(sdkIdProperty.isIdProperty());
|
||||
assertTrue(springIdProperty.isIdProperty());
|
||||
assertThat(sdkIdProperty.isIdProperty()).isTrue();
|
||||
assertThat(springIdProperty.isIdProperty()).isTrue();
|
||||
|
||||
CouchbasePersistentProperty property = test.getIdProperty();
|
||||
assertEquals(springIdProperty, property);
|
||||
assertThat(property).isEqualTo(springIdProperty);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,7 +101,7 @@ public class BasicCouchbasePersistentPropertyTests {
|
||||
test.addPersistentProperty(idProperty);
|
||||
|
||||
CouchbasePersistentProperty property = test.getIdProperty();
|
||||
assertEquals(idProperty, property);
|
||||
assertThat(property).isEqualTo(idProperty);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -117,10 +117,10 @@ public class BasicCouchbasePersistentPropertyTests {
|
||||
// when "overriding" Spring @Id with SDK's @Id...
|
||||
test.addPersistentProperty(springIdProperty);
|
||||
|
||||
assertEquals(springIdProperty, test.getIdProperty());
|
||||
assertThat(test.getIdProperty()).isEqualTo(springIdProperty);
|
||||
|
||||
test.addPersistentProperty(sdkIdProperty);
|
||||
assertEquals(springIdProperty, test.getIdProperty());
|
||||
assertThat(test.getIdProperty()).isEqualTo(springIdProperty);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,9 +130,9 @@ public class BasicCouchbasePersistentPropertyTests {
|
||||
* @return the actual BasicCouchbasePersistentProperty instance.
|
||||
*/
|
||||
private CouchbasePersistentProperty getPropertyFor(Field field) {
|
||||
|
||||
|
||||
ClassTypeInformation<?> type = ClassTypeInformation.from(field.getDeclaringClass());
|
||||
|
||||
|
||||
return new BasicCouchbasePersistentProperty(Property.of(type, field), entity, SimpleTypeHolder.DEFAULT,
|
||||
PropertyNameFieldNamingStrategy.INSTANCE);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.core.mapping;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.text.Format;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -41,6 +39,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import com.couchbase.client.java.repository.annotation.Field;
|
||||
import com.couchbase.client.java.repository.annotation.Id;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests to verify custom mapping logic.
|
||||
*
|
||||
@@ -73,7 +73,7 @@ public class CustomConvertersTests {
|
||||
CouchbaseDocument doc = new CouchbaseDocument();
|
||||
converter.write(post, doc);
|
||||
|
||||
assertEquals(date.toString(), doc.getPayload().get("created"));
|
||||
assertThat(doc.getPayload().get("created")).isEqualTo(date.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,7 +86,7 @@ public class CustomConvertersTests {
|
||||
CouchbaseDocument doc = new CouchbaseDocument();
|
||||
doc.getPayload().put("content", 10);
|
||||
Counter loaded = converter.read(Counter.class, doc);
|
||||
assertEquals("even", loaded.content);
|
||||
assertThat(loaded.content).isEqualTo("even");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -103,8 +103,8 @@ public class CustomConvertersTests {
|
||||
CouchbaseDocument doc = new CouchbaseDocument();
|
||||
converter.write(post, doc);
|
||||
|
||||
assertEquals("The Foo of the Bar", doc.getPayload().get("title"));
|
||||
assertEquals("the_foo_of_the_bar", doc.getPayload().get("slug"));
|
||||
assertThat(doc.getPayload().get("title")).isEqualTo("The Foo of the Bar");
|
||||
assertThat(doc.getPayload().get("slug")).isEqualTo("the_foo_of_the_bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -118,8 +118,8 @@ public class CustomConvertersTests {
|
||||
doc.getPayload().put("title", "My Title");
|
||||
|
||||
BlogPost loaded = converter.read(BlogPost.class, doc);
|
||||
assertEquals("modified", loaded.id);
|
||||
assertEquals("My Title!!", loaded.title);
|
||||
assertThat(loaded.id).isEqualTo("modified");
|
||||
assertThat(loaded.title).isEqualTo("My Title!!");
|
||||
}
|
||||
|
||||
public static class BlogPost {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.core.mapping;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
@@ -53,6 +51,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.couchbase.client.java.repository.annotation.Field;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
|
||||
/**
|
||||
* @author Michael Nitschinger
|
||||
* @author Geoffrey Mina
|
||||
@@ -70,8 +71,8 @@ public class MappingCouchbaseConverterTests {
|
||||
public void shouldNotThrowNPE() {
|
||||
CouchbaseDocument converted = new CouchbaseDocument();
|
||||
converter.write(null, converted);
|
||||
assertNull(converted.getId());
|
||||
assertEquals(0, converted.getExpiration());
|
||||
assertThat(converted.getId()).isNull();
|
||||
assertThat(converted.getExpiration()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test(expected = MappingException.class)
|
||||
@@ -102,9 +103,9 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
assertEquals(entity.getClass().getName(), result.get("_class"));
|
||||
assertEquals("foobar", result.get("attr0"));
|
||||
assertEquals(BaseEntity.ID, converted.getId());
|
||||
assertThat(result.get("_class")).isEqualTo(entity.getClass().getName());
|
||||
assertThat(result.get("attr0")).isEqualTo("foobar");
|
||||
assertThat(converted.getId()).isEqualTo(BaseEntity.ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -114,7 +115,7 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr0", "foobar");
|
||||
|
||||
StringEntity converted = converter.read(StringEntity.class, source);
|
||||
assertEquals("foobar", converted.attr0);
|
||||
assertThat(converted.attr0).isEqualTo("foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,9 +125,9 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
assertEquals(entity.getClass().getName(), result.get("_class"));
|
||||
assertEquals(42L, result.get("attr0"));
|
||||
assertEquals(BaseEntity.ID, converted.getId());
|
||||
assertThat(result.get("_class")).isEqualTo(entity.getClass().getName());
|
||||
assertThat(result.get("attr0")).isEqualTo(42L);
|
||||
assertThat(converted.getId()).isEqualTo(BaseEntity.ID);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +137,7 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr0", 42);
|
||||
|
||||
NumberEntity converted = converter.read(NumberEntity.class, source);
|
||||
assertEquals(42, converted.attr0);
|
||||
assertThat(converted.attr0).isEqualTo(42);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,9 +147,9 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
assertEquals(entity.getClass().getName(), result.get("_class"));
|
||||
assertEquals(true, result.get("attr0"));
|
||||
assertEquals("mockid", converted.getId());
|
||||
assertThat(result.get("_class")).isEqualTo(entity.getClass().getName());
|
||||
assertThat(result.get("attr0")).isEqualTo(true);
|
||||
assertThat(converted.getId()).isEqualTo("mockid");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,7 +159,7 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr0", true);
|
||||
|
||||
BooleanEntity converted = converter.read(BooleanEntity.class, source);
|
||||
assertTrue(converted.attr0);
|
||||
assertThat(converted.attr0).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,11 +169,11 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
assertEquals(entity.getClass().getName(), result.get("_class"));
|
||||
assertEquals("a", result.get("attr0"));
|
||||
assertEquals(5, result.get("attr1"));
|
||||
assertEquals(-0.3, result.get("attr2"));
|
||||
assertEquals(true, result.get("attr3"));
|
||||
assertThat(result.get("_class")).isEqualTo(entity.getClass().getName());
|
||||
assertThat(result.get("attr0")).isEqualTo("a");
|
||||
assertThat(result.get("attr1")).isEqualTo(5);
|
||||
assertThat(result.get("attr2")).isEqualTo(-0.3);
|
||||
assertThat(result.get("attr3")).isEqualTo(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,10 +186,10 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr3", true);
|
||||
|
||||
MixedSimpleEntity converted = converter.read(MixedSimpleEntity.class, source);
|
||||
assertEquals("a", converted.attr0);
|
||||
assertEquals(5, converted.attr1);
|
||||
assertEquals(-0.3, converted.attr2, 0);
|
||||
assertTrue(converted.attr3);
|
||||
assertThat(converted.attr0).isEqualTo("a");
|
||||
assertThat(converted.attr1).isEqualTo(5);
|
||||
assertThat(converted.attr2).isCloseTo(-0.3, offset(0.0));
|
||||
assertThat(converted.attr3).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -198,7 +199,7 @@ public class MappingCouchbaseConverterTests {
|
||||
BasicCouchbasePersistentPropertyTests.Beer beer = converter.read(BasicCouchbasePersistentPropertyTests.Beer.class,
|
||||
document);
|
||||
|
||||
assertEquals("001", beer.getId());
|
||||
assertThat(beer.getId()).isEqualTo("001");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -208,8 +209,8 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
assertEquals(entity.getClass().getName(), result.get("_class"));
|
||||
assertEquals(0, result.get("attr1"));
|
||||
assertThat(result.get("_class")).isEqualTo(entity.getClass().getName());
|
||||
assertThat(result.get("attr1")).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -219,9 +220,9 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr1", 0);
|
||||
|
||||
UninitializedEntity converted = converter.read(UninitializedEntity.class, source);
|
||||
assertNull(converted.attr0);
|
||||
assertEquals(0, converted.attr1);
|
||||
assertNull(converted.attr2);
|
||||
assertThat(converted.attr0).isNull();
|
||||
assertThat(converted.attr1).isEqualTo(0);
|
||||
assertThat(converted.attr2).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -242,10 +243,10 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
assertEquals(attr0, result.get("attr0"));
|
||||
assertEquals(attr1, result.get("attr1"));
|
||||
assertEquals(attr2, result.get("attr2"));
|
||||
assertEquals(attr3, result.get("attr3"));
|
||||
assertThat(result.get("attr0")).isEqualTo(attr0);
|
||||
assertThat(result.get("attr1")).isEqualTo(attr1);
|
||||
assertThat(result.get("attr2")).isEqualTo(attr2);
|
||||
assertThat(result.get("attr3")).isEqualTo(attr3);
|
||||
|
||||
CouchbaseDocument cattr0 = new CouchbaseDocument();
|
||||
cattr0.put("foo", "bar");
|
||||
@@ -266,10 +267,10 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr3", cattr3);
|
||||
|
||||
MapEntity readConverted = converter.read(MapEntity.class, source);
|
||||
assertEquals(attr0, readConverted.attr0);
|
||||
assertEquals(attr1, readConverted.attr1);
|
||||
assertEquals(attr2, readConverted.attr2);
|
||||
assertEquals(attr3, readConverted.attr3);
|
||||
assertThat(readConverted.attr0).isEqualTo(attr0);
|
||||
assertThat(readConverted.attr1).isEqualTo(attr1);
|
||||
assertThat(readConverted.attr2).isEqualTo(attr2);
|
||||
assertThat(readConverted.attr3).isEqualTo(attr3);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -287,9 +288,9 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
assertEquals(attr0, result.get("attr0"));
|
||||
assertEquals(attr1, result.get("attr1"));
|
||||
assertEquals(attr2, result.get("attr2"));
|
||||
assertThat(result.get("attr0")).isEqualTo(attr0);
|
||||
assertThat(result.get("attr1")).isEqualTo(attr1);
|
||||
assertThat(result.get("attr2")).isEqualTo(attr2);
|
||||
|
||||
CouchbaseDocument source = new CouchbaseDocument();
|
||||
source.put("_class", ListEntity.class.getName());
|
||||
@@ -304,10 +305,10 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr2", cattr2);
|
||||
|
||||
ListEntity readConverted = converter.read(ListEntity.class, source);
|
||||
assertEquals(2, readConverted.attr0.size());
|
||||
assertEquals(0, readConverted.attr1.size());
|
||||
assertEquals(1, readConverted.attr2.size());
|
||||
assertEquals(2, readConverted.attr2.get(0).size());
|
||||
assertThat(readConverted.attr0.size()).isEqualTo(2);
|
||||
assertThat(readConverted.attr1.size()).isEqualTo(0);
|
||||
assertThat(readConverted.attr2.size()).isEqualTo(1);
|
||||
assertThat(readConverted.attr2.get(0).size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -325,9 +326,9 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
assertEquals(attr0.size(), ((Collection) result.get("attr0")).size());
|
||||
assertEquals(attr1.size(), ((Collection) result.get("attr1")).size());
|
||||
assertEquals(attr2.size(), ((Collection) result.get("attr2")).size());
|
||||
assertThat(((Collection) result.get("attr0")).size()).isEqualTo(attr0.size());
|
||||
assertThat(((Collection) result.get("attr1")).size()).isEqualTo(attr1.size());
|
||||
assertThat(((Collection) result.get("attr2")).size()).isEqualTo(attr2.size());
|
||||
|
||||
CouchbaseList cattr0 = new CouchbaseList();
|
||||
cattr0.put("foo");
|
||||
@@ -345,9 +346,9 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("attr2", cattr2);
|
||||
|
||||
SetEntity readConverted = converter.read(SetEntity.class, source);
|
||||
assertEquals(attr0, readConverted.attr0);
|
||||
assertEquals(attr1, readConverted.attr1);
|
||||
assertEquals(attr2, readConverted.attr2);
|
||||
assertThat(readConverted.attr0).isEqualTo(attr0);
|
||||
assertThat(readConverted.attr1).isEqualTo(attr1);
|
||||
assertThat(readConverted.attr2).isEqualTo(attr2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -363,10 +364,10 @@ public class MappingCouchbaseConverterTests {
|
||||
converter.write(entity, converted);
|
||||
Map<String, Object> result = converted.export();
|
||||
|
||||
assertEquals(entity.getClass().getName(), result.get("_class"));
|
||||
assertEquals(new HashMap<String, Object>() {{
|
||||
put("emailAddr", email);
|
||||
}}, result.get("email"));
|
||||
assertThat(result.get("_class")).isEqualTo(entity.getClass().getName());
|
||||
assertThat(result.get("email")).isEqualTo(new HashMap<String, Object>() {{
|
||||
put("emailAddr", email);
|
||||
}});
|
||||
|
||||
CouchbaseDocument source = new CouchbaseDocument();
|
||||
source.put("_class", ValueEntity.class.getName());
|
||||
@@ -378,9 +379,9 @@ public class MappingCouchbaseConverterTests {
|
||||
source.put("listOfEmails", listOfEmailsDoc);
|
||||
|
||||
ValueEntity readConverted = converter.read(ValueEntity.class, source);
|
||||
assertEquals(addy.emailAddr, readConverted.email.emailAddr);
|
||||
assertEquals(listOfEmails.get(0).emailAddr,
|
||||
readConverted.listOfEmails.get(0).emailAddr);
|
||||
assertThat(readConverted.email.emailAddr).isEqualTo(addy.emailAddr);
|
||||
assertThat(readConverted.listOfEmails.get(0).emailAddr)
|
||||
.isEqualTo(listOfEmails.get(0).emailAddr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -419,16 +420,20 @@ public class MappingCouchbaseConverterTests {
|
||||
mapOfValuesDoc.put("val2", value2Str);
|
||||
source.put("mapOfValues", mapOfValuesDoc);
|
||||
|
||||
assertEquals(((CouchbaseList)converted.getPayload().get("listOfValues")).get(0), valueStr);
|
||||
assertEquals(((CouchbaseList)converted.getPayload().get("listOfValues")).get(1), value2Str);
|
||||
assertEquals(source.export().toString(), converted.export().toString());
|
||||
assertThat(valueStr)
|
||||
.isEqualTo(((CouchbaseList) converted.getPayload().get("listOfValues"))
|
||||
.get(0));
|
||||
assertThat(value2Str)
|
||||
.isEqualTo(((CouchbaseList) converted.getPayload().get("listOfValues"))
|
||||
.get(1));
|
||||
assertThat(converted.export().toString()).isEqualTo(source.export().toString());
|
||||
|
||||
CustomEntity readConverted = converter.read(CustomEntity.class, source);
|
||||
assertEquals(value, readConverted.value);
|
||||
assertEquals(listOfValues.get(0), readConverted.listOfValues.get(0));
|
||||
assertEquals(listOfValues.get(1), readConverted.listOfValues.get(1));
|
||||
assertEquals(mapOfValues.get("val1"), readConverted.mapOfValues.get("val1"));
|
||||
assertEquals(mapOfValues.get("val2"), readConverted.mapOfValues.get("val2"));
|
||||
assertThat(readConverted.value).isEqualTo(value);
|
||||
assertThat(readConverted.listOfValues.get(0)).isEqualTo(listOfValues.get(0));
|
||||
assertThat(readConverted.listOfValues.get(1)).isEqualTo(listOfValues.get(1));
|
||||
assertThat(readConverted.mapOfValues.get("val1")).isEqualTo(mapOfValues.get("val1"));
|
||||
assertThat(readConverted.mapOfValues.get("val2")).isEqualTo(mapOfValues.get("val2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -465,13 +470,16 @@ public class MappingCouchbaseConverterTests {
|
||||
mapOfObjectsDoc.put("obj0", objectDoc);
|
||||
mapOfObjectsDoc.put("obj1", objectDoc);
|
||||
source.put("mapOfObjects", mapOfObjectsDoc);
|
||||
assertEquals(source.export().toString(), converted.export().toString());
|
||||
assertThat(converted.export().toString()).isEqualTo(source.export().toString());
|
||||
|
||||
CustomObjectEntity readConverted = converter.read(CustomObjectEntity.class, source);
|
||||
assertEquals(addy.weight, readConverted.object.weight);
|
||||
assertEquals(listOfObjects.get(0).weight, readConverted.listOfObjects.get(0).weight);
|
||||
assertEquals(mapOfObjects.get("obj0").weight, readConverted.mapOfObjects.get("obj0").weight);
|
||||
assertEquals(mapOfObjects.get("obj1").weight, readConverted.mapOfObjects.get("obj1").weight);
|
||||
assertThat(readConverted.object.weight).isEqualTo(addy.weight);
|
||||
assertThat(readConverted.listOfObjects.get(0).weight)
|
||||
.isEqualTo(listOfObjects.get(0).weight);
|
||||
assertThat(readConverted.mapOfObjects.get("obj0").weight)
|
||||
.isEqualTo(mapOfObjects.get("obj0").weight);
|
||||
assertThat(readConverted.mapOfObjects.get("obj1").weight)
|
||||
.isEqualTo(mapOfObjects.get("obj1").weight);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -483,15 +491,19 @@ public class MappingCouchbaseConverterTests {
|
||||
|
||||
CouchbaseDocument converted = new CouchbaseDocument();
|
||||
converter.write(entity, converted);
|
||||
assertEquals(created.getTime(), converted.getPayload().get("created"));
|
||||
assertEquals(modified.getTimeInMillis() / 1000, converted.getPayload().get("modified"));
|
||||
assertThat(converted.getPayload().get("created")).isEqualTo(created.getTime());
|
||||
assertThat(converted.getPayload().get("modified"))
|
||||
.isEqualTo(modified.getTimeInMillis() / 1000);
|
||||
LocalDateTimeToLongConverter localDateTimeToDateconverter = LocalDateTimeToLongConverter.INSTANCE;
|
||||
assertEquals(localDateTimeToDateconverter.convert(deleted), converted.getPayload().get("deleted"));
|
||||
assertThat(converted.getPayload().get("deleted"))
|
||||
.isEqualTo(localDateTimeToDateconverter.convert(deleted));
|
||||
|
||||
DateEntity read = converter.read(DateEntity.class, converted);
|
||||
assertEquals(created.getTime(), read.created.getTime());
|
||||
assertEquals(modified.getTimeInMillis() / 1000, read.modified.getTimeInMillis() / 1000);
|
||||
assertEquals(deleted.truncatedTo(ChronoUnit.MILLIS), read.deleted.truncatedTo(ChronoUnit.MILLIS));
|
||||
assertThat(read.created.getTime()).isEqualTo(created.getTime());
|
||||
assertThat(read.modified.getTimeInMillis() / 1000)
|
||||
.isEqualTo(modified.getTimeInMillis() / 1000);
|
||||
assertThat(read.deleted.truncatedTo(ChronoUnit.MILLIS))
|
||||
.isEqualTo(deleted.truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -500,7 +512,7 @@ public class MappingCouchbaseConverterTests {
|
||||
CouchbaseDocument converted = new CouchbaseDocument();
|
||||
converter.write(entity, converted);
|
||||
|
||||
assertEquals("realId", converted.getId());
|
||||
assertThat(converted.getId()).isEqualTo("realId");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -509,7 +521,7 @@ public class MappingCouchbaseConverterTests {
|
||||
CouchbaseDocument converted = new CouchbaseDocument();
|
||||
converter.write(entity, converted);
|
||||
|
||||
assertEquals("springId", converted.getId());
|
||||
assertThat(converted.getId()).isEqualTo("springId");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -521,9 +533,9 @@ public class MappingCouchbaseConverterTests {
|
||||
converter.setEnableStrictFieldChecking(true);
|
||||
converter.write(entity,converted);
|
||||
|
||||
assertTrue(converted.getId() != null);
|
||||
assertTrue(converted.getPayload().containsKey("annotatedField"));
|
||||
assertFalse(converted.getPayload().containsKey("nonAnnotatedField"));
|
||||
assertThat(converted.getId() != null).isTrue();
|
||||
assertThat(converted.getPayload().containsKey("annotatedField")).isTrue();
|
||||
assertThat(converted.getPayload().containsKey("nonAnnotatedField")).isFalse();
|
||||
} finally {
|
||||
converter.setEnableStrictFieldChecking(false);
|
||||
}
|
||||
@@ -538,9 +550,9 @@ public class MappingCouchbaseConverterTests {
|
||||
converter.setEnableStrictFieldChecking(false);
|
||||
converter.write(entity,converted);
|
||||
|
||||
assertTrue(converted.getId() != null);
|
||||
assertTrue(converted.getPayload().containsKey("annotatedField"));
|
||||
assertTrue(converted.getPayload().containsKey("nonAnnotatedField"));
|
||||
assertThat(converted.getId() != null).isTrue();
|
||||
assertThat(converted.getPayload().containsKey("annotatedField")).isTrue();
|
||||
assertThat(converted.getPayload().containsKey("nonAnnotatedField")).isTrue();
|
||||
} finally {
|
||||
converter.setEnableStrictFieldChecking(false);
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.core.mapping.event;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -27,6 +25,8 @@ import org.springframework.test.context.TestExecutionListeners;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Michael Nitschinger
|
||||
*/
|
||||
@@ -49,9 +49,9 @@ public class AbstractCouchbaseEventListenerTests {
|
||||
|
||||
couchbaseTemplate.save(new User("john smith", 18));
|
||||
|
||||
assertEquals(beforeSave + 1, eventListener.onBeforeSaveEvents.size());
|
||||
assertEquals(afterSave + 1, eventListener.onAfterSaveEvents.size());
|
||||
assertEquals(beforeConvert + 1, eventListener.onBeforeConvertEvents.size());
|
||||
assertThat(eventListener.onBeforeSaveEvents.size()).isEqualTo(beforeSave + 1);
|
||||
assertThat(eventListener.onAfterSaveEvents.size()).isEqualTo(afterSave + 1);
|
||||
assertThat(eventListener.onBeforeConvertEvents.size()).isEqualTo(beforeConvert + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.core.mapping.event;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import javax.validation.ConstraintViolationException;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -28,6 +25,9 @@ import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author Michael Nitschinger
|
||||
*/
|
||||
@@ -44,10 +44,10 @@ public class ValidatingCouchbaseEventListenerTests {
|
||||
|
||||
try {
|
||||
template.save(user);
|
||||
fail();
|
||||
fail("Expected ConstraintViolationException");
|
||||
}
|
||||
catch (ConstraintViolationException e) {
|
||||
assertThat(e.getConstraintViolations().size(), equalTo(2));
|
||||
assertThat(e.getConstraintViolations().size()).isEqualTo(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,19 +16,19 @@
|
||||
|
||||
package org.springframework.data.couchbase.monitor;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.isEmptyString;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
|
||||
import com.couchbase.client.java.Bucket;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.couchbase.ContainerResourceRunner;
|
||||
import org.springframework.data.couchbase.IntegrationTestApplicationConfig;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* @author Michael Nitschinger
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ public class ClientInfoIntegrationTests {
|
||||
@Test
|
||||
public void hostNames() {
|
||||
String hostnames = ci.getHostNames();
|
||||
assertThat(hostnames, not(isEmptyString()));
|
||||
assertThat(hostnames).isNotEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,24 +16,20 @@
|
||||
|
||||
package org.springframework.data.couchbase.monitor;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
||||
import com.couchbase.client.java.Bucket;
|
||||
import org.junit.Before;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
;
|
||||
import org.springframework.data.couchbase.ContainerResourceRunner;
|
||||
import org.springframework.data.couchbase.IntegrationTestApplicationConfig;
|
||||
import org.springframework.data.couchbase.TestContainerResource;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* @author Michael Nitschinger
|
||||
*/
|
||||
@@ -57,12 +53,12 @@ public class ClusterInfoIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void totalDiskAssigned() {
|
||||
assertThat(ci.getTotalDiskAssigned(), greaterThan(0L));
|
||||
assertThat(ci.getTotalDiskAssigned()).isGreaterThan(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void totalRAMUsed() {
|
||||
assertThat(ci.getTotalRAMUsed(), greaterThan(0L));
|
||||
assertThat(ci.getTotalRAMUsed()).isGreaterThan(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.couchbase.core.mapping.id.GenerationStrategy.UNIQUE;
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ public class CouchbaseIdGenerationIntegrationTests {
|
||||
public void idFieldEntityIsFillWithGeneratedValueOnSave() {
|
||||
SimpleClassWithGeneratedIdValueUsingUUID entity = new SimpleClassWithGeneratedIdValueUsingUUID();
|
||||
SimpleClassWithGeneratedIdValueUsingUUID savedEntity = entityRepository.save(entity);
|
||||
assertThat("Expected generated value", savedEntity.id != null);
|
||||
assertThat(savedEntity.id != null).as("Expected generated value").isTrue();
|
||||
if (entityRepository.existsById(savedEntity.id)) {
|
||||
entityRepository.existsById(savedEntity.id);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class CouchbaseIdGenerationIntegrationTests {
|
||||
SimpleClassWithGeneratedIdValueUsingUUID entity = new SimpleClassWithGeneratedIdValueUsingUUID();
|
||||
entity.setId(id);
|
||||
SimpleClassWithGeneratedIdValueUsingUUID savedEntity = entityRepository.save(entity);
|
||||
assertThat("Expected same id instance", savedEntity.id == id);
|
||||
assertThat(savedEntity.id == id).as("Expected same id instance").isTrue();
|
||||
if (entityRepository.existsById(savedEntity.id)) {
|
||||
entityRepository.existsById(savedEntity.id);
|
||||
}
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -31,10 +26,10 @@ import com.couchbase.client.java.document.json.JsonObject;
|
||||
import com.couchbase.client.java.view.Stale;
|
||||
import com.couchbase.client.java.view.ViewQuery;
|
||||
import com.couchbase.client.java.view.ViewResult;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
@@ -47,6 +42,9 @@ import org.springframework.data.mapping.PropertyReferenceException;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* @author David Harrigan
|
||||
* @author Simon Baslé
|
||||
@@ -76,7 +74,7 @@ public class CouchbaseRepositoryViewIntegrationTests {
|
||||
public void shouldFindAllWithCustomView() {
|
||||
client.query(ViewQuery.from("user", "customFindAllView").stale(Stale.FALSE));
|
||||
Iterable<User> allUsers = repository.findAll();
|
||||
assertThat(allUsers, Matchers.iterableWithSize(100));
|
||||
assertThat(allUsers).hasSize(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,22 +83,23 @@ public class CouchbaseRepositoryViewIntegrationTests {
|
||||
.reduce().stale(Stale.FALSE));
|
||||
final Object clientRowValue = clientResult.allRows().get(0).value();
|
||||
final long value = repository.count();
|
||||
assertThat(value, is(100L));
|
||||
assertThat(clientRowValue, instanceOf(Number.class));
|
||||
assertThat(((Number) clientRowValue).longValue(), is(value));
|
||||
assertThat(value).isEqualTo(100L);
|
||||
assertThat(clientRowValue).isInstanceOf(Number.class);
|
||||
assertThat(((Number) clientRowValue).longValue()).isEqualTo(value);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDetectMethodNameWithoutPropertyAndIssueGenericQueryOnView() {
|
||||
Iterable<User> users = repository.findRandomMethodName();
|
||||
assertNotNull(users);
|
||||
assertTrue(users.iterator().hasNext());
|
||||
assertThat(users).isNotNull();
|
||||
assertThat(users.iterator().hasNext()).isTrue();
|
||||
|
||||
try {
|
||||
repository.findIncorrectExplicitView();
|
||||
fail("Expected InvalidDataAccessResourceException");
|
||||
} catch (InvalidDataAccessResourceUsageException e) {
|
||||
assertTrue(e.getMessage(), e.getMessage().startsWith("View user/allSomething does not exist"));
|
||||
assertThat(e.getMessage().startsWith("View user/allSomething does not exist"))
|
||||
.as(e.getMessage()).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,18 +111,18 @@ public class CouchbaseRepositoryViewIntegrationTests {
|
||||
@Test
|
||||
public void shouldDeriveViewParametersAndReduce() {
|
||||
long count = repository.countByUsernameGreaterThanEqualAndUsernameLessThan("uname-8", "uname-9");
|
||||
assertEquals(12, count);
|
||||
assertThat(count).isEqualTo(12);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDeriveViewParametersAndReduceNonNumerical() {
|
||||
JsonObject reduceResult = repository.findByAgeLessThan(50);
|
||||
|
||||
assertNotNull(reduceResult);
|
||||
assertEquals(51, (long) reduceResult.getLong("count"));
|
||||
assertEquals(50, (long) reduceResult.getLong("max"));
|
||||
assertEquals(0, (long) reduceResult.getLong("min"));
|
||||
assertEquals(1275, (long) reduceResult.getLong("sum"));
|
||||
assertThat(reduceResult).isNotNull();
|
||||
assertThat((long) reduceResult.getLong("count")).isEqualTo(51);
|
||||
assertThat((long) reduceResult.getLong("max")).isEqualTo(50);
|
||||
assertThat((long) reduceResult.getLong("min")).isEqualTo(0);
|
||||
assertThat((long) reduceResult.getLong("sum")).isEqualTo(1275);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,9 +136,9 @@ public class CouchbaseRepositoryViewIntegrationTests {
|
||||
User u2 = repository.findByUsernameIs(middleKey).get(0);
|
||||
User u3 = repository.findByUsernameIs(highKey).get(0);
|
||||
|
||||
assertEquals(lowKey, u1.getUsername());
|
||||
assertEquals(middleKey, u2.getUsername());
|
||||
assertEquals(highKey, u3.getUsername());
|
||||
assertThat(u1.getUsername()).isEqualTo(lowKey);
|
||||
assertThat(u2.getUsername()).isEqualTo(middleKey);
|
||||
assertThat(u3.getUsername()).isEqualTo(highKey);
|
||||
|
||||
List<User> in = repository.findAllByUsernameIn(keys);
|
||||
List<User> gteLte = repository.findByUsernameGreaterThanEqualAndUsernameLessThanEqual(lowKey, highKey);
|
||||
@@ -148,17 +147,17 @@ public class CouchbaseRepositoryViewIntegrationTests {
|
||||
|
||||
// the results are unordered, so compare using Set
|
||||
Set<User> expected = new HashSet<>(Arrays.asList(u1, u2, u3));
|
||||
assertEquals(expected, new HashSet<>(in));
|
||||
assertEquals(expected, new HashSet<>(gteLte));
|
||||
assertEquals(expected, new HashSet<>(between));
|
||||
assertEquals(expected, new HashSet<>(gteLimited));
|
||||
assertThat(new HashSet<>(in)).isEqualTo(expected);
|
||||
assertThat(new HashSet<>(gteLte)).isEqualTo(expected);
|
||||
assertThat(new HashSet<>(between)).isEqualTo(expected);
|
||||
assertThat(new HashSet<>(gteLimited)).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDeriveToEmptyClause() {
|
||||
List<User> users = repository.findAllByUsername();
|
||||
assertNotNull(users);
|
||||
assertEquals(100, users.size());
|
||||
assertThat(users).isNotNull();
|
||||
assertThat(users.size()).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,20 +166,22 @@ public class CouchbaseRepositoryViewIntegrationTests {
|
||||
repository.findByIncorrectView();
|
||||
fail("Expected InvalidDataAccessResourceException");
|
||||
} catch (InvalidDataAccessResourceUsageException e) {
|
||||
assertTrue(e.getMessage(), e.getMessage().startsWith("View user/byIncorrectView does not exist"));
|
||||
assertThat(e.getMessage().startsWith("View user/byIncorrectView does not exist"))
|
||||
.as(e.getMessage()).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDetermineViewNameFromCountPrefixAndReduce() {
|
||||
long count = repository.countCustomFindAllView();
|
||||
assertEquals(100, count);
|
||||
assertThat(count).isEqualTo(100);
|
||||
|
||||
try {
|
||||
repository.countCustomFindInvalid();
|
||||
fail("Expected InvalidDataAccessResourceException");
|
||||
} catch (InvalidDataAccessResourceUsageException e) {
|
||||
assertTrue(e.getMessage(), e.getMessage().startsWith("View user/customFindInvalid does not exist"));
|
||||
assertThat(e.getMessage().startsWith("View user/customFindInvalid does not exist"))
|
||||
.as(e.getMessage()).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -67,9 +68,9 @@ public class DimensionalQueryIntegrationTests {
|
||||
|
||||
List<Party> parties = repository.findByLocationWithin(zone);
|
||||
|
||||
assertEquals(4, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(4);
|
||||
for (Party party : parties) {
|
||||
assertTrue(expectedKeys.contains(party.getKey()));
|
||||
assertThat(expectedKeys.contains(party.getKey())).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,24 +81,24 @@ public class DimensionalQueryIntegrationTests {
|
||||
expectedKeys.add("testparty-1");
|
||||
|
||||
List<Party> parties = repository.findByLocationNear(new Point(0, 0), new Distance(1.5));
|
||||
assertEquals(2, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(2);
|
||||
for (Party party : parties) {
|
||||
assertTrue(expectedKeys.contains(party.getKey()));
|
||||
assertThat(expectedKeys.contains(party.getKey())).isTrue();
|
||||
}
|
||||
|
||||
//with this one, testparty-2 is within the bounding box but not in correct distance
|
||||
parties = repository.findByLocationNear(new Point(0, 0), new Distance(2.5));
|
||||
assertEquals(2, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(2);
|
||||
for (Party party : parties) {
|
||||
assertTrue(expectedKeys.contains(party.getKey()));
|
||||
assertThat(expectedKeys.contains(party.getKey())).isTrue();
|
||||
}
|
||||
|
||||
//here we adjust the distance so that testparty-2 falls just on the edge
|
||||
parties = repository.findByLocationNear(new Point(0, 0), new Distance(2.8284271247461903));
|
||||
expectedKeys.add("testparty-2");
|
||||
assertEquals(3, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(3);
|
||||
for (Party party : parties) {
|
||||
assertTrue(expectedKeys.contains(party.getKey()));
|
||||
assertThat(expectedKeys.contains(party.getKey())).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +118,8 @@ public class DimensionalQueryIntegrationTests {
|
||||
//first check the zone contains 4 parties
|
||||
List<Party> allPartiesInZone = repository.findByLocationWithinAndAttendeesGreaterThan(zone, -1);
|
||||
List<Party> allPartiesInZoneWithoutAttendeeCriteria = repository.findByLocationWithin(zone);
|
||||
assertEquals(allPartiesInZone.toString(), 4, allPartiesInZone.size());
|
||||
assertEquals(allPartiesInZoneWithoutAttendeeCriteria, allPartiesInZone);
|
||||
assertThat(allPartiesInZone.size()).as(allPartiesInZone.toString()).isEqualTo(4);
|
||||
assertThat(allPartiesInZone).isEqualTo(allPartiesInZoneWithoutAttendeeCriteria);
|
||||
|
||||
//check parties are limited by the attendees
|
||||
List<Party> parties = repository.findByLocationWithinAndAttendeesGreaterThan(zone, 140);
|
||||
@@ -126,10 +127,10 @@ public class DimensionalQueryIntegrationTests {
|
||||
System.out.println(party.getKey() + " : " + party.getLocation() + " " + party.getAttendees());
|
||||
}
|
||||
|
||||
assertEquals(parties.toString(), 2, parties.size());
|
||||
assertThat(parties.size()).as(parties.toString()).isEqualTo(2);
|
||||
for (Party party : parties) {
|
||||
assertTrue(party.getAttendees() >= 140);
|
||||
assertTrue(expectedKeys.contains(party.getKey()));
|
||||
assertThat(party.getAttendees() >= 140).isTrue();
|
||||
assertThat(expectedKeys.contains(party.getKey())).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,17 +142,17 @@ public class DimensionalQueryIntegrationTests {
|
||||
Circle zoneEmpty = new Circle(new Point(6,6), new Distance(3));
|
||||
|
||||
List<Party> parties = repository.findByLocationWithin(zoneBboxFalse);
|
||||
assertEquals(0, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(0);
|
||||
|
||||
parties = repository.findByLocationWithin(zoneEdge);
|
||||
assertEquals(1, parties.size());
|
||||
assertEquals("testparty-0", parties.get(0).getKey());
|
||||
assertThat(parties.size()).isEqualTo(1);
|
||||
assertThat(parties.get(0).getKey()).isEqualTo("testparty-0");
|
||||
|
||||
parties = repository.findByLocationWithin(zoneInside);
|
||||
assertEquals(12, parties.size()); //all the parties except the special one at 100, 100
|
||||
assertThat(parties.size()).isEqualTo(12); //all the parties except the special one at 100, 100
|
||||
|
||||
parties = repository.findByLocationWithin(zoneEmpty);
|
||||
assertEquals(0, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,15 +163,15 @@ public class DimensionalQueryIntegrationTests {
|
||||
|
||||
List<Party> parties = repository.findByLocationWithin(zone1);
|
||||
|
||||
assertEquals(1, parties.size());
|
||||
assertEquals("testparty-0", parties.get(0).getKey());
|
||||
assertThat(parties.size()).isEqualTo(1);
|
||||
assertThat(parties.get(0).getKey()).isEqualTo("testparty-0");
|
||||
|
||||
parties = repository.findByLocationWithin(zone2);
|
||||
|
||||
assertEquals(12, parties.size()); //all the parties except the special one at 100, 100
|
||||
assertThat(parties.size()).isEqualTo(12); //all the parties except the special one at 100, 100
|
||||
|
||||
parties = repository.findByLocationWithin(zoneEmpty);
|
||||
assertEquals(0, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -207,16 +208,19 @@ public class DimensionalQueryIntegrationTests {
|
||||
new Point(6, 3));
|
||||
|
||||
List<Party> parties = repository.findByLocationWithin(zoneFalsePositive);
|
||||
assertEquals("points outside a polygon but within bounding box shouldn't be considered within", 0, parties.size());
|
||||
assertThat(parties.size())
|
||||
.as("points outside a polygon but within bounding box shouldn't be considered within")
|
||||
.isEqualTo(0);
|
||||
|
||||
parties = repository.findByLocationWithin(zoneEdge);
|
||||
assertEquals("point on edge of a polygon shouldn't be considered within", 0, parties.size());
|
||||
assertThat(parties.size())
|
||||
.as("point on edge of a polygon shouldn't be considered within").isEqualTo(0);
|
||||
|
||||
parties = repository.findByLocationWithin(zoneWithin);
|
||||
assertEquals(12, parties.size()); //all the parties except the special one at 100, 100
|
||||
assertThat(parties.size()).isEqualTo(12); //all the parties except the special one at 100, 100
|
||||
|
||||
parties = repository.findByLocationWithin(zoneEmpty);
|
||||
assertEquals(0, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -230,15 +234,15 @@ public class DimensionalQueryIntegrationTests {
|
||||
|
||||
List<Party> parties = repository.findByLocationWithin(zone1LowerLeft, zone1UpperRight);
|
||||
|
||||
assertEquals(1, parties.size());
|
||||
assertEquals("testparty-0", parties.get(0).getKey());
|
||||
assertThat(parties.size()).isEqualTo(1);
|
||||
assertThat(parties.get(0).getKey()).isEqualTo("testparty-0");
|
||||
|
||||
parties = repository.findByLocationWithin(zone2LowerLeft, zone2UpperRight);
|
||||
|
||||
assertEquals(12, parties.size()); //all the parties except the special one at 100, 100
|
||||
assertThat(parties.size()).isEqualTo(12); //all the parties except the special one at 100, 100
|
||||
|
||||
parties = repository.findByLocationWithin(zoneEmptyLowerLeft, zoneEmptyUpperRight);
|
||||
assertEquals(0, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -259,13 +263,13 @@ public class DimensionalQueryIntegrationTests {
|
||||
List<Party> fromZone = repository.findByLocationWithin(zone);
|
||||
List<Party> fromPoints = repository.findByLocationWithin(points);
|
||||
|
||||
assertEquals(4, fromZone.size());
|
||||
assertEquals(fromZone, fromPoints);
|
||||
assertThat(fromZone.size()).isEqualTo(4);
|
||||
assertThat(fromPoints).isEqualTo(fromZone);
|
||||
Set<String> keys = new HashSet<String>();
|
||||
for (Party party : fromZone) {
|
||||
keys.add(party.getKey());
|
||||
}
|
||||
assertEquals(expectedKeys, keys);
|
||||
assertThat(keys).isEqualTo(expectedKeys);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -274,14 +278,16 @@ public class DimensionalQueryIntegrationTests {
|
||||
repository.findByLocationWithin(new Point(0, 0));
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("Cannot compute a bounding box for within, 2 Point needed, missing parameter", e.getMessage());
|
||||
assertThat(e.getMessage())
|
||||
.isEqualTo("Cannot compute a bounding box for within, 2 Point needed, missing parameter");
|
||||
}
|
||||
|
||||
try {
|
||||
repository.findByLocationWithin(new Point(0, 0), null);
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("Cannot compute a bounding box for within, 2 Point needed, got null", e.getMessage());
|
||||
assertThat(e.getMessage())
|
||||
.isEqualTo("Cannot compute a bounding box for within, 2 Point needed, got null");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,22 +295,22 @@ public class DimensionalQueryIntegrationTests {
|
||||
public void testProvidingOneJsonArrayIsRejected() {
|
||||
try {
|
||||
List<Party> parties = repository.findByLocationWithin(JsonArray.from(0,0));
|
||||
fail();
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("2 JsonArray required for within: startRange and endRange, missing parameter", e.getMessage());
|
||||
assertThat(e.getMessage())
|
||||
.isEqualTo("2 JsonArray required for within: startRange and endRange, missing parameter");
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = CouchbaseQueryExecutionException.class)
|
||||
public void testJsonArrayWithNonNumericalValueProducesServerSideError() {
|
||||
repository.findByLocationWithin(JsonArray.from("toto", -2), JsonArray.from(4, 1));
|
||||
fail();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithinJsonArrayRangesFiltersLocationAndAttendees() {
|
||||
List<Party> parties = repository.findByLocationWithin(JsonArray.from(0, -4, 115), JsonArray.from(4, 1, 132));
|
||||
assertEquals(2, parties.size());
|
||||
assertThat(parties.size()).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -314,11 +320,14 @@ public class DimensionalQueryIntegrationTests {
|
||||
repository.findByLocationIsWithin(new Point(0,0), null);
|
||||
fail("expected IllegalArgumentException from SpatialViewQueryCreator");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("Cannot compute a bounding box for within, 2 Point needed, got null", e.getMessage());
|
||||
assertThat(e.getMessage())
|
||||
.isEqualTo("Cannot compute a bounding box for within, 2 Point needed, got null");
|
||||
}
|
||||
|
||||
//when it is correctly formed, it actually returns data
|
||||
assertEquals(1, repository.findByLocationIsWithin(new Point(-10.5, -0.5), new Point(0.5, 10.5)).size());
|
||||
assertThat(repository
|
||||
.findByLocationIsWithin(new Point(-10.5, -0.5), new Point(0.5, 10.5)).size())
|
||||
.isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -331,7 +340,7 @@ public class DimensionalQueryIntegrationTests {
|
||||
final List<Party> parties1 = repository.findByLocationWithin(box1);
|
||||
final List<Party> parties2 = repository.findByLocationWithin(box2);
|
||||
|
||||
assertEquals(3, parties1.size());
|
||||
assertNotEquals(parties1, parties2);
|
||||
assertThat(parties1.size()).isEqualTo(3);
|
||||
assertThat(parties2).isNotEqualTo(parties1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -95,10 +95,11 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
Iterable<Party> allByAttendanceDesc = repository.findAll(Sort.by(Sort.Direction.DESC, "attendees"));
|
||||
long previousAttendance = Long.MAX_VALUE;
|
||||
for (Party party : allByAttendanceDesc) {
|
||||
assertTrue(party.getAttendees() <= previousAttendance);
|
||||
assertThat(party.getAttendees() <= previousAttendance).isTrue();
|
||||
previousAttendance = party.getAttendees();
|
||||
}
|
||||
assertFalse("Expected to find several parties", previousAttendance == Long.MAX_VALUE);
|
||||
assertThat(previousAttendance == Long.MAX_VALUE)
|
||||
.as("Expected to find several parties").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -107,11 +108,11 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
String previousDesc = null;
|
||||
for (Party party : parties) {
|
||||
if (previousDesc != null) {
|
||||
assertTrue(party.getDescription().compareTo(previousDesc) <= 0);
|
||||
assertThat(party.getDescription().compareTo(previousDesc) <= 0).isTrue();
|
||||
}
|
||||
previousDesc = party.getDescription();
|
||||
}
|
||||
assertNotNull("Expected to find several parties", previousDesc);
|
||||
assertThat(previousDesc).as("Expected to find several parties").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,11 +121,12 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
String previousDesc = null;
|
||||
for (Party party : parties) {
|
||||
if (previousDesc != null) {
|
||||
assertTrue(party.getDescription().compareToIgnoreCase(previousDesc) <= 0);
|
||||
assertThat(party.getDescription().compareToIgnoreCase(previousDesc) <= 0)
|
||||
.isTrue();
|
||||
}
|
||||
previousDesc = party.getDescription();
|
||||
}
|
||||
assertNotNull("Expected to find several parties", previousDesc);
|
||||
assertThat(previousDesc).as("Expected to find several parties").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -132,8 +134,9 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
Pageable pageable = PageRequest.of(0, 8);
|
||||
|
||||
Page<Party> page1 = repository.findAll(pageable);
|
||||
assertTrue("Query for parties should be atleast 12", page1.getTotalElements() >= 12);
|
||||
assertEquals(8, page1.getNumberOfElements());
|
||||
assertThat(page1.getTotalElements() >= 12)
|
||||
.as("Query for parties should be atleast 12").isTrue();
|
||||
assertThat(page1.getNumberOfElements()).isEqualTo(8);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,14 +144,15 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
Pageable pageable = PageRequest.of(0, 8, Sort.Direction.DESC, "attendees");
|
||||
|
||||
Page<Party> page1 = repository.findAll(pageable);
|
||||
assertTrue("Query for parties should be atleast 12", page1.getTotalElements() >= 12);
|
||||
assertEquals(8, page1.getNumberOfElements());
|
||||
assertThat(page1.getTotalElements() >= 12)
|
||||
.as("Query for parties should be atleast 12").isTrue();
|
||||
assertThat(page1.getNumberOfElements()).isEqualTo(8);
|
||||
|
||||
List<Party> parties = page1.getContent();
|
||||
Long previousAttendees = null;
|
||||
for (Party party : parties) {
|
||||
if (previousAttendees != null) {
|
||||
assertTrue(party.getAttendees() <= previousAttendees);
|
||||
assertThat(party.getAttendees() <= previousAttendees).isTrue();
|
||||
}
|
||||
previousAttendees = party.getAttendees();
|
||||
}
|
||||
@@ -157,30 +161,31 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void testWrapWhereCriteria() {
|
||||
List<Party> partyList = partyRepository.findByDescriptionOrName("MatchingDescription", "partyName");
|
||||
assertTrue(partyList.size() == 1);
|
||||
assertThat(partyList.size() == 1).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldPageWithStringBasedQuery() {
|
||||
Pageable pageable = PageRequest.of(0, 8, Sort.Direction.DESC, "attendees");
|
||||
Page<Party> page1 = partyRepository.findPartiesWithAttendee(1, pageable);
|
||||
assertTrue("Query for parties with attendees should be atleast 12", page1.getTotalElements() >= 12);
|
||||
assertEquals(8, page1.getNumberOfElements());
|
||||
assertThat(page1.getTotalElements() >= 12)
|
||||
.as("Query for parties with attendees should be atleast 12").isTrue();
|
||||
assertThat(page1.getNumberOfElements()).isEqualTo(8);
|
||||
|
||||
List<Party> parties = page1.getContent();
|
||||
Long previousAttendees = null;
|
||||
for (Party party : parties) {
|
||||
if (previousAttendees != null) {
|
||||
assertTrue(party.getAttendees() <= previousAttendees);
|
||||
assertThat(party.getAttendees() <= previousAttendees).isTrue();
|
||||
}
|
||||
previousAttendees = party.getAttendees();
|
||||
}
|
||||
Page<Party> page2 = partyRepository.findPartiesWithAttendee(1, page1.nextPageable());
|
||||
assertEquals(8, page2.getNumberOfElements());
|
||||
assertThat(page2.getNumberOfElements()).isEqualTo(8);
|
||||
parties = page2.getContent();
|
||||
for (Party party : parties) {
|
||||
if (previousAttendees != null) {
|
||||
assertTrue(party.getAttendees() <= previousAttendees);
|
||||
assertThat(party.getAttendees() <= previousAttendees).isTrue();
|
||||
}
|
||||
previousAttendees = party.getAttendees();
|
||||
}
|
||||
@@ -197,7 +202,7 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
public void testDeleteQuery() {
|
||||
partyRepository.save(new Party("testDeleteQuery", "delete", "delete", null, 0, null));
|
||||
List<Party> partyList = partyRepository.removeByDescriptionOrName("delete", "delete");
|
||||
assertTrue(partyList.size() == 1);
|
||||
assertThat(partyList.size() == 1).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -209,8 +214,8 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
Date date = cal.getTime();
|
||||
partyRepository.save(new Party(key, "", "", date, 0, null));
|
||||
List<Party> partyList = partyRepository.getByEventDate(date);
|
||||
assertTrue(partyList.size() == 1);
|
||||
assertEquals("Key mismatch", partyList.get(0).getKey(), key);
|
||||
assertThat(partyList.size() == 1).isTrue();
|
||||
assertThat(key).as("Key mismatch").isEqualTo(partyList.get(0).getKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -218,6 +223,6 @@ public class N1qlCouchbaseRepositoryIntegrationTests {
|
||||
partyRepository.save(new Party("testN1qlQueryWithInvalidValue", "", "testN1qlQueryWithInvalidValue", null, 0, null));
|
||||
final String description = "testN1qlQueryWithInvalidValue* OR `description` LIKE \"\"";
|
||||
List<Party> partyList = partyRepository.findByDescriptionStartingWith(description);
|
||||
assertTrue(partyList.size() == 0);
|
||||
assertThat(partyList.size() == 0).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -89,11 +90,11 @@ public class N1qlCrudRepositoryIntegrationTests {
|
||||
List<Object> items = itemRepository.findAllByDescriptionNotNull();
|
||||
List<Object> parties = partyRepository.findAllByDescriptionNotNull();
|
||||
|
||||
assertTrue(items.contains(item));
|
||||
assertTrue(parties.contains(party));
|
||||
assertThat(items.contains(item)).isTrue();
|
||||
assertThat(parties.contains(party)).isTrue();
|
||||
|
||||
assertFalse(items.contains(party));
|
||||
assertFalse(parties.contains(item));
|
||||
assertThat(items.contains(party)).isFalse();
|
||||
assertThat(parties.contains(item)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -102,8 +103,8 @@ public class N1qlCrudRepositoryIntegrationTests {
|
||||
partyRepository.save(partyHasKeyword);
|
||||
List<Object> parties = partyRepository.findAllByDescriptionNotNull();
|
||||
|
||||
assertTrue(client.exists(KEY_PARTY_KEYWORD));
|
||||
assertTrue(parties.contains(partyHasKeyword));
|
||||
assertThat(client.exists(KEY_PARTY_KEYWORD)).isTrue();
|
||||
assertThat(parties.contains(partyHasKeyword)).isTrue();
|
||||
for (Object o : parties) {
|
||||
if (!(o instanceof Party)) {
|
||||
fail("expected only Party objects");
|
||||
@@ -117,7 +118,7 @@ public class N1qlCrudRepositoryIntegrationTests {
|
||||
partyRepository.save(partyHasKeyword);
|
||||
long countTotal = partyRepository.count();
|
||||
long countCustom = partyRepository.countAllByDescriptionNotNull();
|
||||
assertEquals(countTotal - 1, countCustom);
|
||||
assertThat(countCustom).isEqualTo(countTotal - 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,7 +128,7 @@ public class N1qlCrudRepositoryIntegrationTests {
|
||||
|
||||
long countTotal = partyRepository.count();
|
||||
long countCustom = partyRepository.countCustom();
|
||||
assertEquals(countTotal, countCustom);
|
||||
assertThat(countCustom).isEqualTo(countTotal);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -137,7 +138,7 @@ public class N1qlCrudRepositoryIntegrationTests {
|
||||
|
||||
long countTotal = partyRepository.count();
|
||||
long countCustom = partyRepository.countCustomPlusFive();
|
||||
assertEquals(countTotal + 5, countCustom);
|
||||
assertThat(countCustom).isEqualTo(countTotal + 5);
|
||||
}
|
||||
|
||||
@Test(expected = CouchbaseQueryExecutionException.class)
|
||||
@@ -154,12 +155,12 @@ public class N1qlCrudRepositoryIntegrationTests {
|
||||
partyRepository.save(partyHasKeyword);
|
||||
|
||||
long max = partyRepository.findMaxAttendees();
|
||||
assertEquals(4000000, max);
|
||||
assertThat(max).isEqualTo(4000000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDoBooleanProjectionWithStringBasedQuery() {
|
||||
boolean someBoolean = partyRepository.justABoolean();
|
||||
assertEquals(true, someBoolean);
|
||||
assertThat(someBoolean).isEqualTo(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import java.util.List;
|
||||
@@ -67,11 +68,11 @@ public class N1qlPlaceholderIntegrationTests {
|
||||
int min = 200;
|
||||
List<Party> result = partyRepository.findAllWithNamedParams(excluded, included, min);
|
||||
|
||||
assertEquals(2, result.size());
|
||||
assertThat(result.size()).isEqualTo(2);
|
||||
for (Party party : result) {
|
||||
assertTrue(party.getDescription().contains(included));
|
||||
assertFalse(party.getDescription().contains(excluded));
|
||||
assertTrue(party.getAttendees() >= min);
|
||||
assertThat(party.getDescription().contains(included)).isTrue();
|
||||
assertThat(party.getDescription().contains(excluded)).isFalse();
|
||||
assertThat(party.getAttendees() >= min).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,11 +83,11 @@ public class N1qlPlaceholderIntegrationTests {
|
||||
int min = 200;
|
||||
List<Party> result = partyRepository.findAllWithPositionalParams(excluded, included, min);
|
||||
|
||||
assertEquals(2, result.size());
|
||||
assertThat(result.size()).isEqualTo(2);
|
||||
for (Party party : result) {
|
||||
assertTrue(party.getDescription().contains(included));
|
||||
assertFalse(party.getDescription().contains(excluded));
|
||||
assertTrue(party.getAttendees() >= min);
|
||||
assertThat(party.getDescription().contains(included)).isTrue();
|
||||
assertThat(party.getDescription().contains(excluded)).isFalse();
|
||||
assertThat(party.getAttendees() >= min).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,11 +98,11 @@ public class N1qlPlaceholderIntegrationTests {
|
||||
int min = 200;
|
||||
List<Party> result = partyRepository.findAllWithPositionalParamsAndQuotedNamedParams(excluded, included, min);
|
||||
|
||||
assertEquals(2, result.size());
|
||||
assertThat(result.size()).isEqualTo(2);
|
||||
for (Party party : result) {
|
||||
assertTrue(party.getDescription().contains(included));
|
||||
assertFalse(party.getDescription().contains(excluded));
|
||||
assertTrue(party.getAttendees() >= min);
|
||||
assertThat(party.getDescription().contains(included)).isTrue();
|
||||
assertThat(party.getDescription().contains(excluded)).isFalse();
|
||||
assertThat(party.getAttendees() >= min).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,8 +118,9 @@ public class N1qlPlaceholderIntegrationTests {
|
||||
factory.getRepository(BadRepository.class);
|
||||
fail("Expected IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals(e.toString(), "Using both named (1) and positional (2) placeholders is not supported, please choose " +
|
||||
"one over the other in findAllWithMixedParamsInQuery", e.getMessage());
|
||||
assertThat(e.getMessage()).as(e.toString())
|
||||
.isEqualTo("Using both named (1) and positional (2) placeholders is not supported, please choose " +
|
||||
"one over the other in findAllWithMixedParamsInQuery");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,11 +131,11 @@ public class N1qlPlaceholderIntegrationTests {
|
||||
int max = 200;
|
||||
List<Party> result = partyRepository.removeWithPositionalParams(excluded, included, max);
|
||||
|
||||
assertEquals(10, result.size());
|
||||
assertThat(result.size()).isEqualTo(10);
|
||||
for (Party party : result) {
|
||||
assertTrue(party.getDescription().contains(included));
|
||||
assertFalse(party.getDescription().contains(excluded));
|
||||
assertTrue(party.getAttendees() < max);
|
||||
assertThat(party.getDescription().contains(included)).isTrue();
|
||||
assertThat(party.getDescription().contains(excluded)).isFalse();
|
||||
assertThat(party.getAttendees() < max).isTrue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -53,19 +51,19 @@ public class PageAndSliceIntegrationTests {
|
||||
Page<User> page2 = repository.findByAgeGreaterThan(9, page1.nextPageable());
|
||||
Page<User> page3 = repository.findByAgeGreaterThan(9, page2.nextPageable());
|
||||
|
||||
assertEquals(90, page1.getTotalElements());
|
||||
assertEquals(3, page1.getTotalPages());
|
||||
assertTrue(page1.hasContent());
|
||||
assertTrue(page1.hasNext());
|
||||
assertEquals(40, page1.getNumberOfElements());
|
||||
assertThat(page1.getTotalElements()).isEqualTo(90);
|
||||
assertThat(page1.getTotalPages()).isEqualTo(3);
|
||||
assertThat(page1.hasContent()).isTrue();
|
||||
assertThat(page1.hasNext()).isTrue();
|
||||
assertThat(page1.getNumberOfElements()).isEqualTo(40);
|
||||
|
||||
assertTrue(page2.hasContent());
|
||||
assertTrue(page2.hasNext());
|
||||
assertEquals(40, page2.getNumberOfElements());
|
||||
assertThat(page2.hasContent()).isTrue();
|
||||
assertThat(page2.hasNext()).isTrue();
|
||||
assertThat(page2.getNumberOfElements()).isEqualTo(40);
|
||||
|
||||
assertTrue(page3.hasContent());
|
||||
assertFalse(page3.hasNext());
|
||||
assertEquals(10, page3.getNumberOfElements());
|
||||
assertThat(page3.hasContent()).isTrue();
|
||||
assertThat(page3.hasNext()).isFalse();
|
||||
assertThat(page3.getNumberOfElements()).isEqualTo(10);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@@ -82,9 +80,9 @@ public class PageAndSliceIntegrationTests {
|
||||
while(slice.hasNext()) {
|
||||
slice = repository.findByAgeLessThan(9, slice.nextPageable());
|
||||
allMatching.addAll(slice.getContent());
|
||||
assertEquals(3, slice.getContent().size());
|
||||
assertThat(slice.getContent().size()).isEqualTo(3);
|
||||
}
|
||||
assertEquals(9, allMatching.size());
|
||||
assertThat(allMatching.size()).isEqualTo(9);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -25,6 +21,8 @@ import org.springframework.data.repository.core.support.RepositoryFactorySupport
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Simon Baslé
|
||||
* @author Mark Paluch
|
||||
@@ -54,7 +52,7 @@ public class QueryDerivationConversionIntegrationTests {
|
||||
@Test
|
||||
public void testConvertsDateParameterInN1qlQuery() {
|
||||
Optional<Party> partyApril = repository.findById("testparty-3");
|
||||
assertTrue(partyApril.isPresent());
|
||||
assertThat(partyApril.isPresent()).isTrue();
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.clear();
|
||||
@@ -62,20 +60,20 @@ public class QueryDerivationConversionIntegrationTests {
|
||||
Date find = cal.getTime();
|
||||
|
||||
List<Party> parties = repository.findByEventDateIs(find);
|
||||
assertNotNull(parties);
|
||||
assertEquals(1, parties.size());
|
||||
assertEquals(find, parties.get(0).getEventDate());
|
||||
assertThat(parties).isNotNull();
|
||||
assertThat(parties.size()).isEqualTo(1);
|
||||
assertThat(parties.get(0).getEventDate()).isEqualTo(find);
|
||||
|
||||
JsonDocument doc = client.get(parties.get(0).getKey());
|
||||
assertEquals(find.getTime(), doc.content().get("eventDate"));
|
||||
assertThat(doc.content().get("eventDate")).isEqualTo(find.getTime());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAcceptLongParameterInN1qlQuery() {
|
||||
List<Party> newYear90 = repository.findByAttendeesGreaterThanEqual(1200000);
|
||||
assertNotNull(newYear90);
|
||||
assertEquals(1, newYear90.size());
|
||||
assertEquals("aTestParty", newYear90.get(0).getKey());
|
||||
assertThat(newYear90).isNotNull();
|
||||
assertThat(newYear90.size()).isEqualTo(1);
|
||||
assertThat(newYear90.get(0).getKey()).isEqualTo("aTestParty");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -86,8 +84,8 @@ public class QueryDerivationConversionIntegrationTests {
|
||||
Date find = cal.getTime();
|
||||
|
||||
List<Party> afterSummerParties = repository.findFirst3ByEventDateGreaterThanEqual(find);
|
||||
assertNotNull(afterSummerParties);
|
||||
assertEquals(3, afterSummerParties.size());
|
||||
assertThat(afterSummerParties).isNotNull();
|
||||
assertThat(afterSummerParties.size()).isEqualTo(3);
|
||||
for (Party afterSummerParty : afterSummerParties) {
|
||||
assert(afterSummerParty.getEventDate().after(find));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import java.util.Calendar;
|
||||
@@ -85,10 +85,11 @@ public class ReactiveN1qlCouchbaseRepositoryIntegrationTests {
|
||||
Iterable<Party> allByAttendanceDesc = repository.findAll(Sort.by(Sort.Direction.DESC, "attendees")).collectList().block();
|
||||
long previousAttendance = Long.MAX_VALUE;
|
||||
for (Party party : allByAttendanceDesc) {
|
||||
assertTrue(party.getAttendees() <= previousAttendance);
|
||||
assertThat(party.getAttendees() <= previousAttendance).isTrue();
|
||||
previousAttendance = party.getAttendees();
|
||||
}
|
||||
assertFalse("Expected to find several parties", previousAttendance == Long.MAX_VALUE);
|
||||
assertThat(previousAttendance == Long.MAX_VALUE)
|
||||
.as("Expected to find several parties").isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,11 +98,11 @@ public class ReactiveN1qlCouchbaseRepositoryIntegrationTests {
|
||||
String previousDesc = null;
|
||||
for (Party party : parties) {
|
||||
if (previousDesc != null) {
|
||||
assertTrue(party.getDescription().compareTo(previousDesc) <= 0);
|
||||
assertThat(party.getDescription().compareTo(previousDesc) <= 0).isTrue();
|
||||
}
|
||||
previousDesc = party.getDescription();
|
||||
}
|
||||
assertNotNull("Expected to find several parties", previousDesc);
|
||||
assertThat(previousDesc).as("Expected to find several parties").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,23 +111,27 @@ public class ReactiveN1qlCouchbaseRepositoryIntegrationTests {
|
||||
String previousDesc = null;
|
||||
for(Party party : parties) {
|
||||
if (previousDesc != null) {
|
||||
assertTrue(party.getDescription().compareToIgnoreCase(previousDesc) <= 0);
|
||||
assertThat(party.getDescription().compareToIgnoreCase(previousDesc) <= 0)
|
||||
.isTrue();
|
||||
}
|
||||
previousDesc = party.getDescription();
|
||||
}
|
||||
assertNotNull("Expected to find several parties", previousDesc);
|
||||
assertThat(previousDesc).as("Expected to find several parties").isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomSpelCountQuery() {
|
||||
long count = partyRepository.countCustom().block();
|
||||
assertTrue("Count query for parties should be atleast 12", count >= 12);
|
||||
assertThat(count >= 12).as("Count query for parties should be atleast 12")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartTreeQuery() {
|
||||
long count = partyRepository.countAllByDescriptionNotNull().block();
|
||||
assertTrue("Count query for parties with description not null should be atleast 12", count >= 12);
|
||||
assertThat(count >= 12)
|
||||
.as("Count query for parties with description not null should be atleast 12")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,8 +143,8 @@ public class ReactiveN1qlCouchbaseRepositoryIntegrationTests {
|
||||
Date date = cal.getTime();
|
||||
partyRepository.save(new Party(key, "", "", date, 0, null)).block();
|
||||
List<Party> partyList = partyRepository.getByEventDate(date).collectList().block();
|
||||
assertTrue(partyList.size() == 1);
|
||||
assertEquals("Key mismatch", partyList.get(0).getKey(), key);
|
||||
assertThat(partyList.size() == 1).isTrue();
|
||||
assertThat(key).as("Key mismatch").isEqualTo(partyList.get(0).getKey());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,6 +152,6 @@ public class ReactiveN1qlCouchbaseRepositoryIntegrationTests {
|
||||
partyRepository.save(new Party("testReactiveN1qlQueryWithInvalidValue", "", "testReactiveN1qlQueryWithInvalidValue", null, 0, null));
|
||||
final String description = "testReactiveN1qlQueryWithInvalidValue* OR `description` LIKE \"\"";
|
||||
List<Party> partyList = partyRepository.findByDescriptionStartingWith(description).collectList().block();
|
||||
assertTrue(partyList.size() == 0);
|
||||
assertThat(partyList.size() == 0).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
|
||||
import static junit.framework.TestCase.assertNull;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
/**
|
||||
@@ -52,6 +52,6 @@ public class ReactivePlaceIntegrationTests {
|
||||
ReactivePlace place = new ReactivePlace("somePlace");
|
||||
assertNull(place.getId());
|
||||
ReactivePlace returned = repository.save(place).block();
|
||||
assertNotNull(returned.getId());
|
||||
assertThat(returned.getId()).isNotNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.domain.Sort.Direction;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@@ -85,7 +86,7 @@ public class RepositoryIndexUsageTest {
|
||||
ArgumentCaptor<ViewQuery> queryCaptor = ArgumentCaptor.forClass(ViewQuery.class);
|
||||
verify(couchbaseOperations).findByView(queryCaptor.capture(), any(Class.class));
|
||||
String sQuery = queryCaptor.getValue().toString();
|
||||
assertEquals(expectedQueryParams, sQuery);
|
||||
assertThat(sQuery).isEqualTo(expectedQueryParams);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -99,7 +100,7 @@ public class RepositoryIndexUsageTest {
|
||||
ArgumentCaptor<ViewQuery> queryCaptor = ArgumentCaptor.forClass(ViewQuery.class);
|
||||
verify(couchbaseOperations).findByView(queryCaptor.capture(), any(Class.class));
|
||||
String sQuery = queryCaptor.getValue().toString();
|
||||
assertEquals(expectedQueryParams, sQuery);
|
||||
assertThat(sQuery).isEqualTo(expectedQueryParams);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,13 +114,13 @@ public class RepositoryIndexUsageTest {
|
||||
ArgumentCaptor<ViewQuery> queryCaptor = ArgumentCaptor.forClass(ViewQuery.class);
|
||||
verify(couchbaseOperations).queryView(queryCaptor.capture());
|
||||
String sQuery = queryCaptor.getValue().toString();
|
||||
assertEquals(expectedQueryParams, sQuery);
|
||||
assertThat(sQuery).isEqualTo(expectedQueryParams);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountParsesAndAddsLongValuesFromRows() {
|
||||
long count = repository.count();
|
||||
assertEquals(300L, count);
|
||||
assertThat(count).isEqualTo(300L);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,7 +134,7 @@ public class RepositoryIndexUsageTest {
|
||||
ArgumentCaptor<ViewQuery> queryCaptor = ArgumentCaptor.forClass(ViewQuery.class);
|
||||
verify(couchbaseOperations).queryView(queryCaptor.capture());
|
||||
String sQuery = queryCaptor.getValue().toString();
|
||||
assertEquals(expectedQueryParams, sQuery);
|
||||
assertThat(sQuery).isEqualTo(expectedQueryParams);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -149,9 +150,11 @@ public class RepositoryIndexUsageTest {
|
||||
verify(couchbaseOperations).findByN1QL(queryCaptor.capture(), any(Class.class));
|
||||
|
||||
JsonObject query = queryCaptor.getValue().n1ql();
|
||||
assertEquals(CONSISTENCY.n1qlConsistency().n1ql(), query.getString("scan_consistency"));
|
||||
assertThat(query.getString("scan_consistency"))
|
||||
.isEqualTo(CONSISTENCY.n1qlConsistency().n1ql());
|
||||
String statement = query.getString("statement");
|
||||
assertTrue("Expected " + expectedOrderClause + " in " + statement, statement.contains(expectedOrderClause));
|
||||
assertThat(statement.contains(expectedOrderClause))
|
||||
.as("Expected " + expectedOrderClause + " in " + statement).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,9 +169,11 @@ public class RepositoryIndexUsageTest {
|
||||
verify(couchbaseOperations).findByN1QL(queryCaptor.capture(), any(Class.class));
|
||||
|
||||
JsonObject query = queryCaptor.getValue().n1ql();
|
||||
assertEquals(CONSISTENCY.n1qlConsistency().n1ql(), query.getString("scan_consistency"));
|
||||
assertThat(query.getString("scan_consistency"))
|
||||
.isEqualTo(CONSISTENCY.n1qlConsistency().n1ql());
|
||||
String statement = query.getString("statement");
|
||||
assertTrue("Expected " + expectedLimitClause + " in " + statement, statement.contains(expectedLimitClause));
|
||||
assertThat(statement.contains(expectedLimitClause))
|
||||
.as("Expected " + expectedLimitClause + " in " + statement).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -99,18 +100,18 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
repository.save(instance);
|
||||
|
||||
Optional<User> found = repository.findById(key);
|
||||
assertTrue(found.isPresent());
|
||||
assertThat(found.isPresent()).isTrue();
|
||||
|
||||
found.ifPresent(actual -> {
|
||||
assertEquals(instance.getKey(), actual.getKey());
|
||||
assertEquals(instance.getUsername(), actual.getUsername());
|
||||
assertThat(actual.getKey()).isEqualTo(instance.getKey());
|
||||
assertThat(actual.getUsername()).isEqualTo(instance.getUsername());
|
||||
|
||||
assertTrue(repository.existsById(key));
|
||||
assertThat(repository.existsById(key)).isTrue();
|
||||
repository.delete(actual);
|
||||
});
|
||||
|
||||
assertFalse(repository.findById(key).isPresent());
|
||||
assertFalse(repository.existsById(key));
|
||||
assertThat(repository.findById(key).isPresent()).isFalse();
|
||||
assertThat(repository.existsById(key)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,10 +126,10 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
int size = 0;
|
||||
for (User u : allUsers) {
|
||||
size++;
|
||||
assertNotNull(u.getKey());
|
||||
assertNotNull(u.getUsername());
|
||||
assertThat(u.getKey()).isNotNull();
|
||||
assertThat(u.getUsername()).isNotNull();
|
||||
}
|
||||
assertEquals(100, size);
|
||||
assertThat(size).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -136,7 +137,7 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
// do a non-stale query to populate data for testing.
|
||||
client.query(ViewQuery.from("user", "all").stale(Stale.FALSE));
|
||||
|
||||
assertEquals(100, repository.count());
|
||||
assertThat(repository.count()).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,18 +148,18 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
int size = 0;
|
||||
for (User u : users) {
|
||||
size++;
|
||||
assertNotNull(u.getKey());
|
||||
assertNotNull(u.getUsername());
|
||||
assertThat(u.getKey()).isNotNull();
|
||||
assertThat(u.getUsername()).isNotNull();
|
||||
}
|
||||
assertEquals(2, size);
|
||||
assertThat(size).isEqualTo(2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindByUsernameUsingN1ql() {
|
||||
User user = repository.findByUsername("uname-1");
|
||||
assertNotNull(user);
|
||||
assertEquals("testuser-1", user.getKey());
|
||||
assertEquals("uname-1", user.getUsername());
|
||||
assertThat(user).isNotNull();
|
||||
assertThat(user.getKey()).isEqualTo("testuser-1");
|
||||
assertThat(user.getUsername()).isEqualTo("uname-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,8 +168,10 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
User user = repository.findByUsernameBadSelect("uname-1");
|
||||
fail("shouldFailFindByUsernameWithNoIdOrCas");
|
||||
} catch (CouchbaseQueryExecutionException e) {
|
||||
assertTrue("_ID expected in exception " + e, e.getMessage().contains("_ID"));
|
||||
assertTrue("_CAS expected in exception " + e, e.getMessage().contains("_CAS"));
|
||||
assertThat(e.getMessage().contains("_ID")).as("_ID expected in exception " + e)
|
||||
.isTrue();
|
||||
assertThat(e.getMessage().contains("_CAS")).as("_CAS expected in exception " + e)
|
||||
.isTrue();
|
||||
} catch (Exception e) {
|
||||
fail("CouchbaseQueryExecutionException expected");
|
||||
}
|
||||
@@ -177,26 +180,26 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void shouldFindFromUsernameInlineWithSpelParsing() {
|
||||
User user = repository.findByUsernameWithSpelAndPlaceholder();
|
||||
assertNotNull(user);
|
||||
assertEquals("testuser-4", user.getKey());
|
||||
assertEquals("uname-4", user.getUsername());
|
||||
assertThat(user).isNotNull();
|
||||
assertThat(user.getKey()).isEqualTo("testuser-4");
|
||||
assertThat(user.getUsername()).isEqualTo("uname-4");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindFromDeriveQueryWithRegexpAndIn() {
|
||||
User user = repository.findByUsernameRegexAndUsernameIn("uname-[123]", Arrays.asList("uname-2", "uname-4"));
|
||||
assertNotNull(user);
|
||||
assertEquals("testuser-2", user.getKey());
|
||||
assertEquals("uname-2", user.getUsername());
|
||||
assertThat(user).isNotNull();
|
||||
assertThat(user.getKey()).isEqualTo("testuser-2");
|
||||
assertThat(user.getUsername()).isEqualTo("uname-2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindContainsWithoutAnnotation() {
|
||||
List<User> users = repository.findByUsernameContains("-9");
|
||||
assertNotNull(users);
|
||||
assertFalse(users.isEmpty());
|
||||
assertThat(users).isNotNull();
|
||||
assertThat(users.isEmpty()).isFalse();
|
||||
for (User user : users) {
|
||||
assertTrue(user.getUsername().startsWith("uname-9"));
|
||||
assertThat(user.getUsername().startsWith("uname-9")).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,14 +220,14 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
final String key = "versionedUserTest";
|
||||
VersionedData initial = new VersionedData(key, "ABCD");
|
||||
versionedDataRepository.save(initial);
|
||||
assertNotEquals(0L, initial.version);
|
||||
assertThat(initial.version).isNotEqualTo(0L);
|
||||
|
||||
Optional<VersionedData> fetch1 = versionedDataRepository.findById(key);
|
||||
|
||||
assertTrue(fetch1.isPresent());
|
||||
assertThat(fetch1.isPresent()).isTrue();
|
||||
fetch1.ifPresent(actual -> {
|
||||
assertNotSame(initial, actual);
|
||||
assertEquals(actual.version, initial.version);
|
||||
assertThat(actual).isNotSameAs(initial);
|
||||
assertThat(initial.version).isEqualTo(actual.version);
|
||||
});
|
||||
|
||||
VersionedData versionedData = fetch1.get();
|
||||
@@ -233,7 +236,7 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
bypass.content().put("data", "BBBB");
|
||||
JsonDocument bypassed = client.upsert(bypass);
|
||||
|
||||
assertNotEquals(bypassed.cas(), versionedData.version);
|
||||
assertThat(versionedData.version).isNotEqualTo(bypassed.cas());
|
||||
System.out.println(bypassed.cas());
|
||||
|
||||
try {
|
||||
@@ -242,8 +245,9 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
fail("Expected CAS failure");
|
||||
} catch (OptimisticLockingFailureException e) {
|
||||
//success
|
||||
assertTrue("optimistic locking should have CASMismatchException as cause, got " + e.getCause(),
|
||||
e.getCause() instanceof CASMismatchException);
|
||||
assertThat(e.getCause() instanceof CASMismatchException)
|
||||
.as("optimistic locking should have CASMismatchException as cause, got " + e
|
||||
.getCause()).isTrue();
|
||||
} finally {
|
||||
client.remove(key);
|
||||
}
|
||||
@@ -260,7 +264,7 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
final AtomicLong updatedCounter = new AtomicLong();
|
||||
VersionedData initial = new VersionedData(key, "value-initial");
|
||||
versionedDataRepository.save(initial);
|
||||
assertNotEquals(0L, initial.version);
|
||||
assertThat(initial.version).isNotEqualTo(0L);
|
||||
|
||||
Callable<Void> task = new Callable<Void>() {
|
||||
@Override
|
||||
@@ -282,8 +286,9 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
};
|
||||
AsyncUtils.executeConcurrently(5, task);
|
||||
|
||||
assertNotEquals(initial.data, versionedDataRepository.findById(key).get().data);
|
||||
assertEquals(5, updatedCounter.intValue());
|
||||
assertThat(versionedDataRepository.findById(key).get().data)
|
||||
.isNotEqualTo(initial.data);
|
||||
assertThat(updatedCounter.intValue()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -310,7 +315,7 @@ public class SimpleCouchbaseRepositoryIntegrationTests {
|
||||
|
||||
AsyncUtils.executeConcurrently(5, task);
|
||||
|
||||
assertEquals(4, optimisticLockCounter.intValue());
|
||||
assertThat(optimisticLockCounter.intValue()).isEqualTo(4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ import org.springframework.data.repository.core.support.ReactiveRepositoryFactor
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
/**
|
||||
@@ -79,12 +78,12 @@ public class SimpleReactiveCouchbaseRepositoryDeleteAllIntegrationTests {
|
||||
repository.save(instance).block();
|
||||
|
||||
// we put a user in, lets be sure the count reflects that.
|
||||
assertTrue(getCount() > 0L);
|
||||
assertThat(getCount() > 0L).isTrue();
|
||||
|
||||
repository.deleteAll().block();
|
||||
|
||||
// after deleteAll, we should have a count of 0
|
||||
assertEquals(0L, getCount());
|
||||
assertThat(getCount()).isEqualTo(0L);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.repository;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -84,14 +85,14 @@ public class SimpleReactiveCouchbaseRepositoryIntegrationTests {
|
||||
repository.save(instance).block();
|
||||
|
||||
ReactiveUser found = repository.findById(key).block();
|
||||
assertEquals(instance.getKey(), found.getKey());
|
||||
assertEquals(instance.getUsername(), found.getUsername());
|
||||
assertThat(found.getKey()).isEqualTo(instance.getKey());
|
||||
assertThat(found.getUsername()).isEqualTo(instance.getUsername());
|
||||
|
||||
assertTrue(repository.existsById(key).block());
|
||||
assertThat(repository.existsById(key).block()).isTrue();
|
||||
repository.delete(found).block();
|
||||
|
||||
assertNull(repository.findById(key).block());
|
||||
assertFalse(repository.existsById(key).block());
|
||||
assertThat(repository.findById(key).block()).isNull();
|
||||
assertThat(repository.existsById(key).block()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -106,10 +107,10 @@ public class SimpleReactiveCouchbaseRepositoryIntegrationTests {
|
||||
int size = 0;
|
||||
for (ReactiveUser u : allUsers) {
|
||||
size++;
|
||||
assertNotNull(u.getKey());
|
||||
assertNotNull(u.getUsername());
|
||||
assertThat(u.getKey()).isNotNull();
|
||||
assertThat(u.getUsername()).isNotNull();
|
||||
}
|
||||
assertEquals(100, size);
|
||||
assertThat(size).isEqualTo(100);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -117,15 +118,15 @@ public class SimpleReactiveCouchbaseRepositoryIntegrationTests {
|
||||
// do a non-stale query to populate data for testing.
|
||||
client.query(ViewQuery.from("reactiveUser", "all").stale(Stale.FALSE));
|
||||
|
||||
assertEquals("100", repository.count().block().toString());
|
||||
assertThat(repository.count().block().toString()).isEqualTo("100");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindByUsernameUsingN1ql() {
|
||||
ReactiveUser user = repository.findByUsername("reactiveuname-1").single().block();
|
||||
assertNotNull(user);
|
||||
assertEquals("reactivetestuser-1", user.getKey());
|
||||
assertEquals("reactiveuname-1", user.getUsername());
|
||||
assertThat(user).isNotNull();
|
||||
assertThat(user.getKey()).isEqualTo("reactivetestuser-1");
|
||||
assertThat(user.getUsername()).isEqualTo("reactiveuname-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -134,8 +135,10 @@ public class SimpleReactiveCouchbaseRepositoryIntegrationTests {
|
||||
ReactiveUser user = repository.findByUsernameBadSelect("reactiveuname-1").single().block();
|
||||
fail("shouldFailFindByUsernameWithNoIdOrCas");
|
||||
} catch (CouchbaseQueryExecutionException e) {
|
||||
assertTrue("_ID expected in exception " + e, e.getMessage().contains("_ID"));
|
||||
assertTrue("_CAS expected in exception " + e, e.getMessage().contains("_CAS"));
|
||||
assertThat(e.getMessage().contains("_ID"))
|
||||
.as("_ID expected in exception " + e).isTrue();
|
||||
assertThat(e.getMessage().contains("_CAS"))
|
||||
.as("_CAS expected in exception " + e).isTrue();
|
||||
} catch (Exception e) {
|
||||
fail("CouchbaseQueryExecutionException expected");
|
||||
}
|
||||
@@ -144,7 +147,7 @@ public class SimpleReactiveCouchbaseRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void shouldFindFromUsernameInlineWithSpelParsing() {
|
||||
ReactiveUser user = repository.findByUsernameWithSpelAndPlaceholder().take(1).blockLast();
|
||||
assertNotNull(user);
|
||||
assertThat(user).isNotNull();
|
||||
assert(user.getUsername().startsWith("reactive"));
|
||||
assert(user.getUsername().startsWith("reactive"));
|
||||
}
|
||||
@@ -152,18 +155,18 @@ public class SimpleReactiveCouchbaseRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void shouldFindFromDeriveQueryWithRegexpAndIn() {
|
||||
ReactiveUser user = repository.findByUsernameRegexAndUsernameIn("reactiveuname-[123]", Arrays.asList("reactiveuname-2", "reactiveuname-4")).take(1).blockLast();
|
||||
assertNotNull(user);
|
||||
assertEquals("reactivetestuser-2", user.getKey());
|
||||
assertEquals("reactiveuname-2", user.getUsername());
|
||||
assertThat(user).isNotNull();
|
||||
assertThat(user.getKey()).isEqualTo("reactivetestuser-2");
|
||||
assertThat(user.getUsername()).isEqualTo("reactiveuname-2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFindContainsWithoutAnnotation() {
|
||||
List<ReactiveUser> users = repository.findByUsernameContains("reactive").collectList().block();
|
||||
assertNotNull(users);
|
||||
assertFalse(users.isEmpty());
|
||||
assertThat(users).isNotNull();
|
||||
assertThat(users.isEmpty()).isFalse();
|
||||
for (ReactiveUser user : users) {
|
||||
assertTrue(user.getUsername().startsWith("reactive"));
|
||||
assertThat(user.getUsername().startsWith("reactive")).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.springframework.data.couchbase.repository.auditing;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -17,6 +15,8 @@ import org.springframework.data.couchbase.TestContainerResource;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Simon Baslé
|
||||
* @author Mark Paluch
|
||||
@@ -40,7 +40,7 @@ public class AuditingIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testCreationEventIsRegistered() {
|
||||
assertFalse(repository.existsById(KEY));
|
||||
assertThat(repository.existsById(KEY)).isFalse();
|
||||
Date start = new Date();
|
||||
AuditedItem item = new AuditedItem(KEY, "creation");
|
||||
|
||||
@@ -48,27 +48,34 @@ public class AuditingIntegrationTests {
|
||||
repository.save(item);
|
||||
Optional<AuditedItem> persisted = repository.findById(KEY);
|
||||
|
||||
assertTrue(persisted.isPresent());
|
||||
assertThat(persisted.isPresent()).isTrue();
|
||||
|
||||
persisted.ifPresent(actual -> {
|
||||
|
||||
assertNotNull("expected creation date audit trail", actual.getCreationDate());
|
||||
assertEquals("expected creation user audit trail", "auditor", actual.getCreator());
|
||||
assertThat(actual.getCreationDate()).as("expected creation date audit trail")
|
||||
.isNotNull();
|
||||
assertThat(actual.getCreator()).as("expected creation user audit trail")
|
||||
.isEqualTo("auditor");
|
||||
|
||||
assertTrue("creation date is too early", actual.getCreationDate().after(start));
|
||||
assertTrue("creation date is too late", actual.getCreationDate().before(new Date()));
|
||||
assertThat(actual.getCreationDate().after(start)).as("creation date is too early")
|
||||
.isTrue();
|
||||
assertThat(actual.getCreationDate().before(new Date()))
|
||||
.as("creation date is too late").isTrue();
|
||||
|
||||
assertNull("expected modification date to be empty", actual.getLastModification());
|
||||
assertNull("expected modification user to be empty", actual.getLastModifiedBy());
|
||||
assertThat(actual.getLastModification())
|
||||
.as("expected modification date to be empty").isNull();
|
||||
assertThat(actual.getLastModifiedBy()).as("expected modification user to be empty")
|
||||
.isNull();
|
||||
|
||||
assertNotNull("expected version to be non null", actual.getVersion());
|
||||
assertTrue("expected version to be greater than 0", actual.getVersion() > 0L);
|
||||
assertThat(actual.getVersion()).as("expected version to be non null").isNotNull();
|
||||
assertThat(actual.getVersion() > 0L).as("expected version to be greater than 0")
|
||||
.isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateEventIsRegistered() {
|
||||
assertFalse(repository.existsById(KEY));
|
||||
assertThat(repository.existsById(KEY)).isFalse();
|
||||
|
||||
String expectedCreator = "user1";
|
||||
String expectedUpdater = "user2";
|
||||
@@ -82,16 +89,25 @@ public class AuditingIntegrationTests {
|
||||
repository.save(item);
|
||||
AuditedItem updated = repository.findById(KEY).orElse(null);
|
||||
|
||||
assertNotNull("expected entity to be persisted", updated);
|
||||
assertNotNull("expected creation date audit trail", updated.getCreationDate());
|
||||
assertEquals("expected creation user audit trail", expectedCreator, updated.getCreator());
|
||||
assertThat(updated).as("expected entity to be persisted").isNotNull();
|
||||
assertThat(updated.getCreationDate()).as("expected creation date audit trail")
|
||||
.isNotNull();
|
||||
assertThat(updated.getCreator()).as("expected creation user audit trail")
|
||||
.isEqualTo(expectedCreator);
|
||||
|
||||
assertNotNull("expected modification date audit trail", updated.getLastModification());
|
||||
assertTrue("expected modification date to be after creation date", updated.getCreationDate().before(updated.getLastModification()));
|
||||
assertEquals("expected modification user to be the modifier", expectedUpdater, updated.getLastModifiedBy());
|
||||
assertThat(updated.getLastModification()).as("expected modification date audit trail")
|
||||
.isNotNull();
|
||||
assertThat(updated.getCreationDate().before(updated.getLastModification()))
|
||||
.as("expected modification date to be after creation date").isTrue();
|
||||
assertThat(updated.getLastModifiedBy())
|
||||
.as("expected modification user to be the modifier")
|
||||
.isEqualTo(expectedUpdater);
|
||||
|
||||
assertNotNull("expected version to be non null", updated.getVersion());
|
||||
assertTrue("expected version to be greater than 0", updated.getVersion() > 0L);
|
||||
assertTrue("expected updated version to be different from the one at creation", created.getVersion() != updated.getVersion());
|
||||
assertThat(updated.getVersion()).as("expected version to be non null").isNotNull();
|
||||
assertThat(updated.getVersion() > 0L).as("expected version to be greater than 0")
|
||||
.isTrue();
|
||||
assertThat(created.getVersion() != updated.getVersion())
|
||||
.as("expected updated version to be different from the one at creation")
|
||||
.isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository.cdi;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -37,6 +35,8 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import javax.enterprise.inject.se.SeContainer;
|
||||
import javax.enterprise.inject.se.SeContainerInitializer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@@ -89,20 +89,20 @@ public class CdiRepositoryIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void testCdiRepository() {
|
||||
assertNotNull(repository);
|
||||
assertThat(repository).isNotNull();
|
||||
repository.deleteAll();
|
||||
|
||||
Person bean = new Person("key", "username");
|
||||
|
||||
repository.save(bean);
|
||||
|
||||
assertTrue(repository.existsById(bean.getId()));
|
||||
assertThat(repository.existsById(bean.getId())).isTrue();
|
||||
|
||||
Optional<Person> retrieved = repository.findById(bean.getId());
|
||||
assertTrue(retrieved.isPresent());
|
||||
assertThat(retrieved.isPresent()).isTrue();
|
||||
retrieved.ifPresent(actual -> {
|
||||
assertEquals(bean.getName(), actual.getName());
|
||||
assertEquals(bean.getId(), actual.getId());
|
||||
assertThat(actual.getName()).isEqualTo(bean.getName());
|
||||
assertThat(actual.getId()).isEqualTo(bean.getId());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,20 +111,20 @@ public class CdiRepositoryIntegrationTests {
|
||||
*/
|
||||
@Test
|
||||
public void testQualifiedCdiRepository() {
|
||||
assertNotNull(qualifiedPersonRepository);
|
||||
assertThat(qualifiedPersonRepository).isNotNull();
|
||||
qualifiedPersonRepository.deleteAll();
|
||||
|
||||
Person bean = new Person("key", "username");
|
||||
|
||||
qualifiedPersonRepository.save(bean);
|
||||
|
||||
assertTrue(qualifiedPersonRepository.existsById(bean.getId()));
|
||||
assertThat(qualifiedPersonRepository.existsById(bean.getId())).isTrue();
|
||||
|
||||
Optional<Person> retrieved = qualifiedPersonRepository.findById(bean.getId());
|
||||
assertTrue(retrieved.isPresent());
|
||||
assertThat(retrieved.isPresent()).isTrue();
|
||||
retrieved.ifPresent(actual -> {
|
||||
assertEquals(bean.getName(), actual.getName());
|
||||
assertEquals(bean.getId(), actual.getId());
|
||||
assertThat(actual.getName()).isEqualTo(bean.getName());
|
||||
assertThat(actual.getId()).isEqualTo(bean.getId());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class CdiRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void testCustomRepository() {
|
||||
|
||||
assertEquals(2, repository.returnTwo());
|
||||
assertThat(repository.returnTwo()).isEqualTo(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.repository.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -35,6 +33,9 @@ import org.springframework.data.repository.config.RepositoryConfigurationSource;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
import org.springframework.data.repository.reactive.RxJava2CrudRepository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ReactiveCouchbaseRepositoryConfigurationExtension}.
|
||||
*
|
||||
@@ -81,7 +82,8 @@ public class ReactiveCouchbaseRepositoryConfigurationExtensionUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
fail("Expected to find config for repository interface ".concat(repositoryInterface.getName()).concat(" but got ")
|
||||
fail("Expected to find config for repository interface "
|
||||
.concat(repositoryInterface.getName()).concat(" but got ")
|
||||
.concat(configs.toString()));
|
||||
}
|
||||
|
||||
@@ -90,7 +92,8 @@ public class ReactiveCouchbaseRepositoryConfigurationExtensionUnitTests {
|
||||
|
||||
for (RepositoryConfiguration<?> config : configs) {
|
||||
if (config.getRepositoryInterface().equals(repositoryInterface.getName())) {
|
||||
fail("Expected not to find config for repository interface ".concat(repositoryInterface.getName()));
|
||||
fail("Expected not to find config for repository interface "
|
||||
.concat(repositoryInterface.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository.extending.base;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -114,14 +113,16 @@ public class RepositoryBaseIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testRepositoryBaseIsChanged() {
|
||||
assertNotNull(repositoryA);
|
||||
assertNotNull(repositoryB);
|
||||
assertThat(repositoryA).isNotNull();
|
||||
assertThat(repositoryB).isNotNull();
|
||||
|
||||
assertEquals(4, repositoryA.sharedCustomMethod("toto"));
|
||||
assertEquals(4000, repositoryA.sharedCustomMethod("anna"));
|
||||
assertThat(repositoryA.sharedCustomMethod("toto")).isEqualTo(4);
|
||||
assertThat(repositoryA.sharedCustomMethod("anna")).isEqualTo(4000);
|
||||
|
||||
assertEquals(repositoryA.sharedCustomMethod("sameInput"), repositoryB.sharedCustomMethod("sameInput"));
|
||||
assertEquals(repositoryA.sharedCustomMethod("anna"), repositoryB.sharedCustomMethod("anna"));
|
||||
assertThat(repositoryB.sharedCustomMethod("sameInput"))
|
||||
.isEqualTo(repositoryA.sharedCustomMethod("sameInput"));
|
||||
assertThat(repositoryB.sharedCustomMethod("anna"))
|
||||
.isEqualTo(repositoryA.sharedCustomMethod("anna"));
|
||||
}
|
||||
|
||||
private static class Item {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository.extending.method;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.junit.After;
|
||||
@@ -32,6 +31,8 @@ import org.springframework.data.couchbase.repository.support.IndexManager;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* This tests custom repository methods.
|
||||
*
|
||||
@@ -92,13 +93,13 @@ public class RepositoryCustomMethodIntegrationTests {
|
||||
@Test
|
||||
public void testRepositoryCustomMethodIsWeavedIn() {
|
||||
long customCount = repository.customCountItems();
|
||||
assertEquals(-1L, customCount);
|
||||
assertThat(customCount).isEqualTo(-1L);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRepositoryCrudMethodIsReplaced() {
|
||||
long count = repository.count();
|
||||
assertEquals(100L, count);
|
||||
assertThat(count).isEqualTo(100L);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository.feature;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import com.couchbase.client.java.cluster.ClusterInfo;
|
||||
@@ -73,7 +72,7 @@ public class FeatureDetectionRepositoryIntegrationTests {
|
||||
factory.getRepository(UserRepository.class);
|
||||
fail("expected UnsupportedCouchbaseFeatureException");
|
||||
} catch (UnsupportedCouchbaseFeatureException e) {
|
||||
assertEquals(CouchbaseFeature.N1QL, e.getFeature());
|
||||
assertThat(e.getFeature()).isEqualTo(CouchbaseFeature.N1QL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +80,7 @@ public class FeatureDetectionRepositoryIntegrationTests {
|
||||
public void testN1qlIncompatibleClusterDoesntFailForViewBasedRepository() throws Exception {
|
||||
RepositoryFactorySupport factory = new CouchbaseRepositoryFactory(operationsMapping, indexManager);
|
||||
ViewOnlyUserRepository repository = getRepositoryWithRetry(factory, ViewOnlyUserRepository.class);
|
||||
assertNotNull(repository);
|
||||
assertThat(repository).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,21 +92,21 @@ public class FeatureDetectionRepositoryIntegrationTests {
|
||||
template.findByN1QL(query, User.class);
|
||||
fail("expected findByN1QL to fail with UnsupportedCouchbaseFeatureException");
|
||||
} catch (UnsupportedCouchbaseFeatureException e) {
|
||||
assertEquals(CouchbaseFeature.N1QL, e.getFeature());
|
||||
assertThat(e.getFeature()).isEqualTo(CouchbaseFeature.N1QL);
|
||||
}
|
||||
|
||||
try {
|
||||
template.findByN1QLProjection(query, User.class);
|
||||
fail("expected findByN1QLProjection to fail with UnsupportedCouchbaseFeatureException");
|
||||
} catch (UnsupportedCouchbaseFeatureException e) {
|
||||
assertEquals(CouchbaseFeature.N1QL, e.getFeature());
|
||||
assertThat(e.getFeature()).isEqualTo(CouchbaseFeature.N1QL);
|
||||
}
|
||||
|
||||
try {
|
||||
template.queryN1QL(query);
|
||||
fail("expected queryN1QL to fail with UnsupportedCouchbaseFeatureException");
|
||||
} catch (UnsupportedCouchbaseFeatureException e) {
|
||||
assertEquals(CouchbaseFeature.N1QL, e.getFeature());
|
||||
assertThat(e.getFeature()).isEqualTo(CouchbaseFeature.N1QL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository.index;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -86,7 +87,7 @@ public class IndexedRepositoryIntegrationTests {
|
||||
N1qlQuery existQuery = N1qlQuery.simple("SELECT 1 FROM `"+ bucket +"`");
|
||||
N1qlQueryResult exist = template.queryN1QL(existQuery);
|
||||
|
||||
assertTrue(exist.finalSuccess());
|
||||
assertThat(exist.finalSuccess()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -97,7 +98,7 @@ public class IndexedRepositoryIntegrationTests {
|
||||
N1qlQuery existQuery = N1qlQuery.simple("SELECT 1 FROM `"+ bucket +"` USE INDEX (" + SECONDARY +")");
|
||||
N1qlQueryResult exist = template.queryN1QL(existQuery);
|
||||
|
||||
assertTrue(exist.finalSuccess());
|
||||
assertThat(exist.finalSuccess()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +114,7 @@ public class IndexedRepositoryIntegrationTests {
|
||||
|
||||
}
|
||||
|
||||
assertNotNull(designDoc);
|
||||
assertThat(designDoc).isNotNull();
|
||||
for (View view : designDoc.views()) {
|
||||
if (view.name().equals(VIEW_NAME)) return;
|
||||
}
|
||||
@@ -127,7 +128,7 @@ public class IndexedRepositoryIntegrationTests {
|
||||
N1qlQuery existQuery = N1qlQuery.simple("SELECT 1 FROM `"+ bucket +"` USE INDEX (" + IGNORED_SECONDARY +")");
|
||||
N1qlQueryResult exist = template.queryN1QL(existQuery);
|
||||
|
||||
assertFalse(exist.finalSuccess());
|
||||
assertThat(exist.finalSuccess()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -161,7 +162,7 @@ public class IndexedRepositoryIntegrationTests {
|
||||
.bucketManager()
|
||||
.getDesignDocument("foo");
|
||||
|
||||
assertNotNull(designDoc);
|
||||
assertThat(designDoc).isNotNull();
|
||||
boolean foundView = false;
|
||||
for (View view : designDoc.views()) {
|
||||
if (view.name().equals("all")) {
|
||||
@@ -169,7 +170,8 @@ public class IndexedRepositoryIntegrationTests {
|
||||
break;
|
||||
}
|
||||
}
|
||||
assertTrue("Expected to find view \"all\" on design document \"foo\"", foundView);
|
||||
assertThat(foundView).as("Expected to find view \"all\" on design document \"foo\"")
|
||||
.isTrue();
|
||||
|
||||
repository.save(foo1);
|
||||
repository.save(foo2);
|
||||
@@ -178,11 +180,11 @@ public class IndexedRepositoryIntegrationTests {
|
||||
for (Object o : repository.findAllById(Arrays.asList("foo1", "foo2"))) {
|
||||
count++;
|
||||
}
|
||||
assertEquals(2L, count);
|
||||
assertThat(count).isEqualTo(2L);
|
||||
count = 0;
|
||||
for (Object o : repository.findAllById(Arrays.asList("foo1", "foo3"))) {
|
||||
count++;
|
||||
}
|
||||
assertEquals(1L, count);
|
||||
assertThat(count).isEqualTo(1L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.data.repository.core.support.RepositoryFactorySupport
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.couchbase.CouchbaseTestHelper.getRepositoryWithRetry;
|
||||
|
||||
/**
|
||||
@@ -65,12 +65,14 @@ public class N1qlJoinIntegrationTests {
|
||||
@Test
|
||||
public void testN1qlJoin() {
|
||||
Author a = authorRepository.findById("Author" + 1).get();
|
||||
assertTrue(a.books.size() == 5);
|
||||
assertThat(a.books.size() == 5).isTrue();
|
||||
for(Book b:a.books) {
|
||||
assertEquals("Book Join on author name mismatch", a.name, b.authorName);
|
||||
assertThat(b.authorName).as("Book Join on author name mismatch")
|
||||
.isEqualTo(a.name);
|
||||
}
|
||||
assertNotNull(a.address);
|
||||
assertEquals("Address Join on author name mismatch", a.name, a.address.name);
|
||||
assertThat(a.address).isNotNull();
|
||||
assertThat(a.address.name).as("Address Join on author name mismatch")
|
||||
.isEqualTo(a.name);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -80,7 +82,7 @@ public class N1qlJoinIntegrationTests {
|
||||
authorRepository.save(a);
|
||||
|
||||
Author saveda = authorRepository.findById(name).get();
|
||||
assertTrue(saveda.books.isEmpty());
|
||||
assertNull(saveda.address);
|
||||
assertThat(saveda.books.isEmpty()).isTrue();
|
||||
assertThat(saveda.address).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
package org.springframework.data.couchbase.repository.query;
|
||||
|
||||
import static com.couchbase.client.java.query.Select.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@@ -64,7 +64,7 @@ import org.springframework.data.repository.query.ReturnedType;
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class AbstractN1qlBasedQueryTest {
|
||||
|
||||
|
||||
CouchbaseMappingContext context = new CouchbaseMappingContext();
|
||||
ProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory();
|
||||
RepositoryMetadata metadata = DefaultRepositoryMetadata.getMetadata(SampleRepository.class);
|
||||
@@ -75,10 +75,11 @@ public class AbstractN1qlBasedQueryTest {
|
||||
N1qlQuery query = AbstractN1qlBasedQuery.buildQuery(st, JsonArray.empty(), ScanConsistency.NOT_BOUNDED);
|
||||
JsonObject queryObject = query.n1ql();
|
||||
|
||||
assertTrue(query instanceof SimpleN1qlQuery);
|
||||
assertEquals(st.toString(), query.statement().toString());
|
||||
assertEquals(N1qlParams.build().consistency(ScanConsistency.NOT_BOUNDED), query.params());
|
||||
assertFalse(queryObject.containsKey("args"));
|
||||
assertThat(query instanceof SimpleN1qlQuery).isTrue();
|
||||
assertThat(query.statement().toString()).isEqualTo(st.toString());
|
||||
assertThat(query.params())
|
||||
.isEqualTo(N1qlParams.build().consistency(ScanConsistency.NOT_BOUNDED));
|
||||
assertThat(queryObject.containsKey("args")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,13 +91,14 @@ public class AbstractN1qlBasedQueryTest {
|
||||
N1qlQuery query = AbstractN1qlBasedQuery.buildQuery(st, placeholderValues, ScanConsistency.NOT_BOUNDED);
|
||||
JsonObject queryObject = query.n1ql();
|
||||
|
||||
assertTrue(query instanceof ParameterizedN1qlQuery);
|
||||
assertEquals(st.toString(), query.statement().toString());
|
||||
assertEquals(N1qlParams.build().consistency(ScanConsistency.NOT_BOUNDED), query.params());
|
||||
assertTrue(queryObject.containsKey("args"));
|
||||
assertThat(query instanceof ParameterizedN1qlQuery).isTrue();
|
||||
assertThat(query.statement().toString()).isEqualTo(st.toString());
|
||||
assertThat(query.params())
|
||||
.isEqualTo(N1qlParams.build().consistency(ScanConsistency.NOT_BOUNDED));
|
||||
assertThat(queryObject.containsKey("args")).isTrue();
|
||||
JsonArray args = queryObject.getArray("args");
|
||||
assertEquals(1, args.size());
|
||||
assertEquals("test", args.get(0));
|
||||
assertThat(args.size()).isEqualTo(1);
|
||||
assertThat(args.get(0)).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,19 +111,20 @@ public class AbstractN1qlBasedQueryTest {
|
||||
N1qlQuery query = AbstractN1qlBasedQuery.buildQuery(st, placeholderValues, ScanConsistency.NOT_BOUNDED);
|
||||
JsonObject queryObject = query.n1ql();
|
||||
|
||||
assertTrue(query instanceof ParameterizedN1qlQuery);
|
||||
assertEquals(st.toString(), query.statement().toString());
|
||||
assertEquals(N1qlParams.build().consistency(ScanConsistency.NOT_BOUNDED), query.params());
|
||||
assertTrue(queryObject.containsKey("args"));
|
||||
assertThat(query instanceof ParameterizedN1qlQuery).isTrue();
|
||||
assertThat(query.statement().toString()).isEqualTo(st.toString());
|
||||
assertThat(query.params())
|
||||
.isEqualTo(N1qlParams.build().consistency(ScanConsistency.NOT_BOUNDED));
|
||||
assertThat(queryObject.containsKey("args")).isTrue();
|
||||
JsonArray args = queryObject.getArray("args");
|
||||
assertEquals(2, args.size());
|
||||
assertEquals(123L, args.get(0));
|
||||
assertEquals("test", args.get(1));
|
||||
assertThat(args.size()).isEqualTo(2);
|
||||
assertThat(args.get(0)).isEqualTo(123L);
|
||||
assertThat(args.get(1)).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldChooseCollectionExecutionWhenCollectionType() throws Exception {
|
||||
|
||||
|
||||
Method method = SampleRepository.class.getMethod("findAll");
|
||||
CouchbaseQueryMethod queryMethod = new CouchbaseQueryMethod(method, metadata, projectionFactory, context);
|
||||
|
||||
@@ -142,11 +145,11 @@ public class AbstractN1qlBasedQueryTest {
|
||||
|
||||
@Test
|
||||
public void shouldChooseEntityExecutionWhenEntityType() throws Exception {
|
||||
|
||||
|
||||
Method method = SampleRepository.class.getMethod("findById", Integer.class);
|
||||
|
||||
|
||||
CouchbaseQueryMethod queryMethod = new CouchbaseQueryMethod(method, metadata, projectionFactory, context);
|
||||
|
||||
|
||||
N1qlQuery query = Mockito.mock(N1qlQuery.class);
|
||||
Pageable pageable = Mockito.mock(Pageable.class);
|
||||
AbstractN1qlBasedQuery mock = mock(AbstractN1qlBasedQuery.class);
|
||||
@@ -164,10 +167,10 @@ public class AbstractN1qlBasedQueryTest {
|
||||
|
||||
@Test
|
||||
public void shouldChooseStreamExecutionWhenStreamType() throws Exception {
|
||||
|
||||
|
||||
Method method = SampleRepository.class.getMethod("streamAll");
|
||||
CouchbaseQueryMethod queryMethod = new CouchbaseQueryMethod(method, metadata, projectionFactory, context);
|
||||
|
||||
|
||||
N1qlQuery query = Mockito.mock(N1qlQuery.class);
|
||||
Pageable pageable = Mockito.mock(Pageable.class);
|
||||
AbstractN1qlBasedQuery mock = mock(AbstractN1qlBasedQuery.class);
|
||||
@@ -186,10 +189,10 @@ public class AbstractN1qlBasedQueryTest {
|
||||
|
||||
@Test
|
||||
public void shouldChoosePagedExecutionWhenPageType() throws Exception {
|
||||
|
||||
|
||||
Method method = SampleRepository.class.getMethod("findAllPaged", Pageable.class);
|
||||
CouchbaseQueryMethod queryMethod = new CouchbaseQueryMethod(method, metadata, projectionFactory, context);
|
||||
|
||||
|
||||
N1qlQuery query = Mockito.mock(N1qlQuery.class);
|
||||
Pageable pageable = Mockito.mock(Pageable.class);
|
||||
AbstractN1qlBasedQuery mock = mock(AbstractN1qlBasedQuery.class);
|
||||
@@ -253,7 +256,7 @@ public class AbstractN1qlBasedQueryTest {
|
||||
|
||||
@Test
|
||||
public void shouldExecuteSingleProjectionWhenPrimitiveReturnType() throws Exception {
|
||||
|
||||
|
||||
Method method = SampleRepository.class.getMethod("longMethod");
|
||||
CouchbaseQueryMethod queryMethod = new CouchbaseQueryMethod(method, metadata, projectionFactory, context);
|
||||
|
||||
@@ -292,10 +295,11 @@ public class AbstractN1qlBasedQueryTest {
|
||||
when(template.getDefaultConsistency()).thenReturn(Consistency.STRONGLY_CONSISTENT);
|
||||
|
||||
ScanConsistency defaultConsistency = new SampleQuery(defaultQueryMethod, template).getScanConsistency();
|
||||
assertEquals(defaultConsistency, Consistency.STRONGLY_CONSISTENT.n1qlConsistency());
|
||||
assertThat(Consistency.STRONGLY_CONSISTENT.n1qlConsistency())
|
||||
.isEqualTo(defaultConsistency);
|
||||
|
||||
ScanConsistency unboundedConsistency = new SampleQuery(unboundedQueryMethod, template).getScanConsistency();
|
||||
assertEquals(unboundedConsistency, ScanConsistency.NOT_BOUNDED);
|
||||
assertThat(ScanConsistency.NOT_BOUNDED).isEqualTo(unboundedConsistency);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.springframework.data.couchbase.repository.query;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -13,6 +12,8 @@ import org.junit.Test;
|
||||
import org.springframework.data.couchbase.repository.query.support.N1qlQueryCreatorUtils;
|
||||
import org.springframework.data.repository.query.parser.Part;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class N1qlQueryCreatorTest {
|
||||
|
||||
//==== The tests below check mapping between a Part.Type and the corresponding N1QL expression ====
|
||||
@@ -32,12 +33,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a").add("b"), phexp);
|
||||
assertEquals(JsonArray.create().add(1).add(2), phexpNum);
|
||||
assertEquals(JsonArray.create().add("C").add("D"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a").add("b"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1).add(2));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("C").add("D"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,12 +56,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create(), phexp);
|
||||
assertEquals(JsonArray.create(), phexpNum);
|
||||
assertEquals(JsonArray.create(), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -78,12 +79,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create(), phexp);
|
||||
assertEquals(JsonArray.create(), phexpNum);
|
||||
assertEquals(JsonArray.create(), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,12 +102,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,12 +125,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,12 +148,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -170,12 +171,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -193,12 +194,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -216,12 +217,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -239,12 +240,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -262,12 +263,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -285,12 +286,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -308,12 +309,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -331,12 +332,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -354,12 +355,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -377,12 +378,13 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("a")), phexp);
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add(1)), phexpNum);
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("b")), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add(JsonArray.create().add("a")));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(JsonArray.create().add(1)));
|
||||
assertThat(phexpIgnoreCase)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("b")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -399,10 +401,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("av1").add("av2")), phexp);
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("bv1").add("bv2")), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("av1").add("av2")));
|
||||
assertThat(phexpIgnoreCase)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("bv1").add("bv2")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -419,10 +423,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("av1").add("av2")), phexp);
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("bv1").add("bv2")), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("av1").add("av2")));
|
||||
assertThat(phexpIgnoreCase)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("bv1").add("bv2")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -440,12 +446,13 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("a")), phexp);
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add(1)), phexpNum);
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("b")), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add(JsonArray.create().add("a")));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(JsonArray.create().add(1)));
|
||||
assertThat(phexpIgnoreCase)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("b")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -462,10 +469,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("av1").add("av2")), phexp);
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("bv1").add("bv2")), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("av1").add("av2")));
|
||||
assertThat(phexpIgnoreCase)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("bv1").add("bv2")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -482,10 +491,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("av1").add("av2")), phexp);
|
||||
assertEquals(JsonArray.create().add(JsonArray.create().add("bv1").add("bv2")), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("av1").add("av2")));
|
||||
assertThat(phexpIgnoreCase)
|
||||
.isEqualTo(JsonArray.create().add(JsonArray.create().add("bv1").add("bv2")));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -519,12 +530,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add("1"), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add("1"));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -542,12 +553,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create(), phexp);
|
||||
assertEquals(JsonArray.create(), phexpNum);
|
||||
assertEquals(JsonArray.create(), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -565,12 +576,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create(), phexp);
|
||||
assertEquals(JsonArray.create(), phexpNum);
|
||||
assertEquals(JsonArray.create(), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -588,12 +599,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create(), phexp);
|
||||
assertEquals(JsonArray.create(), phexpNum);
|
||||
assertEquals(JsonArray.create(), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create());
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -611,12 +622,12 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpIgnoreCase = JsonArray.create();
|
||||
Expression expIgnoreCase = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", true, values, new AtomicInteger(), phexpIgnoreCase);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
}
|
||||
|
||||
enum TestEnum {
|
||||
@@ -641,13 +652,13 @@ public class N1qlQueryCreatorTest {
|
||||
JsonArray phexpEnum = JsonArray.create();
|
||||
Expression expEnum = N1qlQueryCreatorUtils.createExpression(keyword, "doc.field", false, values, new AtomicInteger(), phexpEnum);
|
||||
|
||||
assertEquals(expected, exp.toString());
|
||||
assertEquals(expectedNum, expNum.toString());
|
||||
assertEquals(expectedIgnoreCase, expIgnoreCase.toString());
|
||||
assertEquals(expectedEnum, expEnum.toString());
|
||||
assertEquals(JsonArray.create().add("a"), phexp);
|
||||
assertEquals(JsonArray.create().add(1), phexpNum);
|
||||
assertEquals(JsonArray.create().add("b"), phexpIgnoreCase);
|
||||
assertEquals(JsonArray.create().add("TEST"), phexpEnum);
|
||||
assertThat(exp.toString()).isEqualTo(expected);
|
||||
assertThat(expNum.toString()).isEqualTo(expectedNum);
|
||||
assertThat(expIgnoreCase.toString()).isEqualTo(expectedIgnoreCase);
|
||||
assertThat(expEnum.toString()).isEqualTo(expectedEnum);
|
||||
assertThat(phexp).isEqualTo(JsonArray.create().add("a"));
|
||||
assertThat(phexpNum).isEqualTo(JsonArray.create().add(1));
|
||||
assertThat(phexpIgnoreCase).isEqualTo(JsonArray.create().add("b"));
|
||||
assertThat(phexpEnum).isEqualTo(JsonArray.create().add("TEST"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository.query;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@@ -100,8 +100,9 @@ public class PartTreeN1qBasedQueryTest {
|
||||
PartTreeN1qlBasedQuery query = new PartTreeN1qlBasedQuery(queryMethod, couchbaseOperations);
|
||||
Statement statement = query.getCount(accessor, new Object[] { "value", pr });
|
||||
|
||||
assertEquals("SELECT COUNT(*) AS count FROM `default` WHERE (name = $1) "
|
||||
+ "AND `_class` = \"org.springframework.data.couchbase.core.Beer\"", statement.toString());
|
||||
assertThat(statement.toString())
|
||||
.isEqualTo("SELECT COUNT(*) AS count FROM `default` WHERE (name = $1) "
|
||||
+ "AND `_class` = \"org.springframework.data.couchbase.core.Beer\"");
|
||||
|
||||
}
|
||||
|
||||
@@ -145,8 +146,9 @@ public class PartTreeN1qBasedQueryTest {
|
||||
PartTreeN1qlBasedQuery query = new PartTreeN1qlBasedQuery(queryMethod, couchbaseOperations);
|
||||
Statement statement = query.getCount(accessor, new Object[] { "value", pr });
|
||||
|
||||
assertEquals("SELECT COUNT(*) AS count FROM `default` WHERE (name = $1) "
|
||||
+ "AND `_class` = \"org.springframework.data.couchbase.core.Beer\"", statement.toString());
|
||||
assertThat(statement.toString())
|
||||
.isEqualTo("SELECT COUNT(*) AS count FROM `default` WHERE (name = $1) "
|
||||
+ "AND `_class` = \"org.springframework.data.couchbase.core.Beer\"");
|
||||
|
||||
}
|
||||
|
||||
@@ -180,8 +182,9 @@ public class PartTreeN1qBasedQueryTest {
|
||||
PartTreeN1qlBasedQuery query = new PartTreeN1qlBasedQuery(queryMethod, couchbaseOperations);
|
||||
Statement statement = query.getStatement(accessor, null, processor.getReturnedType());
|
||||
|
||||
assertEquals("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS, `B`.`desc` FROM `B` WHERE "
|
||||
+ "`_class` = \"org.springframework.data.couchbase.core.Beer\"", statement.toString());
|
||||
assertThat(statement.toString())
|
||||
.isEqualTo("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS, `B`.`desc` FROM `B` WHERE "
|
||||
+ "`_class` = \"org.springframework.data.couchbase.core.Beer\"");
|
||||
|
||||
}
|
||||
|
||||
@@ -212,8 +215,9 @@ public class PartTreeN1qBasedQueryTest {
|
||||
PartTreeN1qlBasedQuery query = new PartTreeN1qlBasedQuery(queryMethod, couchbaseOperations);
|
||||
Statement statement = query.getStatement(accessor, null, processor.getReturnedType());
|
||||
|
||||
assertEquals("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS, `B`.`name`, `B`.`desc` FROM `B` "
|
||||
+ "WHERE `_class` = \"org.springframework.data.couchbase.core.Beer\"", statement.toString());
|
||||
assertThat(statement.toString())
|
||||
.isEqualTo("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS, `B`.`name`, `B`.`desc` FROM `B` "
|
||||
+ "WHERE `_class` = \"org.springframework.data.couchbase.core.Beer\"");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.repository.query;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import com.couchbase.client.java.document.json.JsonValue;
|
||||
@@ -42,7 +42,7 @@ import reactor.core.publisher.Flux;
|
||||
* @author Johannes Jasper
|
||||
*/
|
||||
public class ReactiveAbstractN1qlBasedQueryTest {
|
||||
|
||||
|
||||
CouchbaseMappingContext context = new CouchbaseMappingContext();
|
||||
ProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory();
|
||||
RepositoryMetadata metadata = DefaultRepositoryMetadata.getMetadata(SampleRepository.class);
|
||||
@@ -67,10 +67,11 @@ public class ReactiveAbstractN1qlBasedQueryTest {
|
||||
when(template.getDefaultConsistency()).thenReturn(Consistency.STRONGLY_CONSISTENT);
|
||||
|
||||
ScanConsistency defaultConsistency = new SampleQuery(defaultQueryMethod, template).getScanConsistency();
|
||||
assertEquals(defaultConsistency, Consistency.STRONGLY_CONSISTENT.n1qlConsistency());
|
||||
assertThat(Consistency.STRONGLY_CONSISTENT.n1qlConsistency())
|
||||
.isEqualTo(defaultConsistency);
|
||||
|
||||
ScanConsistency unboundedConsistency = new SampleQuery(unboundedQueryMethod, template).getScanConsistency();
|
||||
assertEquals(unboundedConsistency, ScanConsistency.NOT_BOUNDED);
|
||||
assertThat(ScanConsistency.NOT_BOUNDED).isEqualTo(unboundedConsistency);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.data.couchbase.repository.query;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.eq;
|
||||
@@ -33,8 +33,9 @@ public class StringN1QlBasedQueryTest {
|
||||
String parsed = new StringBasedN1qlQueryParser(statement, null, "B", this.couchbaseConverter, "_class", String.class)
|
||||
.doParse(SPEL_PARSER, SPEL_EVALUATION_CONTEXT, false);
|
||||
|
||||
assertEquals("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS, `B`.* FROM `B` where "
|
||||
+ "SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS, `B`.* FROM `B`", parsed);
|
||||
assertThat(parsed)
|
||||
.isEqualTo("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS, `B`.* FROM `B` where "
|
||||
+ "SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS, `B`.* FROM `B`");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -43,7 +44,7 @@ public class StringN1QlBasedQueryTest {
|
||||
String parsed = new StringBasedN1qlQueryParser(statement, null, "B", this.couchbaseConverter, "_class", String.class)
|
||||
.doParse(SPEL_PARSER, SPEL_EVALUATION_CONTEXT, false);
|
||||
|
||||
assertEquals("SELECT * FROM `B` WHERE `B`.test = 1", parsed);
|
||||
assertThat(parsed).isEqualTo("SELECT * FROM `B` WHERE `B`.test = 1");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,8 +53,9 @@ public class StringN1QlBasedQueryTest {
|
||||
String parsed = new StringBasedN1qlQueryParser(statement, null, "B", this.couchbaseConverter, "_class", String.class)
|
||||
.doParse(SPEL_PARSER, SPEL_EVALUATION_CONTEXT, false);
|
||||
|
||||
assertEquals("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS FROM a where a.test = 1 and "
|
||||
+ "META(`B`).id AS _ID, META(`B`).cas AS _CAS", parsed);
|
||||
assertThat(parsed)
|
||||
.isEqualTo("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS FROM a where a.test = 1 and "
|
||||
+ "META(`B`).id AS _ID, META(`B`).cas AS _CAS");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -62,8 +64,9 @@ public class StringN1QlBasedQueryTest {
|
||||
String parsed = new StringBasedN1qlQueryParser(statement, null, "B", this.couchbaseConverter, "@class", String.class)
|
||||
.doParse(SPEL_PARSER, SPEL_EVALUATION_CONTEXT, false);
|
||||
|
||||
assertEquals("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS FROM a WHERE a.test = 1 AND `@class` = "
|
||||
+ "\"java.lang.String\"", parsed);
|
||||
assertThat(parsed)
|
||||
.isEqualTo("SELECT META(`B`).id AS _ID, META(`B`).cas AS _CAS FROM a WHERE a.test = 1 AND `@class` = "
|
||||
+ "\"java.lang.String\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -72,7 +75,8 @@ public class StringN1QlBasedQueryTest {
|
||||
String parsed = new StringBasedN1qlQueryParser(statement, null, "B", this.couchbaseConverter, "_class", String.class)
|
||||
.doParse(SPEL_PARSER, SPEL_EVALUATION_CONTEXT, true);
|
||||
|
||||
assertEquals("SELECT COUNT(*) AS " + CountFragment.COUNT_ALIAS + " FROM `B` WHERE true", parsed);
|
||||
assertThat(parsed)
|
||||
.isEqualTo("SELECT COUNT(*) AS " + CountFragment.COUNT_ALIAS + " FROM `B` WHERE true");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,8 +85,8 @@ public class StringN1QlBasedQueryTest {
|
||||
String parsed = new StringBasedN1qlQueryParser(statement, null, "B", this.couchbaseConverter, "_class", String.class)
|
||||
.doParse(SPEL_PARSER, SPEL_EVALUATION_CONTEXT, true);
|
||||
|
||||
assertEquals("DELETE FROM `B` WHERE test = 1 AND `_class` = "
|
||||
+ "\"java.lang.String\"", parsed);
|
||||
assertThat(parsed).isEqualTo("DELETE FROM `B` WHERE test = 1 AND `_class` = "
|
||||
+ "\"java.lang.String\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,8 +95,8 @@ public class StringN1QlBasedQueryTest {
|
||||
String parsed = new StringBasedN1qlQueryParser(statement, null, "B", this.couchbaseConverter, "_class", String.class)
|
||||
.doParse(SPEL_PARSER, SPEL_EVALUATION_CONTEXT, true);
|
||||
|
||||
assertEquals("DELETE FROM `B` WHERE test = 1 AND `_class` = "
|
||||
+ "\"java.lang.String\" returning `B`.*, META(`B`).id AS _ID, META(`B`).cas AS _CAS", parsed);
|
||||
assertThat(parsed).isEqualTo("DELETE FROM `B` WHERE test = 1 AND `_class` = "
|
||||
+ "\"java.lang.String\" returning `B`.*, META(`B`).id AS _ID, META(`B`).cas AS _CAS");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.springframework.data.couchbase.repository.query.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -14,6 +12,8 @@ import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.geo.Polygon;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
/**
|
||||
* An abstract base for testing {@link PointInShapeEvaluator} implementations.
|
||||
* Each implementation can be commonly tested by extending this base and instantiating the evaluator in createEvaluator.
|
||||
@@ -72,14 +72,20 @@ public abstract class AbstractPointInShapeEvaluatorTest {
|
||||
Point outside = new Point(1.1, 0.3);
|
||||
Point edge = new Point(1.0, 2.0);
|
||||
|
||||
assertTrue("point inside open polygon failed", evaluator.pointInPolygon(inside, openTriangle));
|
||||
assertFalse("point outside open polygon failed", evaluator.pointInPolygon(outside, openTriangle));
|
||||
assertFalse("point on edge of open polygon should not be considered within the polygon",
|
||||
evaluator.pointInPolygon(edge, openTriangle));
|
||||
assertTrue("point inside closed polygon failed", evaluator.pointInPolygon(inside, closedTriangle));
|
||||
assertFalse("point outside closed polygon failed", evaluator.pointInPolygon(outside, closedTriangle));
|
||||
assertFalse("point on edge of closed polygon should not be considered within the polygon",
|
||||
evaluator.pointInPolygon(edge, closedTriangle));
|
||||
assertThat(evaluator.pointInPolygon(inside, openTriangle))
|
||||
.as("point inside open polygon failed").isTrue();
|
||||
assertThat(evaluator.pointInPolygon(outside, openTriangle))
|
||||
.as("point outside open polygon failed").isFalse();
|
||||
assertThat(evaluator.pointInPolygon(edge, openTriangle))
|
||||
.as("point on edge of open polygon should not be considered within the polygon")
|
||||
.isFalse();
|
||||
assertThat(evaluator.pointInPolygon(inside, closedTriangle))
|
||||
.as("point inside closed polygon failed").isTrue();
|
||||
assertThat(evaluator.pointInPolygon(outside, closedTriangle))
|
||||
.as("point outside closed polygon failed").isFalse();
|
||||
assertThat(evaluator.pointInPolygon(edge, closedTriangle))
|
||||
.as("point on edge of closed polygon should not be considered within the polygon")
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,14 +107,20 @@ public abstract class AbstractPointInShapeEvaluatorTest {
|
||||
Point outside = new Point(1.1, 0.3);
|
||||
Point edge = new Point(1.0, 2.0);
|
||||
|
||||
assertTrue("point inside open polygon failed", evaluator.pointInPolygon(inside, openTriangle));
|
||||
assertFalse("point outside open polygon failed", evaluator.pointInPolygon(outside, openTriangle));
|
||||
assertFalse("point on edge of open polygon should not be considered within the polygon",
|
||||
evaluator.pointInPolygon(edge, openTriangle));
|
||||
assertTrue("point inside closed polygon failed", evaluator.pointInPolygon(inside, closedTriangle));
|
||||
assertFalse("point outside closed polygon failed", evaluator.pointInPolygon(outside, closedTriangle));
|
||||
assertFalse("point on edge of closed polygon should not be considered within the polygon",
|
||||
evaluator.pointInPolygon(edge, closedTriangle));
|
||||
assertThat(evaluator.pointInPolygon(inside, openTriangle))
|
||||
.as("point inside open polygon failed").isTrue();
|
||||
assertThat(evaluator.pointInPolygon(outside, openTriangle))
|
||||
.as("point outside open polygon failed").isFalse();
|
||||
assertThat(evaluator.pointInPolygon(edge, openTriangle))
|
||||
.as("point on edge of open polygon should not be considered within the polygon")
|
||||
.isFalse();
|
||||
assertThat(evaluator.pointInPolygon(inside, closedTriangle))
|
||||
.as("point inside closed polygon failed").isTrue();
|
||||
assertThat(evaluator.pointInPolygon(outside, closedTriangle))
|
||||
.as("point outside closed polygon failed").isFalse();
|
||||
assertThat(evaluator.pointInPolygon(edge, closedTriangle))
|
||||
.as("point on edge of closed polygon should not be considered within the polygon")
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -119,9 +131,12 @@ public abstract class AbstractPointInShapeEvaluatorTest {
|
||||
Point outside = new Point(1.3, 2d);
|
||||
Point onEdge = new Point(-2d, 0d);
|
||||
|
||||
assertTrue("point inside failed", evaluator.pointInCircle(inside, circle));
|
||||
assertFalse("point outside failed", evaluator.pointInCircle(outside, circle));
|
||||
assertTrue("point on edge of circle should be considered within / near", evaluator.pointInCircle(onEdge, circle));
|
||||
assertThat(evaluator.pointInCircle(inside, circle)).as("point inside failed")
|
||||
.isTrue();
|
||||
assertThat(evaluator.pointInCircle(outside, circle)).as("point outside failed")
|
||||
.isFalse();
|
||||
assertThat(evaluator.pointInCircle(onEdge, circle))
|
||||
.as("point on edge of circle should be considered within / near").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,9 +148,12 @@ public abstract class AbstractPointInShapeEvaluatorTest {
|
||||
Point outside = new Point(1.3, 2d);
|
||||
Point onEdge = new Point(-2d, 0d);
|
||||
|
||||
assertTrue("point inside failed", evaluator.pointInCircle(inside, center, radius));
|
||||
assertFalse("point outside failed", evaluator.pointInCircle(outside, center, radius));
|
||||
assertTrue("point on edge of circle should be considered within / near", evaluator.pointInCircle(onEdge, center, radius));
|
||||
assertThat(evaluator.pointInCircle(inside, center, radius)).as("point inside failed")
|
||||
.isTrue();
|
||||
assertThat(evaluator.pointInCircle(outside, center, radius))
|
||||
.as("point outside failed").isFalse();
|
||||
assertThat(evaluator.pointInCircle(onEdge, center, radius))
|
||||
.as("point on edge of circle should be considered within / near").isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -163,8 +181,8 @@ public abstract class AbstractPointInShapeEvaluatorTest {
|
||||
List<LocatedValue> filteredOpen = evaluator.removeFalsePositives(tested, LOCATED_VALUE_POINT_CONVERTER, openTriangle);
|
||||
List<LocatedValue> filteredClosed = evaluator.removeFalsePositives(tested, LOCATED_VALUE_POINT_CONVERTER, closedTriangle);
|
||||
|
||||
assertEquals(expected, filteredOpen);
|
||||
assertEquals(expected, filteredClosed);
|
||||
assertThat(filteredOpen).isEqualTo(expected);
|
||||
assertThat(filteredClosed).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -192,8 +210,8 @@ public abstract class AbstractPointInShapeEvaluatorTest {
|
||||
List<LocatedValue> filteredOpen = evaluator.removeFalsePositives(tested, LOCATED_VALUE_POINT_CONVERTER, openTriangle);
|
||||
List<LocatedValue> filteredClosed = evaluator.removeFalsePositives(tested, LOCATED_VALUE_POINT_CONVERTER, closedTriangle);
|
||||
|
||||
assertEquals(expected, filteredOpen);
|
||||
assertEquals(expected, filteredClosed);
|
||||
assertThat(filteredOpen).isEqualTo(expected);
|
||||
assertThat(filteredClosed).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -209,7 +227,7 @@ public abstract class AbstractPointInShapeEvaluatorTest {
|
||||
|
||||
List<LocatedValue> filtered = evaluator.removeFalsePositives(tested, LOCATED_VALUE_POINT_CONVERTER, circle);
|
||||
|
||||
assertEquals(expected, filtered);
|
||||
assertThat(filtered).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -226,6 +244,6 @@ public abstract class AbstractPointInShapeEvaluatorTest {
|
||||
|
||||
List<LocatedValue> filtered = evaluator.removeFalsePositives(tested, LOCATED_VALUE_POINT_CONVERTER, center, radius);
|
||||
|
||||
assertEquals(expected, filtered);
|
||||
assertThat(filtered).isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.springframework.data.couchbase.repository.query.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test case for the {@link AwtPointInShapeEvaluator}.
|
||||
*
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.springframework.data.couchbase.repository.query.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.geo.Box;
|
||||
import org.springframework.data.geo.Circle;
|
||||
@@ -12,6 +10,9 @@ import org.springframework.data.geo.Shape;
|
||||
|
||||
import com.couchbase.client.java.document.json.JsonArray;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.data.Offset.offset;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link GeoUtils} utility class.
|
||||
* @author Simon Baslé
|
||||
@@ -22,32 +23,32 @@ public class GeoUtilsTest {
|
||||
public void testGetBoundingBoxForNear() throws Exception {
|
||||
final Distance distance = new Distance(120);
|
||||
double[] bbox = GeoUtils.getBoundingBoxForNear(new Point(1, 1), distance);
|
||||
assertEquals(-119d, bbox[0], 0d); //xMin
|
||||
assertEquals(121d, bbox[2], 0d); //xMax
|
||||
assertEquals(-119d, bbox[1], 0d); //yMin
|
||||
assertEquals(121d, bbox[3], 0d); //yMax
|
||||
assertThat(bbox[0]).isCloseTo(-119d, offset(0d)); //xMin
|
||||
assertThat(bbox[2]).isCloseTo(121d, offset(0d)); //xMax
|
||||
assertThat(bbox[1]).isCloseTo(-119d, offset(0d)); //yMin
|
||||
assertThat(bbox[3]).isCloseTo(121d, offset(0d)); //yMax
|
||||
|
||||
bbox = GeoUtils.getBoundingBoxForNear(new Point(-3,-5), distance);
|
||||
assertEquals(-123d, bbox[0], 0d); //xMin
|
||||
assertEquals(117d, bbox[2], 0d); //xMax
|
||||
assertEquals(-125d, bbox[1], 0d); //yMin
|
||||
assertEquals(115d, bbox[3], 0d); //yMax
|
||||
assertThat(bbox[0]).isCloseTo(-123d, offset(0d)); //xMin
|
||||
assertThat(bbox[2]).isCloseTo(117d, offset(0d)); //xMax
|
||||
assertThat(bbox[1]).isCloseTo(-125d, offset(0d)); //yMin
|
||||
assertThat(bbox[3]).isCloseTo(115d, offset(0d)); //yMax
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBoundingBoxForNearNegativeDistance() throws Exception {
|
||||
final Distance distance = new Distance(-120);
|
||||
double[] bbox = GeoUtils.getBoundingBoxForNear(new Point(1, 1), distance);
|
||||
assertEquals(-119d, bbox[0], 0d); //xMin
|
||||
assertEquals(121d, bbox[2], 0d); //xMax
|
||||
assertEquals(-119d, bbox[1], 0d); //yMin
|
||||
assertEquals(121d, bbox[3], 0d); //yMax
|
||||
assertThat(bbox[0]).isCloseTo(-119d, offset(0d)); //xMin
|
||||
assertThat(bbox[2]).isCloseTo(121d, offset(0d)); //xMax
|
||||
assertThat(bbox[1]).isCloseTo(-119d, offset(0d)); //yMin
|
||||
assertThat(bbox[3]).isCloseTo(121d, offset(0d)); //yMax
|
||||
|
||||
bbox = GeoUtils.getBoundingBoxForNear(new Point(-3,-5), distance);
|
||||
assertEquals(-123d, bbox[0], 0d); //xMin
|
||||
assertEquals(117d, bbox[2], 0d); //xMax
|
||||
assertEquals(-125d, bbox[1], 0d); //yMin
|
||||
assertEquals(115d, bbox[3], 0d); //yMax
|
||||
assertThat(bbox[0]).isCloseTo(-123d, offset(0d)); //xMin
|
||||
assertThat(bbox[2]).isCloseTo(117d, offset(0d)); //xMax
|
||||
assertThat(bbox[1]).isCloseTo(-125d, offset(0d)); //yMin
|
||||
assertThat(bbox[3]).isCloseTo(115d, offset(0d)); //yMax
|
||||
}
|
||||
|
||||
@Test(expected = NullPointerException.class)
|
||||
@@ -104,12 +105,12 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertPointsTo2DRanges(startRange, endRange, true, p1, p2);
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(2d, startRange.getDouble(0), 0d);
|
||||
assertEquals(3d, startRange.getDouble(1), 0d);
|
||||
assertEquals(4d, endRange.getDouble(0), 0d);
|
||||
assertEquals(5d, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(2d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(3d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(4d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(5d, offset(0d));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -121,12 +122,12 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertPointsTo2DRanges(startRange, endRange, false, p1, p2);
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(2d, startRange.getDouble(0), 0d);
|
||||
assertEquals(3d, startRange.getDouble(1), 0d);
|
||||
assertEquals(4d, endRange.getDouble(0), 0d);
|
||||
assertEquals(5d, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(2d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(3d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(4d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(5d, offset(0d));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -139,12 +140,12 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertPointsTo2DRanges(startRange, endRange, false, p1, p2, p3);
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(-4d, startRange.getDouble(0), 0d);
|
||||
assertEquals(-12d, startRange.getDouble(1), 0d);
|
||||
assertEquals(6d, endRange.getDouble(0), 0d);
|
||||
assertEquals(3d, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(-4d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(-12d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(6d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(3d, offset(0d));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -162,12 +163,12 @@ public class GeoUtilsTest {
|
||||
new Point(6, 5),
|
||||
new Point(6, 3));
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(3d, startRange.getDouble(0), 0d);
|
||||
assertEquals(3d, startRange.getDouble(1), 0d);
|
||||
assertEquals(9d, endRange.getDouble(0), 0d);
|
||||
assertEquals(9d, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(3d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(3d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(9d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(9d, offset(0d));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -188,12 +189,12 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertShapeTo2DRanges(startRange, endRange, box);
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(0d, startRange.getDouble(0), 0d);
|
||||
assertEquals(5d, startRange.getDouble(1), 0d);
|
||||
assertEquals(10d, endRange.getDouble(0), 0d);
|
||||
assertEquals(30, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(0d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(5d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(10d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(30, offset(0d));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -204,12 +205,12 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertShapeTo2DRanges(startRange, endRange, box);
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(0d, startRange.getDouble(0), 0d);
|
||||
assertEquals(5d, startRange.getDouble(1), 0d);
|
||||
assertEquals(10d, endRange.getDouble(0), 0d);
|
||||
assertEquals(-3d, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(0d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(5d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(10d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(-3d, offset(0d));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,12 +221,12 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertShapeTo2DRanges(startRange, endRange, box);
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(0d, startRange.getDouble(0), 0d);
|
||||
assertEquals(-3d, startRange.getDouble(1), 0d);
|
||||
assertEquals(10d, endRange.getDouble(0), 0d);
|
||||
assertEquals(5d, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(0d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(-3d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(10d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(5d, offset(0d));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -245,12 +246,12 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertShapeTo2DRanges(startRange, endRange, polygon);
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(3d, startRange.getDouble(0), 0d);
|
||||
assertEquals(3d, startRange.getDouble(1), 0d);
|
||||
assertEquals(9d, endRange.getDouble(0), 0d);
|
||||
assertEquals(9d, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(3d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(3d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(9d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(9d, offset(0d));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -282,14 +283,14 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertShapeTo2DRanges(startRangePolygon, endRangePolygon, polygon);
|
||||
|
||||
assertEquals(2, startRangePoints.size());
|
||||
assertEquals(2, endRangePoints.size());
|
||||
assertEquals(3d, startRangePoints.getDouble(0), 0d);
|
||||
assertEquals(3d, startRangePoints.getDouble(1), 0d);
|
||||
assertEquals(9d, endRangePoints.getDouble(0), 0d);
|
||||
assertEquals(9d, endRangePoints.getDouble(1), 0d);
|
||||
assertEquals(endRangePoints, endRangePolygon);
|
||||
assertEquals(startRangePoints, startRangePolygon);
|
||||
assertThat(startRangePoints.size()).isEqualTo(2);
|
||||
assertThat(endRangePoints.size()).isEqualTo(2);
|
||||
assertThat(startRangePoints.getDouble(0)).isCloseTo(3d, offset(0d));
|
||||
assertThat(startRangePoints.getDouble(1)).isCloseTo(3d, offset(0d));
|
||||
assertThat(endRangePoints.getDouble(0)).isCloseTo(9d, offset(0d));
|
||||
assertThat(endRangePoints.getDouble(1)).isCloseTo(9d, offset(0d));
|
||||
assertThat(endRangePolygon).isEqualTo(endRangePoints);
|
||||
assertThat(startRangePolygon).isEqualTo(startRangePoints);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -300,12 +301,12 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertShapeTo2DRanges(startRange, endRange, circle);
|
||||
|
||||
assertEquals(2, startRange.size());
|
||||
assertEquals(2, endRange.size());
|
||||
assertEquals(-3d, startRange.getDouble(0), 0d);
|
||||
assertEquals(-3d, startRange.getDouble(1), 0d);
|
||||
assertEquals(3d, endRange.getDouble(0), 0d);
|
||||
assertEquals(3d, endRange.getDouble(1), 0d);
|
||||
assertThat(startRange.size()).isEqualTo(2);
|
||||
assertThat(endRange.size()).isEqualTo(2);
|
||||
assertThat(startRange.getDouble(0)).isCloseTo(-3d, offset(0d));
|
||||
assertThat(startRange.getDouble(1)).isCloseTo(-3d, offset(0d));
|
||||
assertThat(endRange.getDouble(0)).isCloseTo(3d, offset(0d));
|
||||
assertThat(endRange.getDouble(1)).isCloseTo(3d, offset(0d));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -319,18 +320,18 @@ public class GeoUtilsTest {
|
||||
GeoUtils.convertShapeTo2DRanges(startRangeCircle, endRangeCircle, circle);
|
||||
double[] bbox = GeoUtils.getBoundingBoxForNear(origin, distance);
|
||||
|
||||
assertEquals(2, startRangeCircle.size());
|
||||
assertEquals(2, endRangeCircle.size());
|
||||
assertThat(startRangeCircle.size()).isEqualTo(2);
|
||||
assertThat(endRangeCircle.size()).isEqualTo(2);
|
||||
|
||||
assertEquals(-3d, bbox[0], 0d);
|
||||
assertEquals(-3d, bbox[1], 0d);
|
||||
assertEquals(3d, bbox[2], 0d);
|
||||
assertEquals(3d, bbox[3], 0d);
|
||||
assertThat(bbox[0]).isCloseTo(-3d, offset(0d));
|
||||
assertThat(bbox[1]).isCloseTo(-3d, offset(0d));
|
||||
assertThat(bbox[2]).isCloseTo(3d, offset(0d));
|
||||
assertThat(bbox[3]).isCloseTo(3d, offset(0d));
|
||||
|
||||
assertEquals(bbox[0], startRangeCircle.getDouble(0), 0d);
|
||||
assertEquals(bbox[1], startRangeCircle.getDouble(1), 0d);
|
||||
assertEquals(bbox[2], endRangeCircle.getDouble(0), 0d);
|
||||
assertEquals(bbox[3], endRangeCircle.getDouble(1), 0d);
|
||||
assertThat(startRangeCircle.getDouble(0)).isCloseTo(bbox[0], offset(0d));
|
||||
assertThat(startRangeCircle.getDouble(1)).isCloseTo(bbox[1], offset(0d));
|
||||
assertThat(endRangeCircle.getDouble(0)).isCloseTo(bbox[2], offset(0d));
|
||||
assertThat(endRangeCircle.getDouble(1)).isCloseTo(bbox[3], offset(0d));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -350,4 +351,4 @@ public class GeoUtilsTest {
|
||||
|
||||
GeoUtils.convertShapeTo2DRanges(startRange, endRange, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.springframework.data.couchbase.repository.query.support;
|
||||
|
||||
import static com.couchbase.client.java.query.dsl.Expression.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Ignore;
|
||||
@@ -26,7 +26,7 @@ public class N1qlUtilsTest {
|
||||
|
||||
String real = N1qlUtils.escapedBucket(bucketName).toString();
|
||||
|
||||
assertEquals(expected, real);
|
||||
assertThat(real).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -34,7 +34,7 @@ public class N1qlUtilsTest {
|
||||
String expected = "SELECT META(`b`).id AS _ID, META(`b`).cas AS _CAS, `b`.*";
|
||||
String real = N1qlUtils.createSelectClauseForEntity("b").toString();
|
||||
|
||||
assertEquals(expected, real);
|
||||
assertThat(real).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -42,7 +42,7 @@ public class N1qlUtilsTest {
|
||||
String expected = "SELECT META(`b`).id AS _ID, META(`b`).cas AS _CAS, `b`.* FROM `b`";
|
||||
String real = N1qlUtils.createSelectFromForEntity("b").toString();
|
||||
|
||||
assertEquals(expected, real);
|
||||
assertThat(real).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,7 +55,7 @@ public class N1qlUtilsTest {
|
||||
|
||||
String real = N1qlUtils.createWhereFilterForEntity(null, converter, metadata).toString();
|
||||
|
||||
assertEquals(expected, real);
|
||||
assertThat(real).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,7 +68,7 @@ public class N1qlUtilsTest {
|
||||
|
||||
String real = N1qlUtils.createWhereFilterForEntity(null, converter, metadata).toString();
|
||||
|
||||
assertEquals(expected, real);
|
||||
assertThat(real).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,9 +95,13 @@ public class N1qlUtilsTest {
|
||||
com.couchbase.client.java.query.dsl.Sort[] realSort =
|
||||
N1qlUtils.createSort(Sort.by("description", "attendees"), converter);
|
||||
|
||||
assertEquals(2, realSort.length);
|
||||
assertEquals(com.couchbase.client.java.query.dsl.Sort.asc("`description`").toString(), realSort[0].toString());
|
||||
assertEquals(com.couchbase.client.java.query.dsl.Sort.asc("`attendees`").toString(), realSort[1].toString());
|
||||
assertThat(realSort.length).isEqualTo(2);
|
||||
assertThat(realSort[0].toString())
|
||||
.isEqualTo(com.couchbase.client.java.query.dsl.Sort.asc("`description`")
|
||||
.toString());
|
||||
assertThat(realSort[1].toString())
|
||||
.isEqualTo(com.couchbase.client.java.query.dsl.Sort.asc("`attendees`")
|
||||
.toString());
|
||||
|
||||
verifyZeroInteractions(converter);
|
||||
}
|
||||
@@ -108,9 +112,12 @@ public class N1qlUtilsTest {
|
||||
Sort sortDescription = Sort.by(Order.asc("description").ignoreCase(), Order.asc("attendees"));
|
||||
com.couchbase.client.java.query.dsl.Sort[] realSort = N1qlUtils.createSort(sortDescription, converter);
|
||||
|
||||
assertEquals(2, realSort.length);
|
||||
assertEquals(com.couchbase.client.java.query.dsl.Sort.asc("LOWER(TOSTRING(`description`))").toString(), realSort[0].toString());
|
||||
assertEquals(com.couchbase.client.java.query.dsl.Sort.asc("`attendees`").toString(), realSort[1].toString());
|
||||
assertThat(realSort.length).isEqualTo(2);
|
||||
assertThat(realSort[0].toString()).isEqualTo(com.couchbase.client.java.query.dsl.Sort
|
||||
.asc("LOWER(TOSTRING(`description`))").toString());
|
||||
assertThat(realSort[1].toString())
|
||||
.isEqualTo(com.couchbase.client.java.query.dsl.Sort.asc("`attendees`")
|
||||
.toString());
|
||||
|
||||
verifyZeroInteractions(converter);
|
||||
}
|
||||
@@ -127,8 +134,8 @@ public class N1qlUtilsTest {
|
||||
String real = N1qlUtils.createCountQueryForEntity("b", converter, entityInformation).toString();
|
||||
String realWithTypeKey = N1qlUtils.createCountQueryForEntity("b", converter, entityInformation).toString();
|
||||
|
||||
assertEquals(expectedDefault, real);
|
||||
assertEquals(expectedTypeKey, realWithTypeKey);
|
||||
assertThat(real).isEqualTo(expectedDefault);
|
||||
assertThat(realWithTypeKey).isEqualTo(expectedTypeKey);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -143,7 +150,7 @@ public class N1qlUtilsTest {
|
||||
x("field1").gte(30).or(x("field2").eq(s("foo"))),
|
||||
converter, metadata).toString();
|
||||
|
||||
assertEquals(expected, real);
|
||||
assertThat(real).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,7 +159,7 @@ public class N1qlUtilsTest {
|
||||
com.couchbase.client.java.query.dsl.Sort[] realSort =
|
||||
N1qlUtils.createSort(Sort.by("party.attendees"), converter);
|
||||
|
||||
assertEquals("`party`.`attendees` ASC", realSort[0].toString());
|
||||
assertThat(realSort[0].toString()).isEqualTo("`party`.`attendees` ASC");
|
||||
verifyZeroInteractions(converter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
package org.springframework.data.couchbase.repository.spel;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.couchbase.client.java.Bucket;
|
||||
@@ -36,6 +32,8 @@ import org.springframework.data.couchbase.repository.support.IndexManager;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.TestExecutionListeners;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Simon Baslé
|
||||
*/
|
||||
@@ -59,9 +57,9 @@ public class SpelRepositoryIntegrationTests {
|
||||
@Test
|
||||
public void testSpelExtensionResolved() {
|
||||
List<User> users = repository.findCustomUsers();
|
||||
assertEquals(1, users.size());
|
||||
assertEquals("testuser-3", users.get(0).getKey());
|
||||
assertEquals("uname-3", users.get(0).getUsername());
|
||||
assertThat(users.size()).isEqualTo(1);
|
||||
assertThat(users.get(0).getKey()).isEqualTo("testuser-3");
|
||||
assertThat(users.get(0).getUsername()).isEqualTo("uname-3");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,10 +67,10 @@ public class SpelRepositoryIntegrationTests {
|
||||
List<User> usersByName = repository.findUserWithDynamicCriteria("username", "uname-5");
|
||||
List<User> usersByAge = repository.findUserWithDynamicCriteria("age", 4);
|
||||
|
||||
assertThat(usersByName, hasSize(1));
|
||||
assertThat(usersByAge, hasSize(1));
|
||||
assertThat(usersByName.get(0).getKey(), is("testuser-5"));
|
||||
assertThat(usersByAge.get(0).getKey(), is("testuser-4"));
|
||||
assertThat(usersByName).hasSize(1);
|
||||
assertThat(usersByAge).hasSize(1);
|
||||
assertThat(usersByName.get(0).getKey()).isEqualTo("testuser-5");
|
||||
assertThat(usersByAge.get(0).getKey()).isEqualTo("testuser-4");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.data.couchbase.repository.wiring;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -132,20 +132,20 @@ public class RepositoryTemplateWiringIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void testRepositoriesAreInstanciatedWithCorrectTemplates() {
|
||||
assertNotNull(repositoryA);
|
||||
assertNotNull(repositoryB);
|
||||
assertNotNull(repositoryC);
|
||||
assertThat(repositoryA).isNotNull();
|
||||
assertThat(repositoryB).isNotNull();
|
||||
assertThat(repositoryC).isNotNull();
|
||||
|
||||
boolean existA = repositoryA.existsById("testA");
|
||||
boolean existB = repositoryB.existsById("testB");
|
||||
Optional<Misc> valueC = repositoryC.findById("toto");
|
||||
|
||||
assertTrue(existA);
|
||||
assertFalse(existB);
|
||||
assertTrue(valueC.isPresent());
|
||||
assertThat(existA).isTrue();
|
||||
assertThat(existB).isFalse();
|
||||
assertThat(valueC.isPresent()).isTrue();
|
||||
valueC.ifPresent(actual -> {
|
||||
assertEquals("mock", actual.id);
|
||||
assertEquals(true, actual.random);
|
||||
assertThat(actual.id).isEqualTo("mock");
|
||||
assertThat(actual.random).isEqualTo(true);
|
||||
});
|
||||
|
||||
verify(mockOpsA).exists("testA");
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.springframework.data.couchbase.repository.xmlconfig;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -15,6 +12,8 @@ import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.couchbase.ContainerResourceRunner;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Simon Baslé
|
||||
*/
|
||||
@@ -37,14 +36,16 @@ public class XmlRepositoryConfigurationIntegrationTests {
|
||||
reader.loadBeanDefinitions(new ClassPathResource("configurations/couchbase-repository-bean.xml"));
|
||||
|
||||
BeanDefinition definition = factory.getBeanDefinition("xmlItemRepository");
|
||||
assertEquals("org.springframework.data.couchbase.repository.support.CouchbaseRepositoryFactoryBean", definition.getBeanClassName());
|
||||
assertThat(definition.getBeanClassName())
|
||||
.isEqualTo("org.springframework.data.couchbase.repository.support.CouchbaseRepositoryFactoryBean");
|
||||
assertDefinitionProperty(definition, "couchbaseOperations");
|
||||
|
||||
Object bean = factory.getBean("xmlItemRepository");
|
||||
assertTrue(bean instanceof XmlItemRepository);
|
||||
assertThat(bean instanceof XmlItemRepository).isTrue();
|
||||
}
|
||||
|
||||
private void assertDefinitionProperty(BeanDefinition definition, String property) {
|
||||
assertTrue("bean definition properties don't include " + property, definition.getPropertyValues().contains(property));
|
||||
assertThat(definition.getPropertyValues().contains(property))
|
||||
.as("bean definition properties don't include " + property).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user