DATACMNS-1554 - Polishing.

Replace AtTest(expected = …) and ExpectedException with the corresponding AssertJ assertThatExceptionOfType(…) and assertThatIllegalArgumentException().isThrownBy(…).
This commit is contained in:
Mark Paluch
2019-07-10 11:47:46 +02:00
parent 660006b8c9
commit 704913c866
79 changed files with 457 additions and 474 deletions

View File

@@ -19,9 +19,8 @@ import static org.assertj.core.api.Assertions.*;
import java.lang.reflect.Field;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.util.ReflectionUtils;
@@ -39,8 +38,6 @@ public class AnnotationAuditingMetadataUnitTests {
static final Field lastModifiedByField = ReflectionUtils.findField(AnnotatedUser.class, "lastModifiedBy");
static final Field lastModifiedDateField = ReflectionUtils.findField(AnnotatedUser.class, "lastModifiedDate");
@Rule public ExpectedException exception = ExpectedException.none();
@Test
public void checkAnnotationDiscovery() {
@@ -82,11 +79,8 @@ public class AnnotationAuditingMetadataUnitTests {
@CreatedDate String field;
}
exception.expect(IllegalStateException.class);
exception.expectMessage(String.class.getName());
exception.expectMessage("field");
AnnotationAuditingMetadata.getMetadata(Sample.class);
assertThatIllegalStateException().isThrownBy(() -> AnnotationAuditingMetadata.getMetadata(Sample.class))
.withMessageContaining("field").withMessageContaining("String");
}
@SuppressWarnings("unused")

View File

@@ -26,6 +26,7 @@ import java.time.temporal.TemporalAccessor;
import java.util.Optional;
import org.junit.Test;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.auditing.DefaultAuditableBeanWrapperFactory.AuditableInterfaceBeanWrapper;
@@ -43,9 +44,9 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
DefaultAuditableBeanWrapperFactory factory = new DefaultAuditableBeanWrapperFactory();
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullSource() {
factory.getBeanWrapperFor(null);
assertThatIllegalArgumentException().isThrownBy(() -> factory.getBeanWrapperFor(null));
}
@Test
@@ -85,7 +86,7 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
});
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-867
@Test // DATACMNS-867
public void errorsWhenUnableToConvertDateViaIntermediateJavaUtilDateConversion() {
Jsr310ThreeTenBpAuditedUser user = new Jsr310ThreeTenBpAuditedUser();
@@ -93,7 +94,10 @@ public class DefaultAuditableBeanWrapperFactoryUnitTests {
Optional<AuditableBeanWrapper<Jsr310ThreeTenBpAuditedUser>> wrapper = factory.getBeanWrapperFor(user);
assertThat(wrapper).hasValueSatisfying(it -> it.setLastModifiedDate(zonedDateTime));
assertThat(wrapper).isNotEmpty();
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> wrapper.ifPresent(it -> it.setLastModifiedDate(zonedDateTime)));
}
@Test // DATACMNS-1259

View File

@@ -23,6 +23,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.annotation.Id;
import org.springframework.data.mapping.context.PersistentEntities;
import org.springframework.data.mapping.context.SampleMappingContext;
@@ -74,9 +75,9 @@ public class IsNewAwareAuditingHandlerUnitTests extends AuditingHandlerUnitTests
assertThat(user.modifiedDate).isNotNull();
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-365
@Test // DATACMNS-365
public void rejectsNullMappingContext() {
new IsNewAwareAuditingHandler((PersistentEntities) null);
assertThatIllegalArgumentException().isThrownBy(() -> new IsNewAwareAuditingHandler((PersistentEntities) null));
}
@Test // DATACMNS-365

View File

@@ -86,13 +86,14 @@ public class ClassGeneratingEntityInstantiatorUnitTests<P extends PersistentProp
.satisfies(it -> verify(provider, times(1)).getParameterValue(it.getParameters().iterator().next()));
}
@Test(expected = MappingInstantiationException.class) // DATACMNS-300, DATACMNS-578
@Test // DATACMNS-300, DATACMNS-578
@SuppressWarnings({ "unchecked", "rawtypes" })
public void throwsExceptionOnBeanInstantiationException() {
doReturn(PersistentEntity.class).when(entity).getType();
this.instance.createInstance(entity, provider);
assertThatExceptionOfType(MappingInstantiationException.class)
.isThrownBy(() -> this.instance.createInstance(entity, provider));
}
@Test // DATACMNS-134, DATACMNS-578

View File

@@ -45,19 +45,19 @@ public class ConfigurableTypeInformationMapperUnitTests<T extends PersistentProp
mapper = new ConfigurableTypeInformationMapper(Collections.singletonMap(String.class, "1"));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullTypeMap() {
new ConfigurableTypeInformationMapper(null);
assertThatIllegalArgumentException().isThrownBy(() -> new ConfigurableTypeInformationMapper(null));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNonBijectionalMap() {
Map<Class<?>, String> map = new HashMap<>();
map.put(String.class, "1");
map.put(Object.class, "1");
new ConfigurableTypeInformationMapper(map);
assertThatIllegalArgumentException().isThrownBy(() -> new ConfigurableTypeInformationMapper(map));
}
@Test

View File

@@ -38,9 +38,9 @@ public class EntityInstantiatorsUnitTests {
@Mock PersistentEntity<?, ?> entity;
@Mock EntityInstantiator customInstantiator;
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullFallbackInstantiator() {
new EntityInstantiators((EntityInstantiator) null);
assertThatIllegalArgumentException().isThrownBy(() -> new EntityInstantiators((EntityInstantiator) null));
}
@Test

View File

@@ -45,9 +45,9 @@ public class MappingContextTypeInformationMapperUnitTests {
mappingContext = new SampleMappingContext();
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullMappingContext() {
new MappingContextTypeInformationMapper(null);
assertThatIllegalArgumentException().isThrownBy(() -> new MappingContextTypeInformationMapper(null));
}
@Test

View File

@@ -80,13 +80,14 @@ public class ReflectionEntityInstantiatorUnitTests<P extends PersistentProperty<
.satisfies(it -> verify(provider, times(1)).getParameterValue(it.getParameters().iterator().next()));
}
@Test(expected = MappingInstantiationException.class) // DATACMNS-300
@Test // DATACMNS-300
@SuppressWarnings({ "unchecked", "rawtypes" })
public void throwsExceptionOnBeanInstantiationException() {
doReturn(PersistentEntity.class).when(entity).getType();
INSTANCE.createInstance(entity, provider);
assertThatExceptionOfType(MappingInstantiationException.class)
.isThrownBy(() -> INSTANCE.createInstance(entity, provider));
}
@Test // DATACMNS-134

View File

@@ -28,14 +28,14 @@ public abstract class AbstractPageRequestUnitTests {
public abstract AbstractPageRequest newPageRequest(int page, int size);
@Test(expected = IllegalArgumentException.class) // DATACMNS-402
@Test // DATACMNS-402
public void preventsNegativePage() {
newPageRequest(-1, 10);
assertThatIllegalArgumentException().isThrownBy(() -> newPageRequest(-1, 10));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-402
@Test // DATACMNS-402
public void preventsNegativeSize() {
newPageRequest(0, -1);
assertThatIllegalArgumentException().isThrownBy(() -> newPageRequest(0, -1));
}
@Test // DATACMNS-402
@@ -72,9 +72,9 @@ public abstract class AbstractPageRequestUnitTests {
assertNotEqualsAndHashcode(request, newPageRequest(0, 11));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-377
@Test // DATACMNS-377
public void preventsPageSizeLessThanOne() {
newPageRequest(0, 0);
assertThatIllegalArgumentException().isThrownBy(() -> newPageRequest(0, 0));
}
@Test // DATACMNS-1327

View File

@@ -7,7 +7,7 @@ import org.springframework.data.domain.Sort.Direction;
/**
* Unit test for {@link Direction}.
*
*
* @author Oliver Gierke
*/
public class DirectionUnitTests {
@@ -19,8 +19,8 @@ public class DirectionUnitTests {
assertThat(Direction.fromString("desc")).isEqualTo(Direction.DESC);
}
@Test(expected = IllegalArgumentException.class)
public void rejectsInvalidString() throws Exception {
Direction.fromString("foo");
@Test
public void rejectsInvalidString() {
assertThatIllegalArgumentException().isThrownBy(() -> Direction.fromString("foo"));
}
}

View File

@@ -57,9 +57,10 @@ public class ExampleMatcherUnitTests {
assertThat(matcher.getNullHandler()).isEqualTo(NullHandler.IGNORE);
}
@Test(expected = UnsupportedOperationException.class) // DATACMNS-810
@Test // DATACMNS-810
public void ignoredPathsIsNotModifiable() {
matcher.getIgnoredPaths().add("¯\\_(ツ)_/¯");
assertThatExceptionOfType(UnsupportedOperationException.class)
.isThrownBy(() -> matcher.getIgnoredPaths().add("¯\\_(ツ)_/¯"));
}
@Test // DATACMNS-810

View File

@@ -42,9 +42,9 @@ public class ExampleUnitTests {
example = Example.of(person);
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-810
@Test // DATACMNS-810
public void rejectsNullProbe() {
Example.of(null);
assertThatIllegalArgumentException().isThrownBy(() -> Example.of(null));
}
@Test // DATACMNS-810

View File

@@ -55,14 +55,14 @@ public class PageImplUnitTests {
assertNotEqualsAndHashcode(page, new PageImpl<>(content, PageRequest.of(0, 15), 100));
}
@Test(expected = IllegalArgumentException.class)
public void preventsNullContentForSimpleSetup() throws Exception {
new PageImpl<>(null);
@Test
public void preventsNullContentForSimpleSetup() {
assertThatIllegalArgumentException().isThrownBy(() -> new PageImpl<>(null));
}
@Test(expected = IllegalArgumentException.class)
public void preventsNullContentForAdvancedSetup() throws Exception {
new PageImpl<>(null, null, 0);
@Test
public void preventsNullContentForAdvancedSetup() {
assertThatIllegalArgumentException().isThrownBy(() -> new PageImpl<>(null, null, 0));
}
@Test

View File

@@ -18,6 +18,7 @@ package org.springframework.data.domain;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.springframework.data.domain.Range.Bound;
/**
@@ -29,9 +30,10 @@ import org.springframework.data.domain.Range.Bound;
*/
public class RangeUnitTests {
@Test(expected = IllegalArgumentException.class) // DATACMNS-651
@Test // DATACMNS-651
public void rejectsNullReferenceValuesForContains() {
Range.from(Bound.inclusive(10L)).to(Bound.inclusive(20L)).contains(null);
assertThatIllegalArgumentException()
.isThrownBy(() -> Range.from(Bound.inclusive(10L)).to(Bound.inclusive(20L)).contains(null));
}
@Test // DATACMNS-651

View File

@@ -42,7 +42,7 @@ public class SortUnitTests {
* @throws Exception
*/
@Test
public void appliesDefaultForOrder() throws Exception {
public void appliesDefaultForOrder() {
assertThat(Sort.by("foo").iterator().next().getDirection()).isEqualTo(Sort.DEFAULT_DIRECTION);
}
@@ -51,11 +51,10 @@ public class SortUnitTests {
*
* @throws Exception
*/
@Test
@SuppressWarnings("null")
@Test(expected = IllegalArgumentException.class)
public void preventsNullProperties() throws Exception {
Sort.by(Direction.ASC, (String[]) null);
public void preventsNullProperties() {
assertThatIllegalArgumentException().isThrownBy(() -> Sort.by(Direction.ASC, (String[]) null));
}
/**
@@ -63,10 +62,9 @@ public class SortUnitTests {
*
* @throws Exception
*/
@Test(expected = IllegalArgumentException.class)
public void preventsNullProperty() throws Exception {
Sort.by(Direction.ASC, (String) null);
@Test
public void preventsNullProperty() {
assertThatIllegalArgumentException().isThrownBy(() -> Sort.by(Direction.ASC, (String) null));
}
/**
@@ -74,10 +72,9 @@ public class SortUnitTests {
*
* @throws Exception
*/
@Test(expected = IllegalArgumentException.class)
public void preventsEmptyProperty() throws Exception {
Sort.by(Direction.ASC, "");
@Test
public void preventsEmptyProperty() {
assertThatIllegalArgumentException().isThrownBy(() -> Sort.by(Direction.ASC, ""));
}
/**
@@ -85,10 +82,9 @@ public class SortUnitTests {
*
* @throws Exception
*/
@Test(expected = IllegalArgumentException.class)
public void preventsNoProperties() throws Exception {
Sort.by(Direction.ASC);
@Test
public void preventsNoProperties() {
assertThatIllegalArgumentException().isThrownBy(() -> Sort.by(Direction.ASC));
}
@Test

View File

@@ -28,14 +28,14 @@ import org.springframework.util.SerializationUtils;
*/
public class CircleUnitTests {
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
@Test // DATACMNS-437
public void rejectsNullOrigin() {
new Circle(null, new Distance(0));
assertThatIllegalArgumentException().isThrownBy(() -> new Circle(null, new Distance(0)));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
@Test // DATACMNS-437
public void rejectsNegativeRadius() {
new Circle(1, 1, -1);
assertThatIllegalArgumentException().isThrownBy(() -> new Circle(1, 1, -1));
}
@Test // DATACMNS-437

View File

@@ -50,10 +50,11 @@ public class GeoResultUnitTests {
assertThat(fourth.equals(first)).isFalse();
}
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
// DATACMNS-437
public void rejectsNullContent() {
new GeoResult(null, new Distance(2.5));
assertThatIllegalArgumentException().isThrownBy(() -> new GeoResult(null, new Distance(2.5)));
}
@Test // DATACMNS-482

View File

@@ -28,9 +28,9 @@ import org.springframework.util.SerializationUtils;
*/
public class PointUnitTests {
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
@Test // DATACMNS-437
public void rejectsNullforCopyConstructor() {
new Point(null);
assertThatIllegalArgumentException().isThrownBy(() -> new Point(null));
}
@Test // DATACMNS-437

View File

@@ -32,9 +32,9 @@ public class PolygonUnitTests {
Point second = new Point(2, 2);
Point third = new Point(3, 3);
@Test(expected = IllegalArgumentException.class) // DATACMNS-437
@Test // DATACMNS-437
public void rejectsNullPoints() {
new Polygon(null, null, null);
assertThatIllegalArgumentException().isThrownBy(() -> new Polygon(null, null, null));
}
@Test // DATACMNS-437

View File

@@ -49,14 +49,14 @@ public class DistanceFormatterUnitTests {
public static class UnparameterizedTests {
@Test(expected = IllegalArgumentException.class) // DATAREST-279, DATACMNS-626
@Test // DATAREST-279, DATACMNS-626
public void rejectsArbitraryNonsense() {
INSTANCE.convert("foo");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("foo"));
}
@Test(expected = IllegalArgumentException.class) // DATAREST-279, DATACMNS-626
@Test // DATAREST-279, DATACMNS-626
public void rejectsUnsupportedMetric() {
INSTANCE.convert("10.8cm");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8cm"));
}
@Test // DATAREST-279, DATACMNS-626

View File

@@ -23,14 +23,13 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Locale;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.springframework.data.geo.Point;
/**
@@ -50,25 +49,19 @@ public class PointFormatterUnitTests {
public static class UnparameterizedTests {
public @Rule ExpectedException exception = ExpectedException.none();
@Test // DATAREST-279, DATACMNS-626
public void rejectsArbitraryNonsense() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("comma");
INSTANCE.convert("foo");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("foo")).withMessageContaining("comma");
}
@Test(expected = IllegalArgumentException.class) // DATAREST-279, DATACMNS-626
@Test // DATAREST-279, DATACMNS-626
public void rejectsMoreThanTwoCoordinates() {
INSTANCE.convert("10.8,20.9,30.10");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8,20.9,30.10"));
}
@Test(expected = IllegalArgumentException.class) // DATAREST-279, DATACMNS-626
@Test // DATAREST-279, DATACMNS-626
public void rejectsInvalidCoordinate() {
INSTANCE.convert("10.8,foo");
assertThatIllegalArgumentException().isThrownBy(() -> INSTANCE.convert("10.8,foo"));
}
}

View File

@@ -23,9 +23,8 @@ import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
@@ -34,12 +33,11 @@ import org.springframework.data.util.TypeInformation;
*
* @author Oliver Gierke
* @author Christoph Strobl
* @author Mark Paluch
*/
@SuppressWarnings("unused")
public class PropertyPathUnitTests {
@Rule public ExpectedException exception = ExpectedException.none();
@Test
public void parsesSimplePropertyCorrectly() throws Exception {
@@ -214,16 +212,17 @@ public class PropertyPathUnitTests {
.withMessageContaining("property _id");
}
@Test(expected = PropertyReferenceException.class) // DATACMNS 158
@Test // DATACMNS 158
public void rejectsInvalidPathsContainingDigits() {
PropertyPath.from("PropertyThatWillFail4Sure", Foo.class);
assertThatExceptionOfType(PropertyReferenceException.class)
.isThrownBy(() -> from("PropertyThatWillFail4Sure", Foo.class));
}
@Test
public void rejectsInvalidProperty() {
assertThatExceptionOfType(PropertyReferenceException.class)//
.isThrownBy(() -> PropertyPath.from("_foo_id", Sample2.class))//
.isThrownBy(() -> from("_foo_id", Sample2.class))//
.matches(e -> e.getBaseProperty().getSegment().equals("_foo"));
}
@@ -278,61 +277,54 @@ public class PropertyPathUnitTests {
@Test // DATACMNS-381
public void exposesPreviouslyReferencedPathInExceptionMessage() {
exception.expect(PropertyReferenceException.class);
exception.expectMessage("bar"); // missing variable
exception.expectMessage("String"); // type
exception.expectMessage("Bar.user.name"); // previously referenced path
PropertyPath.from("userNameBar", Bar.class);
assertThatExceptionOfType(PropertyReferenceException.class).isThrownBy(() -> from("userNameBar", Bar.class)) //
.withMessageContaining("bar") // missing variable
.withMessageContaining("String") // type
.withMessageContaining("Bar.user.name"); // previously referenced path
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-387
@Test // DATACMNS-387
public void rejectsNullSource() {
from(null, Foo.class);
assertThatIllegalArgumentException().isThrownBy(() -> from(null, Foo.class));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-387
@Test // DATACMNS-387
public void rejectsEmptySource() {
from("", Foo.class);
assertThatIllegalArgumentException().isThrownBy(() -> from("", Foo.class));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-387
@Test // DATACMNS-387
public void rejectsNullClass() {
from("foo", (Class<?>) null);
assertThatIllegalArgumentException().isThrownBy(() -> from("foo", (Class<?>) null));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-387
@Test // DATACMNS-387
public void rejectsNullTypeInformation() {
from("foo", (TypeInformation<?>) null);
assertThatIllegalArgumentException().isThrownBy(() -> from("foo", (TypeInformation<?>) null));
}
@Test // DATACMNS-546
public void returnsCompletePathIfResolutionFailedCompletely() {
exception.expect(PropertyReferenceException.class);
exception.expectMessage("somethingDifferent");
from("somethingDifferent", Foo.class);
assertThatExceptionOfType(PropertyReferenceException.class) //
.isThrownBy(() -> from("somethingDifferent", Foo.class)).withMessageContaining("somethingDifferent");
}
@Test // DATACMNS-546
public void includesResolvedPathInExceptionMessage() {
exception.expect(PropertyReferenceException.class);
exception.expectMessage("fooName");
exception.expectMessage(FooBar.class.getSimpleName());
exception.expectMessage("Bar.user");
from("userFooName", Bar.class);
assertThatExceptionOfType(PropertyReferenceException.class) //
.isThrownBy(() -> from("userFooName", Bar.class)) //
.withMessageContaining("fooName") // missing variable
.withMessageContaining(FooBar.class.getSimpleName()) // type
.withMessageContaining("Bar.user"); // previously referenced path
}
@Test // DATACMNS-703
public void includesPropertyHintsOnTypos() {
exception.expect(PropertyReferenceException.class);
exception.expectMessage("userName");
from("userAme", Foo.class);
assertThatExceptionOfType(PropertyReferenceException.class) //
.isThrownBy(() -> from("userAme", Foo.class)).withMessageContaining("userName");
}
@Test // DATACMNS-867

View File

@@ -21,9 +21,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
@@ -31,39 +30,32 @@ import org.springframework.data.util.TypeInformation;
* Unit tests for {@link PropertyReferenceException}
*
* @author Oliver Gierke
* @author Mark Paluch
*/
public class PropertyReferenceExceptionUnitTests {
static final TypeInformation<Sample> TYPE_INFO = ClassTypeInformation.from(Sample.class);
static final List<PropertyPath> NO_PATHS = Collections.emptyList();
public @Rule ExpectedException exception = ExpectedException.none();
@Test
public void rejectsNullPropertyName() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("name");
new PropertyReferenceException(null, TYPE_INFO, NO_PATHS);
assertThatIllegalArgumentException().isThrownBy(() -> new PropertyReferenceException(null, TYPE_INFO, NO_PATHS))
.withMessageContaining("name");
}
@Test
public void rejectsNullType() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Type");
new PropertyReferenceException("nme", null, NO_PATHS);
assertThatIllegalArgumentException().isThrownBy(() -> new PropertyReferenceException("nme", null, NO_PATHS))
.withMessageContaining("Type");
}
@Test
public void rejectsNullPaths() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("paths");
new PropertyReferenceException("nme", TYPE_INFO, null);
assertThatIllegalArgumentException().isThrownBy(() -> new PropertyReferenceException("nme", TYPE_INFO, null))
.withMessageContaining("paths");
}
@Test // DATACMNS-801

View File

@@ -24,6 +24,7 @@ import java.util.HashSet;
import java.util.UUID;
import org.junit.Test;
import org.springframework.data.mapping.model.SimpleTypeHolder;
/**
@@ -34,20 +35,22 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
*/
public class SimpleTypeHolderUnitTests {
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullCustomTypes() {
new SimpleTypeHolder(null, false);
assertThatIllegalArgumentException().isThrownBy(() -> new SimpleTypeHolder(null, false));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullOriginal() {
new SimpleTypeHolder(new HashSet<>(), null);
assertThatIllegalArgumentException().isThrownBy(() -> new SimpleTypeHolder(new HashSet<>(), null));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-31
@Test // DATACMNS-31
public void rejectsNullTypeForIsSimpleTypeCall() {
SimpleTypeHolder holder = SimpleTypeHolder.DEFAULT;
holder.isSimpleType(null);
assertThatIllegalArgumentException().isThrownBy(() -> holder.isSimpleType(null));
}
@Test

View File

@@ -28,7 +28,7 @@ import java.util.TreeMap;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.data.annotation.Id;
@@ -57,7 +57,7 @@ public class AbstractMappingContextUnitTests {
context.setSimpleTypeHolder(new SimpleTypeHolder(Collections.singleton(LocalDateTime.class), true));
}
@Test(expected = MappingException.class) // DATACMNS-92
@Test // DATACMNS-92
public void doesNotAddInvalidEntity() {
context = new SampleMappingContext() {
@@ -82,7 +82,7 @@ public class AbstractMappingContextUnitTests {
// expected
}
context.getPersistentEntity(Unsupported.class);
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> context.getPersistentEntity(Unsupported.class));
}
@Test
@@ -93,10 +93,10 @@ public class AbstractMappingContextUnitTests {
context.setInitialEntitySet(Collections.singleton(Person.class));
context.setApplicationEventPublisher(applicationContext);
verify(applicationContext, times(0)).publishEvent(Mockito.any(ApplicationEvent.class));
verify(applicationContext, times(0)).publishEvent(any(ApplicationEvent.class));
context.afterPropertiesSet();
verify(applicationContext, times(1)).publishEvent(Mockito.any(ApplicationEvent.class));
verify(applicationContext, times(1)).publishEvent(any(ApplicationEvent.class));
}
@Test // DATACMNS-214
@@ -106,14 +106,14 @@ public class AbstractMappingContextUnitTests {
assertThat(context.getPersistentEntity(String.class)).isNull();
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-214
@Test // DATACMNS-214
public void rejectsNullValueForGetPersistentEntityOfClass() {
context.getPersistentEntity((Class<?>) null);
assertThatIllegalArgumentException().isThrownBy(() -> context.getPersistentEntity((Class<?>) null));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-214
@Test // DATACMNS-214
public void rejectsNullValueForGetPersistentEntityOfTypeInformation() {
context.getPersistentEntity((TypeInformation<?>) null);
assertThatIllegalArgumentException().isThrownBy(() -> context.getPersistentEntity((TypeInformation<?>) null));
}
@Test // DATACMNS-228

View File

@@ -52,9 +52,9 @@ public class DefaultPersistentPropertyPathUnitTests<P extends PersistentProperty
twoLegs = new DefaultPersistentPropertyPath<>(Arrays.asList(first, second));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullProperties() {
new DefaultPersistentPropertyPath<>(null);
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultPersistentPropertyPath<>(null));
}
@Test

View File

@@ -40,9 +40,9 @@ public class PersistentEntitiesUnitTests {
@Mock SampleMappingContext first;
@Mock SampleMappingContext second;
@Test(expected = IllegalArgumentException.class) // DATACMNS-458
@Test // DATACMNS-458
public void rejectsNullMappingContexts() {
new PersistentEntities(null);
assertThatIllegalArgumentException().isThrownBy(() -> new PersistentEntities(null));
}
@Test // DATACMNS-458

View File

@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
/**
* Unit tests for {@link PersistentPropertyPathFactory}.
*
*
* @author Oliver Gierke
* @soundtrack Cypress Hill - Illusions (Q-Tip Remix, Unreleased & Revamped)
*/
@@ -57,9 +57,9 @@ public class PersistentPropertyPathFactoryUnitTests {
assertThat(path.getLeafProperty().getName()).isEqualTo("name");
}
@Test(expected = MappingException.class) // DATACMNS-380
@Test // DATACMNS-380
public void rejectsInvalidPropertyReferenceWithMappingException() {
factory.from(PersonSample.class, "foo");
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> factory.from(PersonSample.class, "foo"));
}
@Test // DATACMNS-695

View File

@@ -28,9 +28,9 @@ import org.springframework.data.mapping.context.AbstractMappingContext.Persisten
*/
public class PropertyMatchUnitTests {
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsBothParametersBeingNull() {
new PropertyMatch(null, null);
assertThatIllegalArgumentException().isThrownBy(() -> new PropertyMatch(null, null));
}
@Test

View File

@@ -30,9 +30,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Stream;
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;
@@ -73,8 +71,6 @@ import org.springframework.test.util.ReflectionTestUtils;
@RunWith(MockitoJUnitRunner.class)
public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
@Rule public ExpectedException exception = ExpectedException.none();
@Mock T property, anotherProperty;
@Test
@@ -82,14 +78,14 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
PersistentEntitySpec.assertInvariants(createEntity(Person.class));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullTypeInformation() {
new BasicPersistentEntity<Object, T>(null);
assertThatIllegalArgumentException().isThrownBy(() -> new BasicPersistentEntity<Object, T>(null));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullProperty() {
createEntity(Person.class, null).addPersistentProperty(null);
assertThatIllegalArgumentException().isThrownBy(() -> createEntity(Person.class, null).addPersistentProperty(null));
}
@Test
@@ -160,8 +156,7 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
when(anotherProperty.getName()).thenReturn("another");
entity.addPersistentProperty(property);
exception.expect(MappingException.class);
entity.addPersistentProperty(anotherProperty);
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> entity.addPersistentProperty(anotherProperty));
}
@Test // DATACMNS-365
@@ -205,22 +200,22 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
assertThat(accessor.getBean()).isEqualTo(value);
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-596
@Test // DATACMNS-596
public void rejectsNullBeanForPropertyAccessor() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
entity.getPropertyAccessor(null);
assertThatIllegalArgumentException().isThrownBy(() -> entity.getPropertyAccessor(null));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-596
@Test // DATACMNS-596
public void rejectsNonMatchingBeanForPropertyAccessor() {
SampleMappingContext context = new SampleMappingContext();
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
entity.getPropertyAccessor("foo");
assertThatIllegalArgumentException().isThrownBy(() -> entity.getPropertyAccessor("foo"));
}
@Test // DATACMNS-597
@@ -245,10 +240,8 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
PersistentEntity<Entity, T> entity = createEntity(Entity.class);
exception.expectMessage(Entity.class.getName());
exception.expectMessage(Object.class.getName());
entity.getPropertyAccessor(new Object());
assertThatThrownBy(() -> entity.getPropertyAccessor(new Object())).hasMessageContaining(Entity.class.getName())
.hasMessageContaining(Object.class.getName());
}
@Test // DATACMNS-934, DATACMNS-867

View File

@@ -139,9 +139,10 @@ public class ClassGeneratingPropertyAccessorFactoryTests {
assertThat(declaredConstructors[0].getParameterTypes()[0]).isEqualTo(expectedConstructorType);
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-809
@Test // DATACMNS-809
public void shouldFailOnNullBean() {
factory.getPropertyAccessor(mappingContext.getRequiredPersistentEntity(bean.getClass()), null);
assertThatIllegalArgumentException().isThrownBy(
() -> factory.getPropertyAccessor(mappingContext.getRequiredPersistentEntity(bean.getClass()), null));
}
@Test // DATACMNS-809

View File

@@ -35,14 +35,15 @@ public class ConvertingPropertyAccessorUnitTests {
static final ConversionService CONVERSION_SERVICE = new DefaultFormattingConversionService();
@Test(expected = IllegalArgumentException.class) // DATACMNS-596
@Test // DATACMNS-596
public void rejectsNullPropertyAccessorDelegate() {
new ConvertingPropertyAccessor(null, CONVERSION_SERVICE);
assertThatIllegalArgumentException().isThrownBy(() -> new ConvertingPropertyAccessor(null, CONVERSION_SERVICE));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-596
@Test // DATACMNS-596
public void rejectsNullConversionService() {
new ConvertingPropertyAccessor(new BeanWrapper<>(new Object()), null);
assertThatIllegalArgumentException()
.isThrownBy(() -> new ConvertingPropertyAccessor(new BeanWrapper<>(new Object()), null));
}
@Test // DATACMNS-596

View File

@@ -30,16 +30,16 @@ public class IdPropertyIdentifierAccessorUnitTests {
SampleMappingContext mappingContext = new SampleMappingContext();
@Test(expected = IllegalArgumentException.class) // DATACMNS-599
@Test // DATACMNS-599
public void rejectsEntityWithoutIdentifierProperty() {
new IdPropertyIdentifierAccessor(mappingContext.getRequiredPersistentEntity(Sample.class), new Sample());
assertThatIllegalArgumentException().isThrownBy(
() -> new IdPropertyIdentifierAccessor(mappingContext.getRequiredPersistentEntity(Sample.class), new Sample()));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-599
@Test // DATACMNS-599
public void rejectsNullBean() {
new IdPropertyIdentifierAccessor(mappingContext.getRequiredPersistentEntity(SampleWithId.class), null);
assertThatIllegalArgumentException().isThrownBy(
() -> new IdPropertyIdentifierAccessor(mappingContext.getRequiredPersistentEntity(SampleWithId.class), null));
}
@Test // DATACMNS-599

View File

@@ -38,9 +38,9 @@ public class MapAccessingMethodInterceptorUnitTests {
@Mock MethodInvocation invocation;
@Test(expected = IllegalArgumentException.class) // DATACMNS-630
@Test // DATACMNS-630
public void rejectsNullMap() {
new MapAccessingMethodInterceptor(null);
assertThatIllegalArgumentException().isThrownBy(() -> new MapAccessingMethodInterceptor(null));
}
@Test // DATACMNS-630
@@ -94,11 +94,12 @@ public class MapAccessingMethodInterceptorUnitTests {
assertThat(new MapAccessingMethodInterceptor(map).invoke(invocation)).isNull();
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-630
@Test // DATACMNS-630
public void rejectsNonAccessorInvocation() throws Throwable {
when(invocation.getMethod()).thenReturn(Sample.class.getMethod("someMethod"));
new MapAccessingMethodInterceptor(Collections.emptyMap()).invoke(invocation);
assertThatIllegalArgumentException()
.isThrownBy(() -> new MapAccessingMethodInterceptor(Collections.emptyMap()).invoke(invocation));
}
interface Sample {

View File

@@ -50,11 +50,12 @@ public class PropertyAccessingMethodInterceptorUnitTests {
assertThat(interceptor.invoke(invocation)).isEqualTo("Dave");
}
@Test(expected = NotReadablePropertyException.class) // DATAREST-221
@Test // DATAREST-221
public void throwsAppropriateExceptionIfThePropertyCannotBeFound() throws Throwable {
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("getLastname"));
new PropertyAccessingMethodInterceptor(new Source()).invoke(invocation);
assertThatExceptionOfType(NotReadablePropertyException.class)
.isThrownBy(() -> new PropertyAccessingMethodInterceptor(new Source()).invoke(invocation));
}
@Test // DATAREST-221
@@ -65,12 +66,13 @@ public class PropertyAccessingMethodInterceptorUnitTests {
new PropertyAccessingMethodInterceptor(new Source()).invoke(invocation);
}
@Test(expected = IllegalStateException.class) // DATACMNS-630
@Test // DATACMNS-630
public void rejectsNonAccessorMethod() throws Throwable {
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("someGarbage"));
new PropertyAccessingMethodInterceptor(new Source()).invoke(invocation);
assertThatIllegalStateException()
.isThrownBy(() -> new PropertyAccessingMethodInterceptor(new Source()).invoke(invocation));
}
@Test // DATACMNS-820
@@ -87,7 +89,7 @@ public class PropertyAccessingMethodInterceptorUnitTests {
assertThat(source.firstname).isEqualTo("Carl");
}
@Test(expected = IllegalStateException.class) // DATACMNS-820
@Test // DATACMNS-820
public void throwsAppropriateExceptionIfTheInvocationHasNoArguments() throws Throwable {
Source source = new Source();
@@ -95,16 +97,18 @@ public class PropertyAccessingMethodInterceptorUnitTests {
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("setFirstname", String.class));
when(invocation.getArguments()).thenReturn(new Object[0]);
new PropertyAccessingMethodInterceptor(source).invoke(invocation);
assertThatIllegalStateException()
.isThrownBy(() -> new PropertyAccessingMethodInterceptor(source).invoke(invocation));
}
@Test(expected = NotWritablePropertyException.class) // DATACMNS-820
@Test // DATACMNS-820
public void throwsAppropriateExceptionIfThePropertyCannotWritten() throws Throwable {
when(invocation.getMethod()).thenReturn(Projection.class.getMethod("setGarbage", String.class));
when(invocation.getArguments()).thenReturn(new Object[] { "Carl" });
new PropertyAccessingMethodInterceptor(new Source()).invoke(invocation);
assertThatExceptionOfType(NotWritablePropertyException.class)
.isThrownBy(() -> new PropertyAccessingMethodInterceptor(new Source()).invoke(invocation));
}
static class Source {

View File

@@ -39,16 +39,18 @@ public class ProxyProjectionFactoryUnitTests {
ProjectionFactory factory = new ProxyProjectionFactory();
@Test
@SuppressWarnings("null")
@Test(expected = IllegalArgumentException.class) // DATACMNS-630
// DATACMNS-630
public void rejectsNullProjectionType() {
factory.createProjection(null);
assertThatIllegalArgumentException().isThrownBy(() -> factory.createProjection(null));
}
@Test
@SuppressWarnings("null")
@Test(expected = IllegalArgumentException.class) // DATACMNS-630
// DATACMNS-630
public void rejectsNullProjectionTypeWithSource() {
factory.createProjection(null, new Object());
assertThatIllegalArgumentException().isThrownBy(() -> factory.createProjection(null, new Object()));
}
@Test // DATACMNS-630
@@ -82,9 +84,9 @@ public class ProxyProjectionFactoryUnitTests {
assertThat(((TargetClassAware) proxy).getTargetClass()).isEqualTo(HashMap.class);
}
@Test(expected = IllegalArgumentException.class) // DATAREST-221, DATACMNS-630
@Test // DATAREST-221, DATACMNS-630
public void rejectsNonInterfacesAsProjectionTarget() {
factory.createProjection(Object.class, new Object());
assertThatIllegalArgumentException().isThrownBy(() -> factory.createProjection(Object.class, new Object()));
}
@Test // DATACMNS-630

View File

@@ -21,9 +21,8 @@ import java.beans.PropertyDescriptor;
import java.util.List;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.NotWritablePropertyException;
import org.springframework.beans.factory.annotation.Value;
@@ -36,8 +35,6 @@ import org.springframework.beans.factory.annotation.Value;
*/
public class SpelAwareProxyProjectionFactoryUnitTests {
public @Rule ExpectedException exception = ExpectedException.none();
SpelAwareProxyProjectionFactory factory;
@Before
@@ -97,8 +94,7 @@ public class SpelAwareProxyProjectionFactoryUnitTests {
ProjectionWithNotWriteableProperty projection = factory.createProjection(ProjectionWithNotWriteableProperty.class,
customer);
exception.expect(NotWritablePropertyException.class);
projection.setFirstName("Carl");
assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() -> projection.setFirstName("Carl"));
}
static class Customer {

View File

@@ -83,11 +83,10 @@ public class SpelEvaluatingMethodInterceptorUnitTests {
verify(delegate).invoke(invocation);
}
@Test(expected = IllegalStateException.class) // DATACMNS-630
public void rejectsEmptySpelExpression() throws Throwable {
new SpelEvaluatingMethodInterceptor(delegate, new Target(), new DefaultListableBeanFactory(), parser,
InvalidProjection.class);
@Test // DATACMNS-630
public void rejectsEmptySpelExpression() {
assertThatIllegalStateException().isThrownBy(() -> new SpelEvaluatingMethodInterceptor(delegate, new Target(),
new DefaultListableBeanFactory(), parser, InvalidProjection.class));
}
@Test // DATACMNS-630

View File

@@ -23,6 +23,7 @@ import static org.springframework.data.querydsl.QQSortUnitTests_WrapperToWrapWra
import java.util.List;
import org.junit.Test;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
@@ -41,9 +42,9 @@ import com.querydsl.core.types.dsl.StringPath;
*/
public class QSortUnitTests {
@Test(expected = IllegalArgumentException.class) // DATACMNS-402
@Test // DATACMNS-402
public void shouldThrowIfNullIsGiven() {
new QSort((List<OrderSpecifier<?>>) null);
assertThatIllegalArgumentException().isThrownBy(() -> new QSort((List<OrderSpecifier<?>>) null));
}
@Test // DATACMNS-402

View File

@@ -41,9 +41,10 @@ public class SimpleEntityPathResolverUnitTests {
assertThat(resolver.createPath(NamedUser.class)).isInstanceOf(QSimpleEntityPathResolverUnitTests_NamedUser.class);
}
@Test(expected = IllegalArgumentException.class)
public void rejectsClassWithoutQueryClassConfrmingToTheNamingScheme() throws Exception {
resolver.createPath(QSimpleEntityPathResolverUnitTests_Sample.class);
@Test
public void rejectsClassWithoutQueryClassConfrmingToTheNamingScheme() {
assertThatIllegalArgumentException()
.isThrownBy(() -> resolver.createPath(QSimpleEntityPathResolverUnitTests_Sample.class));
}
@Test // DATACMNS-1235

View File

@@ -21,6 +21,7 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.data.querydsl.QSpecialUser;
import org.springframework.data.querydsl.QUser;
@@ -52,9 +53,9 @@ public class QuerydslBindingsUnitTests {
this.bindings = new QuerydslBindings();
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-669
@Test // DATACMNS-669
public void rejectsNullPath() {
bindings.getBindingForPath(null);
assertThatIllegalArgumentException().isThrownBy(() -> bindings.getBindingForPath(null));
}
@Test // DATACMNS-669
@@ -190,14 +191,14 @@ public class QuerydslBindingsUnitTests {
assertThat(bindings.isPathAvailable("address.city", User.class)).isFalse();
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-787
@Test // DATACMNS-787
public void rejectsNullAlias() {
bindings.bind(QUser.user.address).as(null);
assertThatIllegalArgumentException().isThrownBy(() -> bindings.bind(QUser.user.address).as(null));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-787
@Test // DATACMNS-787
public void rejectsEmptyAlias() {
bindings.bind(QUser.user.address).as("");
assertThatIllegalArgumentException().isThrownBy(() -> bindings.bind(QUser.user.address).as(""));
}
@Test // DATACMNS-787

View File

@@ -63,14 +63,15 @@ public class QuerydslPredicateBuilderUnitTests {
this.values = new LinkedMultiValueMap<>();
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-669
@Test // DATACMNS-669
public void rejectsNullConversionService() {
new QuerydslPredicateBuilder(null, SimpleEntityPathResolver.INSTANCE);
assertThatIllegalArgumentException()
.isThrownBy(() -> new QuerydslPredicateBuilder(null, SimpleEntityPathResolver.INSTANCE));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-669
@Test // DATACMNS-669
public void getPredicateShouldThrowErrorWhenBindingContextIsNull() {
builder.getPredicate(null, values, null);
assertThatIllegalArgumentException().isThrownBy(() -> builder.getPredicate(null, values, null));
}
@Test // DATACMNS-669, DATACMNS-1168

View File

@@ -70,19 +70,22 @@ public class CdiRepositoryBeanUnitTests {
@Mock BeanManager beanManager;
@Mock RepositoryFactorySupport repositoryFactory;
@Test(expected = IllegalArgumentException.class)
@Test
public void voidRejectsNullQualifiers() {
new DummyCdiRepositoryBean<>(null, SampleRepository.class, beanManager);
assertThatIllegalArgumentException()
.isThrownBy(() -> new DummyCdiRepositoryBean<>(null, SampleRepository.class, beanManager));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void voidRejectsNullRepositoryType() {
new DummyCdiRepositoryBean<>(NO_ANNOTATIONS, null, beanManager);
assertThatIllegalArgumentException()
.isThrownBy(() -> new DummyCdiRepositoryBean<>(NO_ANNOTATIONS, null, beanManager));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void voidRejectsNullBeanManager() {
new DummyCdiRepositoryBean<>(NO_ANNOTATIONS, SampleRepository.class, null);
assertThatIllegalArgumentException()
.isThrownBy(() -> new DummyCdiRepositoryBean<>(NO_ANNOTATIONS, SampleRepository.class, null));
}
@Test

View File

@@ -78,9 +78,10 @@ public class RepositoryComponentProviderUnitTests {
assertThat(components).extracting(BeanDefinition::getBeanClassName).contains(nestedRepositoryClassName);
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-1098
@Test // DATACMNS-1098
public void rejectsNullBeanDefinitionRegistry() {
new RepositoryComponentProvider(Collections.emptyList(), null);
assertThatIllegalArgumentException()
.isThrownBy(() -> new RepositoryComponentProvider(Collections.emptyList(), null));
}
@Test // DATACMNS-1098

View File

@@ -41,17 +41,19 @@ public class SelectionSetUnitTests {
assertThat(SelectionSet.of(emptySet()).uniqueResult()).isEmpty();
}
@Test(expected = IllegalStateException.class) // DATACMNS-764
@Test // DATACMNS-764
public void multipleElementsThrowException() {
SelectionSet.of(asList("one", "two")).uniqueResult();
assertThatIllegalStateException().isThrownBy(() -> SelectionSet.of(asList("one", "two")).uniqueResult());
}
@Test(expected = NullPointerException.class) // DATACMNS-764
@Test // DATACMNS-764
public void throwsCustomExceptionWhenConfigured() {
SelectionSet.of(asList("one", "two"), c -> {
throw new NullPointerException();
}).uniqueResult();
assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> {
SelectionSet.of(asList("one", "two"), c -> {
throw new NullPointerException();
}).uniqueResult();
});
}
@Test // DATACMNS-764

View File

@@ -20,6 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.io.Serializable;
import org.junit.Test;
import org.springframework.data.annotation.Id;
import org.springframework.data.repository.core.EntityInformation;
import org.springframework.test.util.ReflectionTestUtils;
@@ -34,9 +35,9 @@ import org.springframework.util.ReflectionUtils;
*/
public class AbstractEntityInformationUnitTests {
@Test(expected = IllegalArgumentException.class)
public void rejectsNullDomainClass() throws Exception {
new DummyEntityInformation<>(null);
@Test
public void rejectsNullDomainClass() {
assertThatIllegalArgumentException().isThrownBy(() -> new DummyEntityInformation<>(null));
}
@Test

View File

@@ -39,24 +39,24 @@ import com.google.common.base.Optional;
*/
public class DefaultRepositoryMetadataUnitTests {
@Test(expected = IllegalArgumentException.class)
@Test
public void preventsNullRepositoryInterface() {
new DefaultRepositoryMetadata(null);
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultRepositoryMetadata(null));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNonInterface() {
new DefaultRepositoryMetadata(Object.class);
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultRepositoryMetadata(Object.class));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNonRepositoryInterface() {
new DefaultRepositoryMetadata(Collection.class);
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultRepositoryMetadata(Collection.class));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-406
@Test // DATACMNS-406
public void rejectsUnparameterizedRepositoryInterface() {
new DefaultRepositoryMetadata(Repository.class);
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultRepositoryMetadata(Repository.class));
}
@Test

View File

@@ -35,6 +35,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.domain.AfterDomainEventPublication;
@@ -58,9 +59,9 @@ public class EventPublishingRepositoryProxyPostProcessorUnitTests {
@Mock ApplicationEventPublisher publisher;
@Mock MethodInvocation invocation;
@Test(expected = IllegalArgumentException.class) // DATACMNS-928
@Test // DATACMNS-928
public void rejectsNullAggregateTypes() {
EventPublishingMethod.of(null);
assertThatIllegalArgumentException().isThrownBy(() -> EventPublishingMethod.of(null));
}
@Test // DATACMNS-928

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.repository.core.support;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.junit.Test;
@@ -37,9 +38,10 @@ public class PersistenceExceptionTranslationRepositoryProxyPostProcessorUnitTest
@Mock ListableBeanFactory beanFactory;
@Mock ProxyFactory proxyFactory;
@Test(expected = IllegalArgumentException.class) // DATACMNS-318
public void rejectsNullBeanFactory() throws Exception {
new PersistenceExceptionTranslationRepositoryProxyPostProcessor(null);
@Test // DATACMNS-318
public void rejectsNullBeanFactory() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new PersistenceExceptionTranslationRepositoryProxyPostProcessor(null));
}
@Test // DATACMNS-318

View File

@@ -266,7 +266,7 @@ public class QueryExecutionResultHandlerUnitTests {
assertThat(mono.block()).isNull();
}
@Test(expected = InvalidDataAccessApiUsageException.class) // DATACMNS-836
@Test // DATACMNS-836
@SuppressWarnings("unchecked")
public void convertsRxJavaCompletableIntoMonoWithException() throws Exception {
@@ -276,8 +276,8 @@ public class QueryExecutionResultHandlerUnitTests {
assertThat(result).isInstanceOf(Mono.class);
Mono mono = (Mono) result;
mono.block();
fail("Missing InvalidDataAccessApiUsageException");
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(mono::block);
}
@Test // DATACMNS-836

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.repository.core.support;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.util.Optional;
@@ -23,6 +24,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
import org.springframework.data.repository.core.RepositoryInformation;
import org.springframework.data.repository.query.QueryLookupStrategy;
@@ -42,13 +44,14 @@ public class QueryExecutorMethodInterceptorUnitTests {
@Mock RepositoryInformation information;
@Mock QueryLookupStrategy strategy;
@Test(expected = IllegalStateException.class)
public void rejectsRepositoryInterfaceWithQueryMethodsIfNoQueryLookupStrategyIsDefined() throws Exception {
@Test
public void rejectsRepositoryInterfaceWithQueryMethodsIfNoQueryLookupStrategyIsDefined() {
when(information.hasQueryMethods()).thenReturn(true);
when(factory.getQueryLookupStrategy(any(), any())).thenReturn(Optional.empty());
factory.new QueryExecutorMethodInterceptor(information, new SpelAwareProxyProjectionFactory());
assertThatIllegalStateException().isThrownBy(
() -> factory.new QueryExecutorMethodInterceptor(information, new SpelAwareProxyProjectionFactory()));
}
@Test

View File

@@ -15,7 +15,7 @@
*/
package org.springframework.data.repository.core.support;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import io.reactivex.Completable;
@@ -26,13 +26,12 @@ import rx.Single;
import java.io.Serializable;
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.reactivestreams.Publisher;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.reactive.ReactiveSortingRepository;
@@ -45,8 +44,6 @@ import org.springframework.data.repository.reactive.ReactiveSortingRepository;
@RunWith(MockitoJUnitRunner.Silent.class)
public class ReactiveWrapperRepositoryFactorySupportUnitTests {
public @Rule ExpectedException exception = ExpectedException.none();
DummyRepositoryFactory factory;
@Mock ReactiveSortingRepository<Object, Serializable> backingRepo;

View File

@@ -18,9 +18,8 @@ package org.springframework.data.repository.core.support;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.core.RepositoryInformation;
@@ -34,8 +33,6 @@ import org.springframework.test.util.ReflectionTestUtils;
*/
public class RepositoryFactoryBeanSupportUnitTests {
public @Rule ExpectedException exception = ExpectedException.none();
@Test // DATACMNS-341
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setsConfiguredClassLoaderOnRepositoryFactory() {

View File

@@ -16,6 +16,7 @@
package org.springframework.data.repository.core.support;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.io.Serializable;
@@ -24,8 +25,8 @@ import java.lang.reflect.Method;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.data.repository.Repository;
@@ -48,14 +49,16 @@ public class TransactionRepositoryProxyPostProcessorUnitTests {
@Mock ProxyFactory proxyFactory;
@Mock RepositoryInformation repositoryInformation;
@Test(expected = IllegalArgumentException.class)
public void rejectsNullBeanFactory() throws Exception {
new TransactionalRepositoryProxyPostProcessor(null, "transactionManager", true);
@Test
public void rejectsNullBeanFactory() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new TransactionalRepositoryProxyPostProcessor(null, "transactionManager", true));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsNullTxManagerName() throws Exception {
new TransactionalRepositoryProxyPostProcessor(beanFactory, null, true);
@Test
public void rejectsNullTxManagerName() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new TransactionalRepositoryProxyPostProcessor(beanFactory, null, true));
}
@Test
@@ -65,7 +68,7 @@ public class TransactionRepositoryProxyPostProcessorUnitTests {
true);
postProcessor.postProcess(proxyFactory, repositoryInformation);
verify(proxyFactory).addAdvice(Mockito.any(TransactionInterceptor.class));
verify(proxyFactory).addAdvice(any(TransactionInterceptor.class));
}
@Test // DATACMNS-464

View File

@@ -25,6 +25,7 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
@@ -57,17 +58,17 @@ public class ParametersUnitTests {
new DefaultParameters(validWithSort);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsInvalidMethodWithParamMissing() throws Exception {
Method method = SampleDao.class.getMethod("invalidParamMissing", String.class, String.class);
new DefaultParameters(method);
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultParameters(method));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsNullMethod() throws Exception {
new DefaultParameters(null);
@Test
public void rejectsNullMethod() {
assertThatIllegalArgumentException().isThrownBy(() -> new DefaultParameters(null));
}
@Test

View File

@@ -51,17 +51,19 @@ public class QueryMethodUnitTests {
RepositoryMetadata metadata = new DefaultRepositoryMetadata(SampleRepository.class);
ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
@Test(expected = IllegalStateException.class) // DATAJPA-59
@Test // DATAJPA-59
public void rejectsPagingMethodWithInvalidReturnType() throws Exception {
Method method = SampleRepository.class.getMethod("pagingMethodWithInvalidReturnType", Pageable.class);
new QueryMethod(method, metadata, factory);
assertThatIllegalStateException().isThrownBy(() -> new QueryMethod(method, metadata, factory));
}
@Test(expected = IllegalArgumentException.class) // DATAJPA-59
@Test // DATAJPA-59
public void rejectsPagingMethodWithoutPageable() throws Exception {
Method method = SampleRepository.class.getMethod("pagingMethodWithoutPageable");
new QueryMethod(method, metadata, factory);
assertThatIllegalArgumentException().isThrownBy(() -> new QueryMethod(method, metadata, factory));
}
@Test // DATACMNS-64

View File

@@ -45,25 +45,25 @@ public class SimpleParameterAccessorUnitTests {
new ParametersParameterAccessor(parameters, new Object[] { "test" });
}
@Test(expected = IllegalArgumentException.class)
public void rejectsNullParameters() throws Exception {
new ParametersParameterAccessor(null, new Object[0]);
@Test
public void rejectsNullParameters() {
assertThatIllegalArgumentException().isThrownBy(() -> new ParametersParameterAccessor(null, new Object[0]));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsNullValues() throws Exception {
new ParametersParameterAccessor(parameters, null);
@Test
public void rejectsNullValues() {
assertThatIllegalArgumentException().isThrownBy(() -> new ParametersParameterAccessor(parameters, null));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsTooLittleNumberOfArguments() throws Exception {
new ParametersParameterAccessor(parameters, new Object[0]);
@Test
public void rejectsTooLittleNumberOfArguments() {
assertThatIllegalArgumentException().isThrownBy(() -> new ParametersParameterAccessor(parameters, new Object[0]));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsTooManyArguments() throws Exception {
new ParametersParameterAccessor(parameters, new Object[] { "test", "test" });
@Test
public void rejectsTooManyArguments() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ParametersParameterAccessor(parameters, new Object[] { "test", "test" }));
}
@Test

View File

@@ -30,26 +30,25 @@ import org.springframework.data.domain.Sort;
public class OrderBySourceUnitTests {
@Test
public void handlesSingleDirectionAndPropertyCorrectly() throws Exception {
public void handlesSingleDirectionAndPropertyCorrectly() {
assertThat(new OrderBySource("UsernameDesc").toSort()).isEqualTo(Sort.by("username").descending());
}
@Test
public void handlesCamelCasePropertyCorrecty() throws Exception {
public void handlesCamelCasePropertyCorrecty() {
assertThat(new OrderBySource("LastnameUsernameDesc").toSort()).isEqualTo(Sort.by("lastnameUsername").descending());
}
@Test
public void handlesMultipleDirectionsCorrectly() throws Exception {
public void handlesMultipleDirectionsCorrectly() {
OrderBySource orderBySource = new OrderBySource("LastnameAscUsernameDesc");
assertThat(orderBySource.toSort()).isEqualTo(Sort.by("lastname").ascending().and(Sort.by("username").descending()));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsMissingProperty() throws Exception {
new OrderBySource("Desc");
@Test
public void rejectsMissingProperty() {
assertThatIllegalArgumentException().isThrownBy(() -> new OrderBySource("Desc"));
}
@Test

View File

@@ -50,19 +50,19 @@ public class PartTreeUnitTests {
private String[] PREFIXES = { "find", "read", "get", "query", "stream", "count", "delete", "remove", "exists" };
@Test(expected = IllegalArgumentException.class)
public void rejectsNullSource() throws Exception {
new PartTree(null, getClass());
@Test
public void rejectsNullSource() {
assertThatIllegalArgumentException().isThrownBy(() -> new PartTree(null, getClass()));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsNullDomainClass() throws Exception {
new PartTree("test", null);
@Test
public void rejectsNullDomainClass() {
assertThatIllegalArgumentException().isThrownBy(() -> new PartTree("test", null));
}
@Test(expected = IllegalArgumentException.class)
public void rejectsMultipleOrderBy() throws Exception {
partTree("firstnameOrderByLastnameOrderByFirstname");
@Test
public void rejectsMultipleOrderBy() {
assertThatIllegalArgumentException().isThrownBy(() -> partTree("firstnameOrderByLastnameOrderByFirstname"));
}
@Test

View File

@@ -29,14 +29,14 @@ import org.springframework.stereotype.Component;
*/
public class AnnotationAttributeUnitTests {
@Test(expected = IllegalArgumentException.class) // DATACMNS-607
@Test // DATACMNS-607
public void rejectsNullAnnotationType() {
new AnnotationAttribute(null);
assertThatIllegalArgumentException().isThrownBy(() -> new AnnotationAttribute(null));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-607
@Test // DATACMNS-607
public void rejectsNullAnnotationTypeForAnnotationAndAttributeName() {
new AnnotationAttribute(null, Optional.of("name"));
assertThatIllegalArgumentException().isThrownBy(() -> new AnnotationAttribute(null, Optional.of("name")));
}
@Test // DATACMNS-607

View File

@@ -21,10 +21,9 @@ import static org.mockito.Mockito.*;
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.sample.Product;
import org.springframework.data.repository.sample.ProductRepository;
@@ -47,8 +46,6 @@ public class DefaultRepositoryInvokerFactoryIntegrationTests {
RepositoryInvokerFactory factory;
@Rule public ExpectedException exception = ExpectedException.none();
@Before
public void setUp() {
this.factory = new DefaultRepositoryInvokerFactory(repositories);
@@ -69,11 +66,10 @@ public class DefaultRepositoryInvokerFactoryIntegrationTests {
@Test // DATACMNS-374, DATACMNS-589
public void shouldThrowMeaningfulExceptionWhenTheRepositoryForAGivenDomainClassCannotBeFound() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("No repository found for domain type: ");
exception.expectMessage(Object.class.getName());
factory.getInvokerFor(Object.class);
assertThatIllegalArgumentException() //
.isThrownBy(() -> factory.getInvokerFor(Object.class)) //
.withMessageContaining("No repository found for domain type: ") //
.withMessageContaining(Object.class.getName());
}
@Test // DATACMNS-589

View File

@@ -32,6 +32,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.AdditionalAnswers;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.GenericConversionService;
@@ -45,7 +46,7 @@ import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
import org.springframework.data.repository.query.Param;
import org.springframework.data.repository.support.CrudRepositoryInvokerUnitTests.PersonRepository;
import org.springframework.data.repository.support.RepositoryInvocationTestUtils.VerifyingMethodInterceptor;
import org.springframework.data.repository.support.RepositoryInvocationTestUtils.*;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -171,40 +172,40 @@ public class ReflectionRepositoryInvokerUnitTests {
getInvokerFor(repository, expectInvocationOf(method)).invokeDeleteById("1");
}
@Test(expected = IllegalStateException.class) // DATACMNS-589
@Test // DATACMNS-589
public void rejectsInvocationOfMissingDeleteMethod() {
RepositoryInvoker invoker = getInvokerFor(mock(EmptyRepository.class));
assertThat(invoker.hasDeleteMethod()).isFalse();
invoker.invokeDeleteById(1L);
assertThatIllegalStateException().isThrownBy(() -> invoker.invokeDeleteById(1L));
}
@Test(expected = IllegalStateException.class) // DATACMNS-589
@Test // DATACMNS-589
public void rejectsInvocationOfMissingFindOneMethod() {
RepositoryInvoker invoker = getInvokerFor(mock(EmptyRepository.class));
assertThat(invoker.hasFindOneMethod()).isFalse();
invoker.invokeFindById(1L);
assertThatIllegalStateException().isThrownBy(() -> invoker.invokeFindById(1L));
}
@Test(expected = IllegalStateException.class) // DATACMNS-589
@Test // DATACMNS-589
public void rejectsInvocationOfMissingFindAllMethod() {
RepositoryInvoker invoker = getInvokerFor(mock(EmptyRepository.class));
assertThat(invoker.hasFindAllMethod()).isFalse();
invoker.invokeFindAll(Sort.unsorted());
assertThatIllegalStateException().isThrownBy(() -> invoker.invokeFindAll(Sort.unsorted()));
}
@Test(expected = IllegalStateException.class) // DATACMNS-589
@Test // DATACMNS-589
public void rejectsInvocationOfMissingSaveMethod() {
RepositoryInvoker invoker = getInvokerFor(mock(EmptyRepository.class));
assertThat(invoker.hasSaveMethod()).isFalse();
invoker.invokeSave(new Object());
assertThatIllegalStateException().isThrownBy(() -> invoker.invokeSave(new Object()));
}
@Test // DATACMNS-647

View File

@@ -96,9 +96,9 @@ public class RepositoriesUnitTests {
assertThat(repositories.getRepositoryFor(String.class)).isNotPresent();
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullBeanFactory() {
new Repositories(null);
assertThatIllegalArgumentException().isThrownBy(() -> new Repositories(null));
}
@Test // DATACMNS-256

View File

@@ -36,9 +36,10 @@ import org.springframework.scheduling.annotation.Async;
*/
public class ClassUtilsUnitTests {
@Test(expected = IllegalStateException.class)
public void rejectsInvalidReturnType() throws Exception {
assertReturnTypeAssignable(SomeDao.class.getMethod("findByFirstname", Pageable.class, String.class), User.class);
@Test
public void rejectsInvalidReturnType() {
assertThatIllegalStateException().isThrownBy(() -> assertReturnTypeAssignable(
SomeDao.class.getMethod("findByFirstname", Pageable.class, String.class), User.class));
}
@Test

View File

@@ -39,9 +39,9 @@ public class PersistableIsNewStrategyUnitTests {
assertThat(strategy.isNew(entity)).isFalse();
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNonPersistableEntity() {
strategy.isNew(new Object());
assertThatIllegalArgumentException().isThrownBy(() -> strategy.isNew(new Object()));
}
@SuppressWarnings("serial")

View File

@@ -111,12 +111,13 @@ public class ChainedTransactionManagerTests {
}
@Test(expected = UnexpectedRollbackException.class)
@Test
public void shouldThrowExceptionOnFailingRollback() {
PlatformTransactionManager first = createFailingTransactionManager("first");
setupTransactionManagers(first);
createAndRollbackTransaction();
assertThatExceptionOfType(UnexpectedRollbackException.class).isThrownBy(this::createAndRollbackTransaction);
}
private void setupTransactionManagers(PlatformTransactionManager... transactionManagers) {

View File

@@ -30,9 +30,9 @@ import org.springframework.util.ReflectionUtils;
*/
public class AnnotationDetectionFieldCallbackUnitTests {
@Test(expected = IllegalArgumentException.class) // DATACMNS-616
@Test // DATACMNS-616
public void rejectsNullAnnotationType() {
new AnnotationDetectionFieldCallback(null);
assertThatIllegalArgumentException().isThrownBy(() -> new AnnotationDetectionFieldCallback(null));
}
@Test // DATACMNS-616

View File

@@ -17,9 +17,8 @@ package org.springframework.data.util;
import static org.assertj.core.api.Assertions.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.ReflectionUtils;
@@ -27,11 +26,10 @@ import org.springframework.util.ReflectionUtils;
* Unit tests for {@link AnnotationDetectionMethodCallback}.
*
* @author Oliver Gierke
* @author Mark Paluch
*/
public class AnnotationDetectionMethodCallbackUnitTests {
public @Rule ExpectedException exception = ExpectedException.none();
@Test // DATACMNS-452
public void findsMethodWithAnnotation() throws Exception {
@@ -47,13 +45,13 @@ public class AnnotationDetectionMethodCallbackUnitTests {
@Test // DATACMNS-452
public void detectsAmbiguousAnnotations() {
exception.expect(IllegalStateException.class);
exception.expectMessage("Value");
exception.expectMessage("getValue");
exception.expectMessage("getOtherValue");
AnnotationDetectionMethodCallback<Value> callback = new AnnotationDetectionMethodCallback<>(Value.class, true);
ReflectionUtils.doWithMethods(Multiple.class, callback);
assertThatIllegalStateException() //
.isThrownBy(() -> ReflectionUtils.doWithMethods(Multiple.class, callback)) //
.withMessageContaining("Value") //
.withMessageContaining("getValue") //
.withMessageContaining("getOtherValue");
}
interface Sample {

View File

@@ -42,7 +42,7 @@ public class ClassTypeInformationUnitTests {
@Test
public void discoversTypeForSimpleGenericField() {
TypeInformation<ConcreteType> discoverer = ClassTypeInformation.from(ConcreteType.class);
TypeInformation<ConcreteType> discoverer = from(ConcreteType.class);
assertThat(discoverer.getType()).isEqualTo(ConcreteType.class);
@@ -56,7 +56,7 @@ public class ClassTypeInformationUnitTests {
@Test
public void discoversTypeForNestedGenericField() {
TypeInformation<ConcreteWrapper> discoverer = ClassTypeInformation.from(ConcreteWrapper.class);
TypeInformation<ConcreteWrapper> discoverer = from(ConcreteWrapper.class);
assertThat(discoverer.getType()).isEqualTo(ConcreteWrapper.class);
assertThat(discoverer.getProperty("wrapped")).satisfies(it -> {
@@ -72,15 +72,14 @@ public class ClassTypeInformationUnitTests {
@SuppressWarnings("rawtypes")
public void discoversBoundType() {
TypeInformation<GenericTypeWithBound> information = ClassTypeInformation.from(GenericTypeWithBound.class);
TypeInformation<GenericTypeWithBound> information = from(GenericTypeWithBound.class);
assertThat(information.getProperty("person")).satisfies(it -> assertThat(it.getType()).isEqualTo(Person.class));
}
@Test
public void discoversBoundTypeForSpecialization() {
TypeInformation<SpecialGenericTypeWithBound> information = ClassTypeInformation
.from(SpecialGenericTypeWithBound.class);
TypeInformation<SpecialGenericTypeWithBound> information = from(SpecialGenericTypeWithBound.class);
assertThat(information.getProperty("person"))
.satisfies(it -> assertThat(it.getType()).isEqualTo(SpecialPerson.class));
}
@@ -89,7 +88,7 @@ public class ClassTypeInformationUnitTests {
@SuppressWarnings("rawtypes")
public void discoversBoundTypeForNested() {
TypeInformation<AnotherGenericType> information = ClassTypeInformation.from(AnotherGenericType.class);
TypeInformation<AnotherGenericType> information = from(AnotherGenericType.class);
assertThat(information.getProperty("nested"))
.satisfies(it -> assertThat(it.getType()).isEqualTo(GenericTypeWithBound.class));
@@ -100,7 +99,7 @@ public class ClassTypeInformationUnitTests {
@Test
public void discoversArraysAndCollections() {
TypeInformation<StringCollectionContainer> information = ClassTypeInformation.from(StringCollectionContainer.class);
TypeInformation<StringCollectionContainer> information = from(StringCollectionContainer.class);
TypeInformation<?> array = information.getProperty("array");
@@ -126,7 +125,7 @@ public class ClassTypeInformationUnitTests {
@Test
public void discoversMapValueType() {
TypeInformation<StringMapContainer> information = ClassTypeInformation.from(StringMapContainer.class);
TypeInformation<StringMapContainer> information = from(StringMapContainer.class);
TypeInformation<?> genericMap = information.getProperty("genericMap");
@@ -142,8 +141,8 @@ public class ClassTypeInformationUnitTests {
@Test
public void typeInfoDoesNotEqualForGenericTypesWithDifferentParent() {
TypeInformation<ConcreteWrapper> first = ClassTypeInformation.from(ConcreteWrapper.class);
TypeInformation<AnotherConcreteWrapper> second = ClassTypeInformation.from(AnotherConcreteWrapper.class);
TypeInformation<ConcreteWrapper> first = from(ConcreteWrapper.class);
TypeInformation<AnotherConcreteWrapper> second = from(AnotherConcreteWrapper.class);
assertThat(first.getProperty("wrapped").equals(second.getProperty("wrapped"))).isFalse();
}
@@ -151,7 +150,7 @@ public class ClassTypeInformationUnitTests {
@Test
public void handlesPropertyFieldMismatchCorrectly() {
TypeInformation<PropertyGetter> from = ClassTypeInformation.from(PropertyGetter.class);
TypeInformation<PropertyGetter> from = from(PropertyGetter.class);
assertThat(from.getProperty("_name")).satisfies(it -> assertThat(it.getType()).isEqualTo(String.class));
assertThat(from.getProperty("name")).satisfies(it -> assertThat(it.getType()).isEqualTo(byte[].class));
@@ -160,14 +159,14 @@ public class ClassTypeInformationUnitTests {
@Test // DATACMNS-77
public void returnsSameInstanceForCachedClass() {
TypeInformation<PropertyGetter> info = ClassTypeInformation.from(PropertyGetter.class);
assertThat(ClassTypeInformation.from(PropertyGetter.class)).isSameAs(info);
TypeInformation<PropertyGetter> info = from(PropertyGetter.class);
assertThat(from(PropertyGetter.class)).isSameAs(info);
}
@Test // DATACMNS-39
public void resolvesWildCardTypeCorrectly() {
TypeInformation<ClassWithWildCardBound> information = ClassTypeInformation.from(ClassWithWildCardBound.class);
TypeInformation<ClassWithWildCardBound> information = from(ClassWithWildCardBound.class);
TypeInformation<?> wildcard = information.getProperty("wildcard");
@@ -186,7 +185,7 @@ public class ClassTypeInformationUnitTests {
@Test
public void resolvesTypeParametersCorrectly() {
TypeInformation<ConcreteType> information = ClassTypeInformation.from(ConcreteType.class);
TypeInformation<ConcreteType> information = from(ConcreteType.class);
TypeInformation<?> superTypeInformation = information.getSuperTypeInformation(GenericType.class);
List<TypeInformation<?>> parameters = superTypeInformation.getTypeArguments();
@@ -198,7 +197,7 @@ public class ClassTypeInformationUnitTests {
@Test
public void resolvesNestedInheritedTypeParameters() {
TypeInformation<SecondExtension> information = ClassTypeInformation.from(SecondExtension.class);
TypeInformation<SecondExtension> information = from(SecondExtension.class);
TypeInformation<?> superTypeInformation = information.getSuperTypeInformation(Base.class);
List<TypeInformation<?>> parameters = superTypeInformation.getTypeArguments();
@@ -209,7 +208,7 @@ public class ClassTypeInformationUnitTests {
@Test
public void discoveresMethodParameterTypesCorrectly() throws Exception {
TypeInformation<SecondExtension> information = ClassTypeInformation.from(SecondExtension.class);
TypeInformation<SecondExtension> information = from(SecondExtension.class);
Method method = SecondExtension.class.getMethod("foo", Base.class);
List<TypeInformation<?>> informations = information.getParameterTypes(method);
TypeInformation<?> returnTypeInformation = information.getReturnType(method);
@@ -281,9 +280,9 @@ public class ClassTypeInformationUnitTests {
assertThat(information.getProperty("category.id")).isEqualTo(from(Long.class));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-387
@Test // DATACMNS-387
public void rejectsNullClass() {
ClassTypeInformation.from(null);
assertThatIllegalArgumentException().isThrownBy(() -> ClassTypeInformation.from(null));
}
@Test // DATACMNS-422
@@ -296,7 +295,7 @@ public class ClassTypeInformationUnitTests {
@Test // DATACMNS-440
public void detectsSpecialMapAsMapValueType() {
TypeInformation<?> seriously = ClassTypeInformation.from(SuperGenerics.class).getProperty("seriously");
TypeInformation<?> seriously = from(SuperGenerics.class).getProperty("seriously");
// Type
assertThat(seriously.getType()).isEqualTo(SortedMap.class);
@@ -331,7 +330,7 @@ public class ClassTypeInformationUnitTests {
@Test // DATACMNS-594
public void considersGenericsOfTypeBounds() {
assertThat(ClassTypeInformation.from(ConcreteRootIntermediate.class)
assertThat(from(ConcreteRootIntermediate.class)
.getProperty("intermediate.content.intermediate.content").getType())//
.isEqualTo(Leaf.class);
}
@@ -339,13 +338,13 @@ public class ClassTypeInformationUnitTests {
@Test // DATACMNS-783, DATACMNS-853
public void specializesTypeUsingTypeVariableContext() {
ClassTypeInformation<Foo> root = ClassTypeInformation.from(Foo.class);
ClassTypeInformation<Foo> root = from(Foo.class);
assertThat(root.getProperty("abstractBar").specialize(ClassTypeInformation.from(Bar.class)))//
assertThat(root.getProperty("abstractBar").specialize(from(Bar.class)))//
.satisfies(it -> {
assertThat(it.getType()).isEqualTo(Bar.class);
assertThat(it.getProperty("field").getType()).isEqualTo(Character.class);
assertThat(it.getProperty("anotherField").getType()).isEqualTo(Integer.class);
assertThat(it.getProperty("field").getType()).isEqualTo(Character.class);
assertThat(it.getProperty("anotherField").getType()).isEqualTo(Integer.class);
});
}
@@ -376,7 +375,7 @@ public class ClassTypeInformationUnitTests {
@Test // DATACMNS-896
public void prefersLocalTypeMappingOverNestedWithSameGenericType() {
ClassTypeInformation<Concrete> information = ClassTypeInformation.from(Concrete.class);
ClassTypeInformation<Concrete> information = from(Concrete.class);
assertThat(information.getProperty("field").getType()).isEqualTo(Nested.class);
}
@@ -384,7 +383,7 @@ public class ClassTypeInformationUnitTests {
@Test // DATACMNS-940
public void detectsVavrTraversableComponentType() {
ClassTypeInformation<SampleTraversable> information = ClassTypeInformation.from(SampleTraversable.class);
ClassTypeInformation<SampleTraversable> information = from(SampleTraversable.class);
assertThat(information.getComponentType().getType()).isAssignableFrom(Integer.class);
}
@@ -392,7 +391,7 @@ public class ClassTypeInformationUnitTests {
@Test // DATACMNS-940
public void detectsVavrMapComponentAndValueType() {
ClassTypeInformation<SampleMap> information = ClassTypeInformation.from(SampleMap.class);
ClassTypeInformation<SampleMap> information = from(SampleMap.class);
assertThat(information.getComponentType().getType()).isAssignableFrom(String.class);
@@ -402,8 +401,8 @@ public class ClassTypeInformationUnitTests {
@Test // DATACMNS-1138
public void usesTargetTypeForWildcardedBaseOnSpecialization() {
ClassTypeInformation<WildcardedWrapper> wrapper = ClassTypeInformation.from(WildcardedWrapper.class);
ClassTypeInformation<SomeConcrete> concrete = ClassTypeInformation.from(SomeConcrete.class);
ClassTypeInformation<WildcardedWrapper> wrapper = from(WildcardedWrapper.class);
ClassTypeInformation<SomeConcrete> concrete = from(SomeConcrete.class);
TypeInformation<?> property = wrapper.getRequiredProperty("wildcarded");

View File

@@ -51,18 +51,22 @@ public class DirectFieldAccessFallbackBeanWrapperUnitTests {
assertThat(sample.firstname).isEqualTo("Dave");
}
@Test(expected = NotReadablePropertyException.class) // DATACMNS-452
@Test // DATACMNS-452
public void throwsAppropriateExceptionIfNoFieldFoundForRead() {
BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(new Sample());
wrapper.getPropertyValue("lastname");
assertThatExceptionOfType(NotReadablePropertyException.class)
.isThrownBy(() -> wrapper.getPropertyValue("lastname"));
}
@Test(expected = NotWritablePropertyException.class) // DATACMNS-452
@Test // DATACMNS-452
public void throwsAppropriateExceptionIfNoFieldFoundForWrite() {
BeanWrapper wrapper = new DirectFieldAccessFallbackBeanWrapper(new Sample());
wrapper.setPropertyValue("lastname", "Matthews");
assertThatExceptionOfType(NotWritablePropertyException.class)
.isThrownBy(() -> wrapper.setPropertyValue("lastname", "Matthews"));
}
static class Sample {

View File

@@ -35,14 +35,14 @@ public class PairUnitTests {
assertThat(pair.getSecond()).isEqualTo(2);
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-790
@Test // DATACMNS-790
public void rejectsNullFirstElement() {
Pair.of(null, 1);
assertThatIllegalArgumentException().isThrownBy(() -> Pair.of(null, 1));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-790
@Test // DATACMNS-790
public void rejectsNullSecondElement() {
Pair.of(1, null);
assertThatIllegalArgumentException().isThrownBy(() -> Pair.of(1, null));
}
@Test // DATACMNS-790

View File

@@ -60,9 +60,10 @@ public class ReflectionUtilsUnitTests {
assertThat(field).isNull();
}
@Test(expected = IllegalStateException.class)
@Test
public void rejectsNonUniqueField() {
ReflectionUtils.findField(Sample.class, new ReflectionUtils.AnnotationFieldFilter(Autowired.class));
assertThatIllegalStateException().isThrownBy(
() -> ReflectionUtils.findField(Sample.class, new ReflectionUtils.AnnotationFieldFilter(Autowired.class)));
}
@Test

View File

@@ -47,9 +47,9 @@ public class TypeDiscovererUnitTests {
@Mock Map<TypeVariable<?>, Type> firstMap;
@Mock Map<TypeVariable<?>, Type> secondMap;
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullType() {
new TypeDiscoverer<>(null, null);
assertThatIllegalArgumentException().isThrownBy(() -> new TypeDiscoverer<>(null, null));
}
@Test

View File

@@ -20,9 +20,8 @@ import static org.springframework.data.web.SortDefaultUnitTests.*;
import javax.servlet.http.HttpServletRequest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.core.MethodParameter;
import org.springframework.data.domain.AbstractPageRequest;
import org.springframework.data.domain.PageRequest;
@@ -53,8 +52,6 @@ public abstract class PageableDefaultUnitTests {
static final AbstractPageRequest REFERENCE_WITH_SORT_FIELDS = PageRequest.of(PAGE_NUMBER, PAGE_SIZE,
Sort.by(SORT_FIELDS));
@Rule public ExpectedException exception = ExpectedException.none();
@Test
public void supportsPageable() {
assertThat(getResolver().supportsParameter(getParameterOfMethod("supportedMethod"))).isTrue();
@@ -107,10 +104,9 @@ public abstract class PageableDefaultUnitTests {
HandlerMethodArgumentResolver resolver = getResolver();
assertThat(resolver.supportsParameter(parameter)).isTrue();
exception.expect(IllegalStateException.class);
exception.expectMessage("unique");
resolver.resolveArgument(parameter, null, TestUtils.getWebRequest(), null);
assertThatIllegalStateException()
.isThrownBy(() -> resolver.resolveArgument(parameter, null, TestUtils.getWebRequest(), null)) //
.withMessageContaining("unique");
}
@Test
@@ -122,10 +118,9 @@ public abstract class PageableDefaultUnitTests {
HandlerMethodArgumentResolver resolver = getResolver();
assertThat(resolver.supportsParameter(parameter)).isTrue();
exception.expect(IllegalStateException.class);
exception.expectMessage("Ambiguous");
resolver.resolveArgument(parameter, null, TestUtils.getWebRequest(), null);
assertThatIllegalStateException()
.isThrownBy(() -> resolver.resolveArgument(parameter, null, TestUtils.getWebRequest(), null)) //
.withMessageContaining("Ambiguous");
}
protected void assertSupportedAndResult(MethodParameter parameter, Pageable pageable) throws Exception {

View File

@@ -56,24 +56,28 @@ public class PageableHandlerMethodArgumentResolverUnitTests extends PageableDefa
assertSupportedAndResult(supportedMethodParameter, PageRequest.of(0, 100), request);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsEmptyPageParameterName() {
new PageableHandlerMethodArgumentResolver().setPageParameterName("");
assertThatIllegalArgumentException()
.isThrownBy(() -> new PageableHandlerMethodArgumentResolver().setPageParameterName(""));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullPageParameterName() {
new PageableHandlerMethodArgumentResolver().setPageParameterName(null);
assertThatIllegalArgumentException()
.isThrownBy(() -> new PageableHandlerMethodArgumentResolver().setPageParameterName(null));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsEmptySizeParameterName() {
new PageableHandlerMethodArgumentResolver().setSizeParameterName("");
assertThatIllegalArgumentException()
.isThrownBy(() -> new PageableHandlerMethodArgumentResolver().setSizeParameterName(""));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullSizeParameterName() {
new PageableHandlerMethodArgumentResolver().setSizeParameterName(null);
assertThatIllegalArgumentException()
.isThrownBy(() -> new PageableHandlerMethodArgumentResolver().setSizeParameterName(null));
}
@Test
@@ -104,10 +108,8 @@ public class PageableHandlerMethodArgumentResolverUnitTests extends PageableDefa
MethodParameter parameter = new MethodParameter(Sample.class.getMethod("invalidDefaultPageSize", Pageable.class),
0);
exception.expect(IllegalStateException.class);
exception.expectMessage("invalidDefaultPageSize");
assertSupportedAndResult(parameter, DEFAULT_PAGE_REQUEST);
assertThatIllegalStateException().isThrownBy(() -> assertSupportedAndResult(parameter, DEFAULT_PAGE_REQUEST)) //
.withMessageContaining("invalidDefaultPageSize");
}
@Test // DATACMNS-408

View File

@@ -21,9 +21,8 @@ import java.lang.reflect.Method;
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.MethodParameter;
import org.springframework.data.domain.Pageable;
@@ -41,8 +40,6 @@ public class PagedResourcesAssemblerArgumentResolverUnitTests {
PagedResourcesAssemblerArgumentResolver resolver;
public @Rule ExpectedException exception = ExpectedException.none();
@Before
public void setUp() {
@@ -160,8 +157,8 @@ public class PagedResourcesAssemblerArgumentResolverUnitTests {
Method method = Controller.class.getMethod(methodName, PagedResourcesAssembler.class, Pageable.class,
Pageable.class);
exception.expect(IllegalStateException.class);
resolver.resolveArgument(new MethodParameter(method, 0), null, null, null);
assertThatIllegalStateException()
.isThrownBy(() -> resolver.resolveArgument(new MethodParameter(method, 0), null, null, null));
}
@RequestMapping("/")

View File

@@ -191,14 +191,14 @@ public class PagedResourcesAssemblerUnitTests {
assertThat(((EmbeddedWrapper) element).getRelTargetType()).isEqualTo(Person.class);
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-699
@Test // DATACMNS-699
public void emptyPageCreatorRejectsPageWithContent() {
assembler.toEmptyModel(createPage(1), Person.class);
assertThatIllegalArgumentException().isThrownBy(() -> assembler.toEmptyModel(createPage(1), Person.class));
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-699
@Test // DATACMNS-699
public void emptyPageCreatorRejectsNullType() {
assembler.toEmptyModel(EMPTY_PAGE, null);
assertThatIllegalArgumentException().isThrownBy(() -> assembler.toEmptyModel(EMPTY_PAGE, null));
}
@Test // DATACMNS-701

View File

@@ -17,9 +17,8 @@ package org.springframework.data.web;
import static org.assertj.core.api.Assertions.*;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.core.MethodParameter;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
@@ -32,6 +31,7 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolver;
*
* @since 1.6
* @author Oliver Gierke
* @author Mark Paluch
*/
public abstract class SortDefaultUnitTests {
@@ -45,8 +45,6 @@ public abstract class SortDefaultUnitTests {
static final Sort SORT = Sort.by(SORT_DIRECTION, SORT_FIELDS);
@Rule public ExpectedException exception = ExpectedException.none();
@Test
public void parsesSimpleSortStringCorrectly() {
@@ -92,19 +90,18 @@ public abstract class SortDefaultUnitTests {
}
@Test
public void rejectsDoubleAnnotatedMethod() throws Exception {
public void rejectsDoubleAnnotatedMethod() {
MethodParameter parameter = getParameterOfMethod("invalid");
HandlerMethodArgumentResolver resolver = new SortHandlerMethodArgumentResolver();
assertThat(resolver.supportsParameter(parameter)).isTrue();
exception.expect(IllegalArgumentException.class);
exception.expectMessage(SortDefault.class.getSimpleName());
exception.expectMessage(SortDefaults.class.getSimpleName());
exception.expectMessage(parameter.toString());
resolver.resolveArgument(parameter, null, TestUtils.getWebRequest(), null);
assertThatIllegalArgumentException()
.isThrownBy(() -> resolver.resolveArgument(parameter, null, TestUtils.getWebRequest(), null)) //
.withMessageContaining(SortDefault.class.getSimpleName()) //
.withMessageContaining(SortDefaults.class.getSimpleName()) //
.withMessageContaining(parameter.toString());
}
@Test

View File

@@ -21,9 +21,8 @@ import static org.springframework.data.web.querydsl.QuerydslPredicateArgumentRes
import java.util.Optional;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.core.MethodParameter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -52,13 +51,10 @@ import com.querydsl.core.types.dsl.BooleanExpression;
*
* @author Christoph Strobl
* @author Oliver Gierke
* @author Mark Paluch
*/
public class QuerydslPredicateArgumentResolverUnitTests {
static final TypeInformation<?> USER_TYPE = ClassTypeInformation.from(User.class);
public @Rule ExpectedException exception = ExpectedException.none();
QuerydslPredicateArgumentResolver resolver;
MockHttpServletRequest request;
@@ -81,9 +77,10 @@ public class QuerydslPredicateArgumentResolverUnitTests {
.isTrue();
}
@Test(expected = IllegalArgumentException.class) // DATACMNS-669
@Test // DATACMNS-669
public void supportsParameterShouldThrowExceptionWhenMethodParameterIsNoPredicateButAnnotatedAsSuch() {
resolver.supportsParameter(getMethodParameterFor("nonPredicateWithAnnotation", String.class));
assertThatIllegalArgumentException().isThrownBy(
() -> resolver.supportsParameter(getMethodParameterFor("nonPredicateWithAnnotation", String.class)));
}
@Test // DATACMNS-669
@@ -100,7 +97,7 @@ public class QuerydslPredicateArgumentResolverUnitTests {
Predicate predicate = resolver.resolveArgument(getMethodParameterFor("simpleFind", Predicate.class), null,
new ServletWebRequest(request), null);
assertThat(predicate).isEqualTo((Predicate) QUser.user.firstname.eq("rand"));
assertThat(predicate).isEqualTo(QUser.user.firstname.eq("rand"));
}
@Test // DATACMNS-669
@@ -112,7 +109,7 @@ public class QuerydslPredicateArgumentResolverUnitTests {
Predicate predicate = resolver.resolveArgument(getMethodParameterFor("simpleFind", Predicate.class), null,
new ServletWebRequest(request), null);
assertThat(predicate).isEqualTo((Predicate) QUser.user.firstname.eq("rand").and(QUser.user.lastname.eq("al'thor")));
assertThat(predicate).isEqualTo(QUser.user.firstname.eq("rand").and(QUser.user.lastname.eq("al'thor")));
}
@Test // DATACMNS-669