DATACASS-674 - Polishing.
Replace AtTest(expected = …) and ExpectedException with the corresponding AssertJ assertThatExceptionOfType(…) and assertThatIllegalArgumentException().isThrownBy(…).
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -36,13 +38,13 @@ public class CassandraAuditingRegistrarUnitTests {
|
||||
@Mock AnnotationMetadata metadata;
|
||||
@Mock BeanDefinitionRegistry registry;
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-4
|
||||
@Test // DATACASS-4
|
||||
public void rejectsNullAnnotationMetadata() {
|
||||
registrar.registerBeanDefinitions(null, registry);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> registrar.registerBeanDefinitions(null, registry));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-4
|
||||
@Test // DATACASS-4
|
||||
public void rejectsNullBeanDefinitionRegistry() {
|
||||
registrar.registerBeanDefinitions(metadata, null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> registrar.registerBeanDefinitions(metadata, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,24 +17,21 @@
|
||||
package org.springframework.data.cassandra.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InOrder;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.CqlOperations;
|
||||
|
||||
import com.datastax.driver.core.Cluster;
|
||||
@@ -50,8 +47,6 @@ import com.datastax.driver.core.Session;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CassandraCqlSessionFactoryBeanUnitTests {
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Mock private Cluster mockCluster;
|
||||
|
||||
@Mock private Session mockSession;
|
||||
@@ -186,27 +181,11 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
|
||||
assertThat(factoryBean.getCluster()).isEqualTo(mockCluster);
|
||||
}
|
||||
|
||||
@Test // DATACASS-219
|
||||
public void setClusterToNullThrowsIllegalArgumentException() {
|
||||
|
||||
try {
|
||||
factoryBean.setCluster(null);
|
||||
fail("Missing IllegalArgumentException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e).hasMessageContaining("Cluster must not be null");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test // DATACASS-219
|
||||
public void getClusterWhenUninitializedThrowsIllegalStateException() {
|
||||
|
||||
try {
|
||||
factoryBean.getCluster();
|
||||
fail("Missing IllegalStateException");
|
||||
} catch (IllegalStateException e) {
|
||||
assertThat(e).hasMessageContaining("Cluster was not properly initialized");
|
||||
}
|
||||
assertThatIllegalStateException().isThrownBy(factoryBean::getCluster)
|
||||
.withMessageContaining("Cluster was not properly initialized");
|
||||
}
|
||||
|
||||
@Test // DATACASS-219
|
||||
@@ -226,19 +205,14 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
|
||||
|
||||
assertThat(factoryBean.getObject()).isNull();
|
||||
|
||||
try {
|
||||
factoryBean.getSession();
|
||||
fail("Missing IllegalStateException");
|
||||
} catch (IllegalStateException e) {
|
||||
assertThat(e).hasMessageContaining("Session was not properly initialized");
|
||||
}
|
||||
|
||||
assertThatIllegalStateException().isThrownBy(factoryBean::getSession)
|
||||
.withMessageContaining("Session was not properly initialized");
|
||||
}
|
||||
|
||||
@Test // DATACASS-219
|
||||
public void setAndGetStartupScripts() {
|
||||
|
||||
assertNonNullEmptyCollection(factoryBean.getStartupScripts());
|
||||
assertThat(factoryBean.getStartupScripts()).isEmpty();
|
||||
|
||||
List<String> expectedStartupScripts = Arrays.asList("/path/to/schema.cql", "/path/to/data.cql");
|
||||
factoryBean.setStartupScripts(expectedStartupScripts);
|
||||
@@ -247,7 +221,7 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
|
||||
assertThat(actualStartupScripts).isNotSameAs(expectedStartupScripts).isEqualTo(expectedStartupScripts);
|
||||
|
||||
factoryBean.setStartupScripts(null);
|
||||
assertNonNullEmptyCollection(factoryBean.getStartupScripts());
|
||||
assertThat(factoryBean.getShutdownScripts()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACASS-219
|
||||
@@ -265,22 +239,20 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
|
||||
|
||||
actualStartupScripts = factoryBean.getStartupScripts();
|
||||
|
||||
assertThat(actualStartupScripts).isNotEqualTo(startupScripts);
|
||||
assertThat(actualStartupScripts).hasSize(1);
|
||||
assertThat(actualStartupScripts).isNotEqualTo(startupScripts).hasSize(1);
|
||||
assertThat(actualStartupScripts.get(0)).isEqualTo(startupScripts.get(0));
|
||||
|
||||
try {
|
||||
exception.expect(UnsupportedOperationException.class);
|
||||
actualStartupScripts.add("/path/to/yetAnother.cql");
|
||||
} finally {
|
||||
assertThat(actualStartupScripts).hasSize(1);
|
||||
}
|
||||
List<String> scriptsToUse = actualStartupScripts;
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||
.isThrownBy(() -> scriptsToUse.add("/path/to/yetAnother.cql"));
|
||||
|
||||
assertThat(actualStartupScripts).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setAndGetShutdownScripts() {
|
||||
|
||||
assertNonNullEmptyCollection(factoryBean.getShutdownScripts());
|
||||
assertThat(factoryBean.getShutdownScripts()).isEmpty();
|
||||
|
||||
List<String> expectedShutdownScripts = Arrays.asList("/path/to/backup.cql", "/path/to/dropTables.cql");
|
||||
factoryBean.setShutdownScripts(expectedShutdownScripts);
|
||||
@@ -289,7 +261,7 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
|
||||
assertThat(actualShutdownScripts).isEqualTo(expectedShutdownScripts).isNotSameAs(expectedShutdownScripts);
|
||||
|
||||
factoryBean.setShutdownScripts(null);
|
||||
assertNonNullEmptyCollection(factoryBean.getShutdownScripts());
|
||||
assertThat(factoryBean.getShutdownScripts()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACASS-219
|
||||
@@ -308,17 +280,9 @@ public class CassandraCqlSessionFactoryBeanUnitTests {
|
||||
assertThat(actualShutdownScripts).isNotEqualTo(shutdownScripts);
|
||||
assertThat(actualShutdownScripts).hasSize(1);
|
||||
|
||||
try {
|
||||
exception.expect(UnsupportedOperationException.class);
|
||||
actualShutdownScripts.add("/path/to/blowUpCluster.cql");
|
||||
} finally {
|
||||
assertThat(actualShutdownScripts).hasSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertNonNullEmptyCollection(Collection<?> collection) {
|
||||
|
||||
assertThat(collection).isNotNull();
|
||||
assertThat(collection.isEmpty()).isTrue();
|
||||
List<String> scriptsToUse = actualShutdownScripts;
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class)
|
||||
.isThrownBy(() -> scriptsToUse.add("/path/to/blowUpCluster.cql"));
|
||||
assertThat(actualShutdownScripts).hasSize(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,6 @@ public class CassandraMappingBeanFactoryPostProcessorUnitTests {
|
||||
|
||||
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
|
||||
context.load(CassandraMappingBeanFactoryPostProcessorUnitTests.class, "multiple-mapping-contexts.xml");
|
||||
context.refresh();
|
||||
|
||||
assertThatIllegalStateException().isThrownBy(context::refresh).withMessageContaining("found 2 beans of type")
|
||||
.withMessageContaining("CassandraMappingContext");
|
||||
|
||||
@@ -15,19 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.data.cassandra.config.CassandraSessionFactoryBean.DEFAULT_CREATE_IF_NOT_EXISTS;
|
||||
import static org.springframework.data.cassandra.config.CassandraSessionFactoryBean.DEFAULT_DROP_TABLES;
|
||||
import static org.springframework.data.cassandra.config.CassandraSessionFactoryBean.DEFAULT_DROP_UNUSED_TABLES;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.data.cassandra.config.CassandraSessionFactoryBean.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -89,19 +80,13 @@ public class CassandraSessionFactoryBeanUnitTests {
|
||||
verify(factoryBean, times(1)).performSchemaAction();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class) // DATACASS-219
|
||||
public void afterPropertiesSetThrowsIllegalStateExceptionWhenConverterIsNull() throws Exception {
|
||||
@Test // DATACASS-219
|
||||
public void afterPropertiesSetThrowsIllegalStateExceptionWhenConverterIsNull() {
|
||||
|
||||
try {
|
||||
factoryBean.setCluster(mockCluster);
|
||||
factoryBean.afterPropertiesSet();
|
||||
} catch (IllegalStateException expected) {
|
||||
factoryBean.setCluster(mockCluster);
|
||||
|
||||
assertThat(expected).hasMessage("Converter was not properly initialized");
|
||||
assertThat(expected).hasNoCause();
|
||||
|
||||
throw expected;
|
||||
}
|
||||
assertThatIllegalStateException().isThrownBy(() -> factoryBean.afterPropertiesSet())
|
||||
.withMessageContaining("Converter was not properly initialized");
|
||||
}
|
||||
|
||||
private void performSchemaActionCallsCreateTableWithArgumentsMatchingTheSchemaAction(SchemaAction schemaAction,
|
||||
@@ -171,20 +156,6 @@ public class CassandraSessionFactoryBeanUnitTests {
|
||||
verifyZeroInteractions(mockConverter);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-219
|
||||
public void setConverterToNull() {
|
||||
|
||||
try {
|
||||
factoryBean.setConverter(null);
|
||||
} catch (IllegalArgumentException expected) {
|
||||
|
||||
assertThat(expected).hasMessage("CassandraConverter must not be null");
|
||||
assertThat(expected).hasNoCause();
|
||||
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATACASS-219
|
||||
public void setAndGetSchemaAction() {
|
||||
|
||||
@@ -199,20 +170,6 @@ public class CassandraSessionFactoryBeanUnitTests {
|
||||
assertThat(factoryBean.getSchemaAction()).isEqualTo(SchemaAction.NONE);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-219
|
||||
public void setSchemaActionToNullThrowsIllegalArgumentException() {
|
||||
|
||||
try {
|
||||
factoryBean.setSchemaAction(null);
|
||||
} catch (IllegalArgumentException expected) {
|
||||
|
||||
assertThat(expected).hasMessage("SchemaAction must not be null");
|
||||
assertThat(expected).hasNoCause();
|
||||
|
||||
throw expected;
|
||||
}
|
||||
}
|
||||
|
||||
static class Person {}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,9 +19,8 @@ package org.springframework.data.cassandra.config;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.cassandra.support.BeanDefinitionTestUtils.*;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -31,11 +30,8 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
*
|
||||
* @author John Blum
|
||||
*/
|
||||
// TODO: add more tests!
|
||||
public class ParsingUtilsUnitTests {
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test // DATACASS-298
|
||||
public void addOptionalReferencePropertyUsesDefault() {
|
||||
|
||||
@@ -98,11 +94,10 @@ public class ParsingUtilsUnitTests {
|
||||
@Test // DATACASS-298
|
||||
public void addRequiredReferencePropertyWithNoReferenceFails() {
|
||||
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectMessage("value required for property reference [referenceProperty] on class [null]");
|
||||
|
||||
ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "referenceProperty", null,
|
||||
"defaultReference", true, true);
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "referenceProperty",
|
||||
null, "defaultReference", true, true))
|
||||
.withMessageContaining("value required for property reference [referenceProperty] on class [null]");
|
||||
}
|
||||
|
||||
@Test // DATACASS-298
|
||||
@@ -119,28 +114,25 @@ public class ParsingUtilsUnitTests {
|
||||
@Test // DATACASS-298
|
||||
public void addRequiredValuePropertyWithNoValueFails() {
|
||||
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectMessage("value required for property [valueProperty] on class [null]");
|
||||
|
||||
ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "valueProperty", null, "defaultValue", true,
|
||||
false);
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), "valueProperty", null,
|
||||
"defaultValue", true, false))
|
||||
.withMessageContaining("value required for property [valueProperty] on class [null]");
|
||||
}
|
||||
|
||||
@Test // DATACASS-298
|
||||
public void addPropertyThrowsIllegalArgumentExceptionForNullBuilder() {
|
||||
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectMessage("BeanDefinitionBuilder must not be null");
|
||||
|
||||
ParsingUtils.addProperty(null, "propertyName", "value", "defaultValue", false, false);
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> ParsingUtils.addProperty(null, "propertyName", "value", "defaultValue", false, false))
|
||||
.withMessageContaining("BeanDefinitionBuilder must not be null");
|
||||
}
|
||||
|
||||
@Test // DATACASS-298
|
||||
public void addPropertyThrowsIllegalArgumentExceptionForNullPropertyName() {
|
||||
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectMessage("Property name must not be null");
|
||||
|
||||
ParsingUtils.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), null, "value", "defaultValue", false, true);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> ParsingUtils
|
||||
.addProperty(BeanDefinitionBuilder.genericBeanDefinition(), null, "value", "defaultValue", false, true))
|
||||
.withMessageContaining("Property name must not be null");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Collections;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -66,28 +66,25 @@ public class ExecutableInsertOperationSupportIntegrationTests extends AbstractKe
|
||||
luke.id = "id-2";
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void domainTypeIsRequired() {
|
||||
this.template.insert((Class) null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert((Class) null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void tableIsRequiredOnSet() {
|
||||
this.template.insert(Person.class).inTable((String) null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert(Person.class).inTable((String) null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void optionsIsRequiredOnSet() {
|
||||
this.template.insert(Person.class).withOptions(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert(Person.class).withOptions(null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
public void insertOne() {
|
||||
|
||||
WriteResult insertResult = this.template
|
||||
.insert(Person.class)
|
||||
.inTable("person")
|
||||
.one(han);
|
||||
WriteResult insertResult = this.template.insert(Person.class).inTable("person").one(han);
|
||||
|
||||
assertThat(insertResult.wasApplied()).isTrue();
|
||||
assertThat(this.template.selectOneById(han.id, Person.class)).isEqualTo(han);
|
||||
@@ -98,10 +95,8 @@ public class ExecutableInsertOperationSupportIntegrationTests extends AbstractKe
|
||||
|
||||
this.template.insert(Person.class).inTable("person").one(han);
|
||||
|
||||
WriteResult insertResult = this.template
|
||||
.insert(Person.class).inTable("person")
|
||||
.withOptions(InsertOptions.builder().withIfNotExists().build())
|
||||
.one(han);
|
||||
WriteResult insertResult = this.template.insert(Person.class).inTable("person")
|
||||
.withOptions(InsertOptions.builder().withIfNotExists().build()).one(han);
|
||||
|
||||
assertThat(insertResult.wasApplied()).isFalse();
|
||||
assertThat(template.selectOneById(han.id, Person.class)).isEqualTo(han);
|
||||
|
||||
@@ -82,19 +82,19 @@ public class ExecutableSelectOperationSupportIntegrationTests extends AbstractKe
|
||||
template.insert(luke);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void domainTypeIsRequired() {
|
||||
this.template.query(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void returnTypeIsRequiredOnSet() {
|
||||
this.template.query(Person.class).as(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(Person.class).as(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void tableIsRequiredOnSet() {
|
||||
this.template.query(Person.class).inTable((String) null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(Person.class).inTable((String) null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
|
||||
@@ -15,15 +15,15 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.where;
|
||||
import static org.springframework.data.cassandra.core.query.Query.query;
|
||||
import static org.springframework.data.cassandra.core.query.Update.update;
|
||||
|
||||
import java.util.Collections;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
import static org.springframework.data.cassandra.core.query.Query.*;
|
||||
import static org.springframework.data.cassandra.core.query.Update.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -67,27 +67,26 @@ public class ExecutableUpdateOperationSupportIntegrationTests extends AbstractKe
|
||||
template.insert(luke);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void domainTypeIsRequired() {
|
||||
this.template.update(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.update(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void queryIsRequired() {
|
||||
this.template.update(Person.class).matching(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.update(Person.class).matching(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void tableIsRequiredOnSet() {
|
||||
this.template.update(Person.class).inTable((CqlIdentifier) null);
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.template.update(Person.class).inTable((CqlIdentifier) null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
public void updateAllMatching() {
|
||||
|
||||
WriteResult updateResult = this.template
|
||||
.update(Person.class)
|
||||
.matching(queryHan())
|
||||
WriteResult updateResult = this.template.update(Person.class).matching(queryHan())
|
||||
.apply(update("firstname", "Han"));
|
||||
|
||||
assertThat(updateResult).isNotNull();
|
||||
@@ -98,16 +97,13 @@ public class ExecutableUpdateOperationSupportIntegrationTests extends AbstractKe
|
||||
@Test // DATACASS-485
|
||||
public void updateWithDifferentDomainClassAndCollection() {
|
||||
|
||||
WriteResult updateResult = this.template
|
||||
.update(Jedi.class)
|
||||
.inTable("person")
|
||||
.matching(query(where("id").is(han.getId())))
|
||||
.apply(update("name", "Han"));
|
||||
WriteResult updateResult = this.template.update(Jedi.class).inTable("person")
|
||||
.matching(query(where("id").is(han.getId()))).apply(update("name", "Han"));
|
||||
|
||||
assertThat(updateResult).isNotNull();
|
||||
assertThat(updateResult.wasApplied()).isTrue();
|
||||
assertThat(this.template.selectOne(queryHan(), Person.class))
|
||||
.isNotEqualTo(han).hasFieldOrPropertyWithValue("firstname", "Han");
|
||||
assertThat(this.template.selectOne(queryHan(), Person.class)).isNotEqualTo(han)
|
||||
.hasFieldOrPropertyWithValue("firstname", "Han");
|
||||
}
|
||||
|
||||
private Query queryHan() {
|
||||
|
||||
@@ -73,19 +73,19 @@ public class ReactiveInsertOperationSupportIntegrationTests extends AbstractKeys
|
||||
luke.id = "id-2";
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void domainTypeIsRequired() {
|
||||
this.template.insert((Class) null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert((Class) null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void optionsIsRequiredOnSet() {
|
||||
this.template.insert(Person.class).withOptions(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert(Person.class).withOptions(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void tableIsRequiredOnSet() {
|
||||
this.template.insert(Person.class).inTable((String) null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.insert(Person.class).inTable((String) null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-485, DATACASS-573
|
||||
|
||||
@@ -84,19 +84,19 @@ public class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeys
|
||||
admin.insert(luke);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void domainTypeIsRequired() {
|
||||
this.template.query(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void returnTypeIsRequiredOnSet() {
|
||||
this.template.query(Person.class).as(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(Person.class).as(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void tableIsRequiredOnSet() {
|
||||
this.template.query(Person.class).inTable((String) null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.query(Person.class).inTable((String) null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
|
||||
@@ -15,18 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.where;
|
||||
import static org.springframework.data.cassandra.core.query.Query.query;
|
||||
import static org.springframework.data.cassandra.core.query.Update.update;
|
||||
|
||||
import java.util.Collections;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
import static org.springframework.data.cassandra.core.query.Query.*;
|
||||
import static org.springframework.data.cassandra.core.query.Update.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -75,27 +74,26 @@ public class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeys
|
||||
admin.insert(luke);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void domainTypeIsRequired() {
|
||||
this.template.update(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.update(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void queryIsRequired() {
|
||||
this.template.update(Person.class).matching(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.template.update(Person.class).matching(null));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-485
|
||||
@Test // DATACASS-485
|
||||
public void tableIsRequiredOnSet() {
|
||||
this.template.update(Person.class).inTable((CqlIdentifier) null);
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.template.update(Person.class).inTable((CqlIdentifier) null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
public void updateAllMatching() {
|
||||
|
||||
Mono<WriteResult> writeResult = this.template
|
||||
.update(Person.class)
|
||||
.matching(queryHan())
|
||||
Mono<WriteResult> writeResult = this.template.update(Person.class).matching(queryHan())
|
||||
.apply(update("firstname", "Han"));
|
||||
|
||||
writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
@@ -104,15 +102,13 @@ public class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeys
|
||||
@Test // DATACASS-485
|
||||
public void updateWithDifferentDomainClassAndCollection() {
|
||||
|
||||
Mono<WriteResult> writeResult = this.template
|
||||
.update(Jedi.class).inTable("person")
|
||||
.matching(query(where("id").is(han.getId())))
|
||||
.apply(update("name", "Han"));
|
||||
Mono<WriteResult> writeResult = this.template.update(Jedi.class).inTable("person")
|
||||
.matching(query(where("id").is(han.getId()))).apply(update("name", "Han"));
|
||||
|
||||
writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
|
||||
assertThat(this.admin.selectOne(queryHan(), Person.class))
|
||||
.isNotEqualTo(han).hasFieldOrPropertyWithValue("firstname", "Han");
|
||||
assertThat(this.admin.selectOne(queryHan(), Person.class)).isNotEqualTo(han)
|
||||
.hasFieldOrPropertyWithValue("firstname", "Han");
|
||||
}
|
||||
|
||||
private Query queryHan() {
|
||||
|
||||
@@ -29,12 +29,11 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.data.annotation.ReadOnlyProperty;
|
||||
import org.springframework.data.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
@@ -58,7 +57,6 @@ import com.datastax.driver.core.querybuilder.QueryBuilder;
|
||||
@RunWith(MockitoJUnitRunner.Silent.class) // there are some unused stubbings in RowMockUtil but they're used in other
|
||||
public class MappingCassandraConverterUDTUnitTests {
|
||||
|
||||
@Rule public final ExpectedException expectedException = ExpectedException.none();
|
||||
@Mock UserTypeResolver userTypeResolver;
|
||||
|
||||
UserType manufacturer = UserTypeBuilder.forName("manufacturer").withField("name", DataType.varchar())
|
||||
|
||||
@@ -44,9 +44,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.ReadOnlyProperty;
|
||||
@@ -92,15 +90,13 @@ import com.datastax.driver.core.querybuilder.Update.Assignments;
|
||||
*/
|
||||
public class MappingCassandraConverterUnitTests {
|
||||
|
||||
@Rule public final ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
Row rowMock;
|
||||
|
||||
CassandraMappingContext mappingContext;
|
||||
MappingCassandraConverter mappingCassandraConverter;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
|
||||
this.mappingContext = new CassandraMappingContext();
|
||||
|
||||
|
||||
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.convert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -26,7 +28,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.LocalTime;
|
||||
import org.junit.Before;
|
||||
@@ -34,6 +35,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.cassandra.core.cql.CqlIdentifier;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
@@ -340,8 +342,8 @@ public class QueryMapperUnitTests {
|
||||
Filter mappedObject = this.queryMapper.getMappedObject(filter,
|
||||
this.mappingContext.getRequiredPersistentEntity(Person.class));
|
||||
|
||||
TupleValue tupleValue = this.mappingContext.getRequiredPersistentEntity(MappedTuple.class)
|
||||
.getTupleType().newValue();
|
||||
TupleValue tupleValue = this.mappingContext.getRequiredPersistentEntity(MappedTuple.class).getTupleType()
|
||||
.newValue();
|
||||
|
||||
tupleValue.setString(0, "foo");
|
||||
|
||||
@@ -359,11 +361,11 @@ public class QueryMapperUnitTests {
|
||||
assertThat(mappedObject).contains(Criteria.where("localdate").gt(1000L));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-523
|
||||
@Test // DATACASS-523
|
||||
public void referencingTupleElementsInQueryShouldFail() {
|
||||
|
||||
this.queryMapper.getMappedObject(Filter.from(Criteria.where("tuple.zip").is("123")),
|
||||
this.mappingContext.getRequiredPersistentEntity(Person.class));
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.queryMapper.getMappedObject(Filter.from(Criteria.where("tuple.zip").is("123")),
|
||||
this.mappingContext.getRequiredPersistentEntity(Person.class)));
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.convert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collections;
|
||||
@@ -25,9 +28,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -242,17 +242,17 @@ public class UpdateMapperUnitTests {
|
||||
@Test // DATACASS-302
|
||||
public void shouldMapTime() {
|
||||
|
||||
Update update = this.updateMapper.getMappedObject(Update.empty()
|
||||
.set("localTime", LocalTime.of(1, 2, 3)),
|
||||
Update update = this.updateMapper.getMappedObject(Update.empty().set("localTime", LocalTime.of(1, 2, 3)),
|
||||
this.persistentEntity);
|
||||
|
||||
assertThat(update.getUpdateOperations()).hasSize(1);
|
||||
assertThat(update.toString()).isEqualTo("localtime = 3723000");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-523
|
||||
@Test // DATACASS-523
|
||||
public void referencingTupleElementsInQueryShouldFail() {
|
||||
this.updateMapper.getMappedObject(Update.empty().set("tuple.zip", "bar"), this.persistentEntity);
|
||||
assertThatIllegalArgumentException().isThrownBy(
|
||||
() -> this.updateMapper.getMappedObject(Update.empty().set("tuple.zip", "bar"), this.persistentEntity));
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.data.cassandra.core.cql;
|
||||
|
||||
import static edu.umd.cs.mtc.TestFramework.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import edu.umd.cs.mtc.MultithreadedTestCase;
|
||||
@@ -54,14 +54,14 @@ public class CachedPreparedStatementCreatorUnitTests {
|
||||
when(sessionMock.prepare(anyString())).thenReturn(preparedStatement);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-253
|
||||
@Test // DATACASS-253
|
||||
public void shouldRejectEmptyCql() {
|
||||
new CachedPreparedStatementCreator("");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new CachedPreparedStatementCreator(""));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-253
|
||||
@Test // DATACASS-253
|
||||
public void shouldRejectNullCql() {
|
||||
new CachedPreparedStatementCreator(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new CachedPreparedStatementCreator(null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-253
|
||||
|
||||
@@ -18,9 +18,7 @@ package org.springframework.data.cassandra.core.cql;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
@@ -39,8 +37,6 @@ public class CassandraAccessorUnitTests {
|
||||
|
||||
private CassandraAccessor cassandraAccessor;
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Mock private CassandraExceptionTranslator mockExceptionTranslator;
|
||||
@Mock private Session mockSession;
|
||||
|
||||
|
||||
@@ -19,9 +19,7 @@ import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
@@ -47,8 +45,6 @@ import com.datastax.driver.core.querybuilder.Using;
|
||||
@SuppressWarnings("unchecked")
|
||||
public class QueryOptionsUtilUnitTests {
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Mock Insert mockInsert;
|
||||
@Mock PreparedStatement mockPreparedStatement;
|
||||
@Mock Session mockSession;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.cql.generator;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.springframework.data.cassandra.core.cql.generator.AlterUserTypeCqlGenerator.*;
|
||||
|
||||
@@ -86,13 +87,13 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
|
||||
session.execute(toCql(spec));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-172
|
||||
@Test // DATACASS-172
|
||||
public void generationFailsIfNameIsNotSet() {
|
||||
toCql(AlterUserTypeSpecification.alterType(null));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> toCql(AlterUserTypeSpecification.alterType(null)));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-172
|
||||
@Test // DATACASS-172
|
||||
public void generationFailsWithoutFields() {
|
||||
toCql(AlterUserTypeSpecification.alterType("hello"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> toCql(AlterUserTypeSpecification.alterType("hello")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ public class AlterUserTypeCqlGeneratorUnitTests {
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-172
|
||||
@Test // DATACASS-172
|
||||
public void generationFailsWithoutFields() {
|
||||
toCql(AlterUserTypeSpecification.alterType("hello"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> toCql(AlterUserTypeSpecification.alterType("hello")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ public class CreateUserTypeCqlGeneratorUnitTests {
|
||||
assertThat(toCql(spec)).isEqualTo("CREATE TYPE IF NOT EXISTS address (zip ascii, city varchar);");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-172
|
||||
@Test // DATACASS-172
|
||||
public void generationFailsWithoutFields() {
|
||||
toCql(CreateUserTypeSpecification.createType("hello"));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> toCql(CreateUserTypeSpecification.createType("hello")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ import org.junit.Test;
|
||||
*/
|
||||
public class OptionUnitTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testOptionWithNullName() {
|
||||
new DefaultOption(null, Object.class, true, true, true);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultOption(null, Object.class, true, true, true));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testOptionWithEmptyName() {
|
||||
new DefaultOption("", Object.class, true, true, true);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultOption("", Object.class, true, true, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -39,9 +39,9 @@ public class BeanFactorySessionFactoryLookupUnitTests {
|
||||
@Mock BeanFactory beanFactory;
|
||||
@Mock SessionFactory sessionFactory;
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-330
|
||||
@Test // DATACASS-330
|
||||
public void shouldRejectNullBeanFactory() {
|
||||
new BeanFactorySessionFactoryLookup(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new BeanFactorySessionFactoryLookup(null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-330
|
||||
|
||||
@@ -29,9 +29,9 @@ import org.springframework.data.cassandra.core.cql.session.lookup.SingleSessionF
|
||||
*/
|
||||
public class SingleSessionFactoryLookupUnitTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-330
|
||||
@Test // DATACASS-330
|
||||
public void shouldRejectNullSessionFactory() {
|
||||
new SingleSessionFactoryLookup(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new SingleSessionFactoryLookup(null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-330
|
||||
|
||||
@@ -67,9 +67,9 @@ public class AuditingEntityCallbackUnitTests {
|
||||
callback = new AuditingEntityCallback(() -> handler);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-4
|
||||
@Test // DATACASS-4
|
||||
public void rejectsNullAuditingHandler() {
|
||||
new AuditingEntityCallback(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new AuditingEntityCallback(null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-4
|
||||
|
||||
@@ -67,9 +67,9 @@ public class ReactiveAuditingEntityCallbackUnitTests {
|
||||
callback = new ReactiveAuditingEntityCallback(() -> handler);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-4
|
||||
@Test // DATACASS-4
|
||||
public void rejectsNullAuditingHandler() {
|
||||
new AuditingEntityCallback(null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> new AuditingEntityCallback(null));
|
||||
}
|
||||
|
||||
@Test // DATACASS-4
|
||||
|
||||
@@ -26,9 +26,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.annotation.Id;
|
||||
@@ -63,8 +61,6 @@ public class CassandraQueryCreatorUnitTests {
|
||||
CassandraMappingContext context;
|
||||
CassandraConverter converter;
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
@@ -288,9 +284,10 @@ public class CassandraQueryCreatorUnitTests {
|
||||
assertThat(query).isEqualTo("SELECT * FROM key WHERE firstname='Walter';");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACASS-7
|
||||
@Test // DATACASS-7
|
||||
public void createsFindByPrimaryKey2PartCorrectly() {
|
||||
createQuery("findByKey", TypeWithCompositeId.class, new Key());
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> createQuery("findByKey", TypeWithCompositeId.class, new Key()));
|
||||
}
|
||||
|
||||
private String createQuery(String source, Class<?> entityClass, Object... values) {
|
||||
|
||||
@@ -24,9 +24,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
@@ -63,8 +61,6 @@ import com.datastax.driver.core.UserType;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PartTreeCassandraQueryUnitTests {
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Mock CassandraOperations mockCassandraOperations;
|
||||
@Mock UserTypeResolver userTypeResolverMock;
|
||||
@Mock UserType userTypeMock;
|
||||
|
||||
@@ -26,12 +26,11 @@ import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
import org.springframework.data.cassandra.core.convert.MappingCassandraConverter;
|
||||
import org.springframework.data.cassandra.core.cql.QueryOptions;
|
||||
@@ -57,8 +56,6 @@ import com.datastax.driver.core.Statement;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ReactivePartTreeCassandraQueryUnitTests {
|
||||
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Mock ReactiveCassandraOperations mockCassandraOperations;
|
||||
@Mock UserTypeResolver userTypeResolver;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user