Use default visibility for test classes and methods in spring-core

See gh-23451
This commit is contained in:
Sam Brannen 2019-08-20 14:43:24 +02:00
parent cf1bf3d98c
commit fab96cad67
180 changed files with 2920 additions and 2899 deletions

View File

@ -14,51 +14,52 @@
* limitations under the License.
*/
package org.springframework.core.type;
package example.type;
/**
* We must use a standalone set of types to ensure that no one else is loading
* them and interfering with {@link ClassloadingAssertions#assertClassNotLoaded(String)}.
* them and interfering with
* {@link org.springframework.core.type.ClassloadingAssertions#assertClassNotLoaded(String)}.
*
* @author Ramnivas Laddad
* @author Juergen Hoeller
* @author Oliver Gierke
* @author Sam Brannen
* @see AnnotationTypeFilterTests
* @see org.springframework.core.type.AnnotationTypeFilterTests
*/
class AnnotationTypeFilterTestsTypes {
public class AnnotationTypeFilterTestsTypes {
@AnnotationTypeFilterTests.InheritedAnnotation
private static class SomeComponent {
@InheritedAnnotation
public static class SomeComponent {
}
@AnnotationTypeFilterTests.InheritedAnnotation
private interface SomeComponentInterface {
@InheritedAnnotation
public interface SomeComponentInterface {
}
@SuppressWarnings("unused")
private static class SomeClassWithSomeComponentInterface implements Cloneable, SomeComponentInterface {
public static class SomeClassWithSomeComponentInterface implements Cloneable, SomeComponentInterface {
}
@SuppressWarnings("unused")
private static class SomeSubclassOfSomeComponent extends SomeComponent {
public static class SomeSubclassOfSomeComponent extends SomeComponent {
}
@AnnotationTypeFilterTests.NonInheritedAnnotation
private static class SomeClassMarkedWithNonInheritedAnnotation {
@NonInheritedAnnotation
public static class SomeClassMarkedWithNonInheritedAnnotation {
}
@SuppressWarnings("unused")
private static class SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation extends SomeClassMarkedWithNonInheritedAnnotation {
public static class SomeSubclassOfSomeClassMarkedWithNonInheritedAnnotation extends SomeClassMarkedWithNonInheritedAnnotation {
}
@SuppressWarnings("unused")
private static class SomeNonCandidateClass {
public static class SomeNonCandidateClass {
}
}

View File

@ -14,38 +14,39 @@
* limitations under the License.
*/
package org.springframework.core.type;
package example.type;
import org.springframework.stereotype.Component;
/**
* We must use a standalone set of types to ensure that no one else is loading
* them and interfering with {@link ClassloadingAssertions#assertClassNotLoaded(String)}.
* them and interfering with
* {@link org.springframework.core.type.ClassloadingAssertions#assertClassNotLoaded(String)}.
*
* @author Ramnivas Laddad
* @author Sam Brannen
* @see AspectJTypeFilterTests
* @see org.springframework.core.type.AspectJTypeFilterTests
*/
public class AspectJTypeFilterTestsTypes {
interface SomeInterface {
public interface SomeInterface {
}
static class SomeClass {
public static class SomeClass {
}
static class SomeClassExtendingSomeClass extends SomeClass {
public static class SomeClassExtendingSomeClass extends SomeClass {
}
static class SomeClassImplementingSomeInterface implements SomeInterface {
public static class SomeClassImplementingSomeInterface implements SomeInterface {
}
static class SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface
public static class SomeClassExtendingSomeClassExtendingSomeClassAndImplementingSomeInterface
extends SomeClassExtendingSomeClass implements SomeInterface {
}
@Component
static class SomeClassAnnotatedWithComponent {
public static class SomeClassAnnotatedWithComponent {
}
}

View File

@ -14,38 +14,39 @@
* limitations under the License.
*/
package org.springframework.core.type;
package example.type;
/**
* We must use a standalone set of types to ensure that no one else is loading
* them and interfering with {@link ClassloadingAssertions#assertClassNotLoaded(String)}.
* them and interfering with
* {@link org.springframework.core.type.ClassloadingAssertions#assertClassNotLoaded(String)}.
*
* @author Ramnivas Laddad
* @author Juergen Hoeller
* @author Sam Brannen
* @see AssignableTypeFilterTests
* @see org.springframework.core.type.AssignableTypeFilterTests
*/
class AssignableTypeFilterTestsTypes {
public class AssignableTypeFilterTestsTypes {
static class TestNonInheritingClass {
public static class TestNonInheritingClass {
}
interface TestInterface {
public interface TestInterface {
}
static class TestInterfaceImpl implements TestInterface {
public static class TestInterfaceImpl implements TestInterface {
}
interface SomeDaoLikeInterface {
public interface SomeDaoLikeInterface {
}
static class SomeDaoLikeImpl extends SimpleJdbcDaoSupport implements SomeDaoLikeInterface {
public static class SomeDaoLikeImpl extends SimpleJdbcDaoSupport implements SomeDaoLikeInterface {
}
interface JdbcDaoSupport {
public interface JdbcDaoSupport {
}
static class SimpleJdbcDaoSupport implements JdbcDaoSupport {
public static class SimpleJdbcDaoSupport implements JdbcDaoSupport {
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package example.type;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Inherited
@Retention(RetentionPolicy.RUNTIME)
public @interface InheritedAnnotation {
}

View File

@ -0,0 +1,24 @@
/*
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package example.type;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface NonInheritedAnnotation {
}

View File

@ -27,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 2.0
*/
public class AttributeAccessorSupportTests {
class AttributeAccessorSupportTests {
private static final String NAME = "foo";
@ -36,20 +36,20 @@ public class AttributeAccessorSupportTests {
private AttributeAccessor attributeAccessor = new SimpleAttributeAccessorSupport();
@Test
public void setAndGet() throws Exception {
void setAndGet() throws Exception {
this.attributeAccessor.setAttribute(NAME, VALUE);
assertThat(this.attributeAccessor.getAttribute(NAME)).isEqualTo(VALUE);
}
@Test
public void setAndHas() throws Exception {
void setAndHas() throws Exception {
assertThat(this.attributeAccessor.hasAttribute(NAME)).isFalse();
this.attributeAccessor.setAttribute(NAME, VALUE);
assertThat(this.attributeAccessor.hasAttribute(NAME)).isTrue();
}
@Test
public void remove() throws Exception {
void remove() throws Exception {
assertThat(this.attributeAccessor.hasAttribute(NAME)).isFalse();
this.attributeAccessor.setAttribute(NAME, VALUE);
assertThat(this.attributeAccessor.removeAttribute(NAME)).isEqualTo(VALUE);
@ -57,7 +57,7 @@ public class AttributeAccessorSupportTests {
}
@Test
public void attributeNames() throws Exception {
void attributeNames() throws Exception {
this.attributeAccessor.setAttribute(NAME, VALUE);
this.attributeAccessor.setAttribute("abc", "123");
String[] attributeNames = this.attributeAccessor.attributeNames();

View File

@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
*/
@SuppressWarnings("rawtypes")
public class BridgeMethodResolverTests {
class BridgeMethodResolverTests {
private static Method findMethodWithReturnType(String name, Class<?> returnType, Class<SettingsDaoImpl> targetType) {
Method[] methods = targetType.getMethods();
@ -54,7 +54,7 @@ public class BridgeMethodResolverTests {
@Test
public void testFindBridgedMethod() throws Exception {
void findBridgedMethod() throws Exception {
Method unbridged = MyFoo.class.getDeclaredMethod("someMethod", String.class, Object.class);
Method bridged = MyFoo.class.getDeclaredMethod("someMethod", Serializable.class, Object.class);
assertThat(unbridged.isBridge()).isFalse();
@ -65,7 +65,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testFindBridgedVarargMethod() throws Exception {
void findBridgedVarargMethod() throws Exception {
Method unbridged = MyFoo.class.getDeclaredMethod("someVarargMethod", String.class, Object[].class);
Method bridged = MyFoo.class.getDeclaredMethod("someVarargMethod", Serializable.class, Object[].class);
assertThat(unbridged.isBridge()).isFalse();
@ -76,7 +76,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testFindBridgedMethodInHierarchy() throws Exception {
void findBridgedMethodInHierarchy() throws Exception {
Method bridgeMethod = DateAdder.class.getMethod("add", Object.class);
assertThat(bridgeMethod.isBridge()).isTrue();
Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod);
@ -87,7 +87,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testIsBridgeMethodFor() throws Exception {
void isBridgeMethodFor() throws Exception {
Method bridged = MyBar.class.getDeclaredMethod("someMethod", String.class, Object.class);
Method other = MyBar.class.getDeclaredMethod("someMethod", Integer.class, Object.class);
Method bridge = MyBar.class.getDeclaredMethod("someMethod", Object.class, Object.class);
@ -97,7 +97,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testDoubleParameterization() throws Exception {
void doubleParameterization() throws Exception {
Method objectBridge = MyBoo.class.getDeclaredMethod("foo", Object.class);
Method serializableBridge = MyBoo.class.getDeclaredMethod("foo", Serializable.class);
@ -109,7 +109,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testFindBridgedMethodFromMultipleBridges() throws Exception {
void findBridgedMethodFromMultipleBridges() throws Exception {
Method loadWithObjectReturn = findMethodWithReturnType("load", Object.class, SettingsDaoImpl.class);
assertThat(loadWithObjectReturn).isNotNull();
@ -123,7 +123,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testFindBridgedMethodFromParent() throws Exception {
void findBridgedMethodFromParent() throws Exception {
Method loadFromParentBridge = SettingsDaoImpl.class.getMethod("loadFromParent");
assertThat(loadFromParentBridge.isBridge()).isTrue();
@ -134,7 +134,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testWithSingleBoundParameterizedOnInstantiate() throws Exception {
void withSingleBoundParameterizedOnInstantiate() throws Exception {
Method bridgeMethod = DelayQueue.class.getMethod("add", Object.class);
assertThat(bridgeMethod.isBridge()).isTrue();
Method actualMethod = DelayQueue.class.getMethod("add", Delayed.class);
@ -143,7 +143,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testWithDoubleBoundParameterizedOnInstantiate() throws Exception {
void withDoubleBoundParameterizedOnInstantiate() throws Exception {
Method bridgeMethod = SerializableBounded.class.getMethod("boundedOperation", Object.class);
assertThat(bridgeMethod.isBridge()).isTrue();
Method actualMethod = SerializableBounded.class.getMethod("boundedOperation", HashMap.class);
@ -152,7 +152,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testWithGenericParameter() throws Exception {
void withGenericParameter() throws Exception {
Method[] methods = StringGenericParameter.class.getMethods();
Method bridgeMethod = null;
Method bridgedMethod = null;
@ -173,7 +173,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testOnAllMethods() throws Exception {
void onAllMethods() throws Exception {
Method[] methods = StringList.class.getMethods();
for (Method method : methods) {
assertThat(BridgeMethodResolver.findBridgedMethod(method)).isNotNull();
@ -181,7 +181,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR2583() throws Exception {
void spr2583() throws Exception {
Method bridgedMethod = MessageBroadcasterImpl.class.getMethod("receive", MessageEvent.class);
assertThat(bridgedMethod.isBridge()).isFalse();
Method bridgeMethod = MessageBroadcasterImpl.class.getMethod("receive", Event.class);
@ -197,7 +197,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR2603() throws Exception {
void spr2603() throws Exception {
Method objectBridge = YourHomer.class.getDeclaredMethod("foo", Bounded.class);
Method abstractBoundedFoo = YourHomer.class.getDeclaredMethod("foo", AbstractBounded.class);
@ -206,7 +206,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR2648() throws Exception {
void spr2648() throws Exception {
Method bridgeMethod = ReflectionUtils.findMethod(GenericSqlMapIntegerDao.class, "saveOrUpdate", Object.class);
assertThat(bridgeMethod != null && bridgeMethod.isBridge()).isTrue();
Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod);
@ -215,7 +215,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR2763() throws Exception {
void spr2763() throws Exception {
Method bridgedMethod = AbstractDao.class.getDeclaredMethod("save", Object.class);
assertThat(bridgedMethod.isBridge()).isFalse();
@ -226,7 +226,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR3041() throws Exception {
void spr3041() throws Exception {
Method bridgedMethod = BusinessDao.class.getDeclaredMethod("save", Business.class);
assertThat(bridgedMethod.isBridge()).isFalse();
@ -237,7 +237,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR3173() throws Exception {
void spr3173() throws Exception {
Method bridgedMethod = UserDaoImpl.class.getDeclaredMethod("saveVararg", User.class, Object[].class);
assertThat(bridgedMethod.isBridge()).isFalse();
@ -248,7 +248,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR3304() throws Exception {
void spr3304() throws Exception {
Method bridgedMethod = MegaMessageProducerImpl.class.getDeclaredMethod("receive", MegaMessageEvent.class);
assertThat(bridgedMethod.isBridge()).isFalse();
@ -259,7 +259,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR3324() throws Exception {
void spr3324() throws Exception {
Method bridgedMethod = BusinessDao.class.getDeclaredMethod("get", Long.class);
assertThat(bridgedMethod.isBridge()).isFalse();
@ -270,7 +270,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR3357() throws Exception {
void spr3357() throws Exception {
Method bridgedMethod = ExtendsAbstractImplementsInterface.class.getDeclaredMethod(
"doSomething", DomainObjectExtendsSuper.class, Object.class);
assertThat(bridgedMethod.isBridge()).isFalse();
@ -283,7 +283,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR3485() throws Exception {
void spr3485() throws Exception {
Method bridgedMethod = DomainObject.class.getDeclaredMethod(
"method2", ParameterType.class, byte[].class);
assertThat(bridgedMethod.isBridge()).isFalse();
@ -296,7 +296,7 @@ public class BridgeMethodResolverTests {
}
@Test
public void testSPR3534() throws Exception {
void spr3534() throws Exception {
Method bridgeMethod = ReflectionUtils.findMethod(TestEmailProvider.class, "findBy", Object.class);
assertThat(bridgeMethod != null && bridgeMethod.isBridge()).isTrue();
Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(bridgeMethod);
@ -305,12 +305,12 @@ public class BridgeMethodResolverTests {
}
@Test // SPR-16103
public void testClassHierarchy() throws Exception {
void testClassHierarchy() throws Exception {
doTestHierarchyResolution(FooClass.class);
}
@Test // SPR-16103
public void testInterfaceHierarchy() throws Exception {
void testInterfaceHierarchy() throws Exception {
doTestHierarchyResolution(FooInterface.class);
}

View File

@ -55,7 +55,7 @@ import static org.springframework.core.CollectionFactory.createMap;
* @author Sam Brannen
* @since 4.1.4
*/
public class CollectionFactoryTests {
class CollectionFactoryTests {
/**
* The test demonstrates that the generics-based API for
@ -69,7 +69,7 @@ public class CollectionFactoryTests {
* actually contains elements of type {@code E}.
*/
@Test
public void createApproximateCollectionIsNotTypeSafeForEnumSet() {
void createApproximateCollectionIsNotTypeSafeForEnumSet() {
Collection<Integer> ints = createApproximateCollection(EnumSet.of(Color.BLUE), 3);
// Use a try-catch block to ensure that the exception is thrown as a result of the
@ -84,7 +84,7 @@ public class CollectionFactoryTests {
}
@Test
public void createCollectionIsNotTypeSafeForEnumSet() {
void createCollectionIsNotTypeSafeForEnumSet() {
Collection<Integer> ints = createCollection(EnumSet.class, Color.class, 3);
// Use a try-catch block to ensure that the exception is thrown as a result of the
@ -106,7 +106,7 @@ public class CollectionFactoryTests {
* {@link #createApproximateCollectionIsNotTypeSafeForEnumSet}.
*/
@Test
public void createApproximateMapIsNotTypeSafeForEnumMap() {
void createApproximateMapIsNotTypeSafeForEnumMap() {
EnumMap<Color, Integer> enumMap = new EnumMap<>(Color.class);
enumMap.put(Color.RED, 1);
enumMap.put(Color.BLUE, 2);
@ -124,7 +124,7 @@ public class CollectionFactoryTests {
}
@Test
public void createMapIsNotTypeSafeForEnumMap() {
void createMapIsNotTypeSafeForEnumMap() {
Map<String, Integer> map = createMap(EnumMap.class, Color.class, 3);
// Use a try-catch block to ensure that the exception is thrown as a result of the
@ -139,7 +139,7 @@ public class CollectionFactoryTests {
}
@Test
public void createMapIsNotTypeSafeForLinkedMultiValueMap() {
void createMapIsNotTypeSafeForLinkedMultiValueMap() {
Map<String, Integer> map = createMap(MultiValueMap.class, null, 3);
// Use a try-catch block to ensure that the exception is thrown as a result of the
@ -154,13 +154,13 @@ public class CollectionFactoryTests {
}
@Test
public void createApproximateCollectionFromEmptyHashSet() {
void createApproximateCollectionFromEmptyHashSet() {
Collection<String> set = createApproximateCollection(new HashSet<String>(), 2);
Assertions.assertThat(set).isEmpty();
}
@Test
public void createApproximateCollectionFromNonEmptyHashSet() {
void createApproximateCollectionFromNonEmptyHashSet() {
HashSet<String> hashSet = new HashSet<>();
hashSet.add("foo");
Collection<String> set = createApproximateCollection(hashSet, 2);
@ -168,25 +168,25 @@ public class CollectionFactoryTests {
}
@Test
public void createApproximateCollectionFromEmptyEnumSet() {
void createApproximateCollectionFromEmptyEnumSet() {
Collection<Color> colors = createApproximateCollection(EnumSet.noneOf(Color.class), 2);
assertThat(colors).isEmpty();
}
@Test
public void createApproximateCollectionFromNonEmptyEnumSet() {
void createApproximateCollectionFromNonEmptyEnumSet() {
Collection<Color> colors = createApproximateCollection(EnumSet.of(Color.BLUE), 2);
assertThat(colors).isEmpty();
}
@Test
public void createApproximateMapFromEmptyHashMap() {
void createApproximateMapFromEmptyHashMap() {
Map<String, String> map = createApproximateMap(new HashMap<String, String>(), 2);
assertThat(map).isEmpty();
}
@Test
public void createApproximateMapFromNonEmptyHashMap() {
void createApproximateMapFromNonEmptyHashMap() {
Map<String, String> hashMap = new HashMap<>();
hashMap.put("foo", "bar");
Map<String, String> map = createApproximateMap(hashMap, 2);
@ -194,13 +194,13 @@ public class CollectionFactoryTests {
}
@Test
public void createApproximateMapFromEmptyEnumMap() {
void createApproximateMapFromEmptyEnumMap() {
Map<Color, String> colors = createApproximateMap(new EnumMap<Color, String>(Color.class), 2);
assertThat(colors).isEmpty();
}
@Test
public void createApproximateMapFromNonEmptyEnumMap() {
void createApproximateMapFromNonEmptyEnumMap() {
EnumMap<Color, String> enumMap = new EnumMap<>(Color.class);
enumMap.put(Color.BLUE, "blue");
Map<Color, String> colors = createApproximateMap(enumMap, 2);
@ -208,7 +208,7 @@ public class CollectionFactoryTests {
}
@Test
public void createsCollectionsCorrectly() {
void createsCollectionsCorrectly() {
// interfaces
assertThat(createCollection(List.class, 0)).isInstanceOf(ArrayList.class);
assertThat(createCollection(Set.class, 0)).isInstanceOf(LinkedHashSet.class);
@ -228,36 +228,36 @@ public class CollectionFactoryTests {
}
@Test
public void createsEnumSet() {
void createsEnumSet() {
assertThat(createCollection(EnumSet.class, Color.class, 0)).isInstanceOf(EnumSet.class);
}
@Test // SPR-17619
public void createsEnumSetSubclass() {
void createsEnumSetSubclass() {
EnumSet<Color> enumSet = EnumSet.noneOf(Color.class);
assertThat(createCollection(enumSet.getClass(), Color.class, 0)).isInstanceOf(enumSet.getClass());
}
@Test
public void rejectsInvalidElementTypeForEnumSet() {
void rejectsInvalidElementTypeForEnumSet() {
assertThatIllegalArgumentException().isThrownBy(() ->
createCollection(EnumSet.class, Object.class, 0));
}
@Test
public void rejectsNullElementTypeForEnumSet() {
void rejectsNullElementTypeForEnumSet() {
assertThatIllegalArgumentException().isThrownBy(() ->
createCollection(EnumSet.class, null, 0));
}
@Test
public void rejectsNullCollectionType() {
void rejectsNullCollectionType() {
assertThatIllegalArgumentException().isThrownBy(() ->
createCollection(null, Object.class, 0));
}
@Test
public void createsMapsCorrectly() {
void createsMapsCorrectly() {
// interfaces
assertThat(createMap(Map.class, 0)).isInstanceOf(LinkedHashMap.class);
assertThat(createMap(SortedMap.class, 0)).isInstanceOf(TreeMap.class);
@ -276,24 +276,24 @@ public class CollectionFactoryTests {
}
@Test
public void createsEnumMap() {
void createsEnumMap() {
assertThat(createMap(EnumMap.class, Color.class, 0)).isInstanceOf(EnumMap.class);
}
@Test
public void rejectsInvalidKeyTypeForEnumMap() {
void rejectsInvalidKeyTypeForEnumMap() {
assertThatIllegalArgumentException().isThrownBy(() ->
createMap(EnumMap.class, Object.class, 0));
}
@Test
public void rejectsNullKeyTypeForEnumMap() {
void rejectsNullKeyTypeForEnumMap() {
assertThatIllegalArgumentException().isThrownBy(() ->
createMap(EnumMap.class, null, 0));
}
@Test
public void rejectsNullMapType() {
void rejectsNullMapType() {
assertThatIllegalArgumentException().isThrownBy(() ->
createMap(null, Object.class, 0));
}

View File

@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rick Evans
* @since 28.04.2003
*/
public class ConstantsTests {
class ConstantsTests {
@Test
public void constants() {
void constants() {
Constants c = new Constants(A.class);
assertThat(c.getClassName()).isEqualTo(A.class.getName());
assertThat(c.getSize()).isEqualTo(9);
@ -52,7 +52,7 @@ public class ConstantsTests {
}
@Test
public void getNames() {
void getNames() {
Constants c = new Constants(A.class);
Set<?> names = c.getNames("");
@ -71,7 +71,7 @@ public class ConstantsTests {
}
@Test
public void getValues() {
void getValues() {
Constants c = new Constants(A.class);
Set<?> values = c.getValues("");
@ -96,7 +96,7 @@ public class ConstantsTests {
}
@Test
public void getValuesInTurkey() {
void getValuesInTurkey() {
Locale oldLocale = Locale.getDefault();
Locale.setDefault(new Locale("tr", ""));
try {
@ -128,7 +128,7 @@ public class ConstantsTests {
}
@Test
public void suffixAccess() {
void suffixAccess() {
Constants c = new Constants(A.class);
Set<?> names = c.getNamesForSuffix("_PROPERTY");
@ -143,7 +143,7 @@ public class ConstantsTests {
}
@Test
public void toCode() {
void toCode() {
Constants c = new Constants(A.class);
assertThat(c.toCode(Integer.valueOf(0), "")).isEqualTo("DOG");
@ -191,28 +191,28 @@ public class ConstantsTests {
}
@Test
public void getValuesWithNullPrefix() throws Exception {
void getValuesWithNullPrefix() throws Exception {
Constants c = new Constants(A.class);
Set<?> values = c.getValues(null);
assertThat(values.size()).as("Must have returned *all* public static final values").isEqualTo(7);
}
@Test
public void getValuesWithEmptyStringPrefix() throws Exception {
void getValuesWithEmptyStringPrefix() throws Exception {
Constants c = new Constants(A.class);
Set<Object> values = c.getValues("");
assertThat(values.size()).as("Must have returned *all* public static final values").isEqualTo(7);
}
@Test
public void getValuesWithWhitespacedStringPrefix() throws Exception {
void getValuesWithWhitespacedStringPrefix() throws Exception {
Constants c = new Constants(A.class);
Set<?> values = c.getValues(" ");
assertThat(values.size()).as("Must have returned *all* public static final values").isEqualTo(7);
}
@Test
public void withClassThatExposesNoConstants() throws Exception {
void withClassThatExposesNoConstants() throws Exception {
Constants c = new Constants(NoConstants.class);
assertThat(c.getSize()).isEqualTo(0);
final Set<?> values = c.getValues("");
@ -221,7 +221,7 @@ public class ConstantsTests {
}
@Test
public void ctorWithNullClass() throws Exception {
void ctorWithNullClass() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
new Constants(null));
}

View File

@ -41,43 +41,43 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Rob Harrop
* @author Sam Brannen
*/
public class ConventionsTests {
class ConventionsTests {
@Test
public void simpleObject() {
void simpleObject() {
assertThat(Conventions.getVariableName(new TestObject())).as("Incorrect singular variable name").isEqualTo("testObject");
assertThat(Conventions.getVariableNameForParameter(getMethodParameter(TestObject.class))).as("Incorrect singular variable name").isEqualTo("testObject");
assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(TestObject.class))).as("Incorrect singular variable name").isEqualTo("testObject");
}
@Test
public void array() {
void array() {
Object actual = Conventions.getVariableName(new TestObject[0]);
assertThat(actual).as("Incorrect plural array form").isEqualTo("testObjectList");
}
@Test
public void list() {
void list() {
assertThat(Conventions.getVariableName(Collections.singletonList(new TestObject()))).as("Incorrect plural List form").isEqualTo("testObjectList");
assertThat(Conventions.getVariableNameForParameter(getMethodParameter(List.class))).as("Incorrect plural List form").isEqualTo("testObjectList");
assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(List.class))).as("Incorrect plural List form").isEqualTo("testObjectList");
}
@Test
public void emptyList() {
void emptyList() {
assertThatIllegalArgumentException().isThrownBy(() ->
Conventions.getVariableName(new ArrayList<>()));
}
@Test
public void set() {
void set() {
assertThat(Conventions.getVariableName(Collections.singleton(new TestObject()))).as("Incorrect plural Set form").isEqualTo("testObjectList");
assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Set.class))).as("Incorrect plural Set form").isEqualTo("testObjectList");
assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Set.class))).as("Incorrect plural Set form").isEqualTo("testObjectList");
}
@Test
public void reactiveParameters() {
void reactiveParameters() {
assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Mono.class))).isEqualTo("testObjectMono");
assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Flux.class))).isEqualTo("testObjectFlux");
assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Single.class))).isEqualTo("testObjectSingle");
@ -85,7 +85,7 @@ public class ConventionsTests {
}
@Test
public void reactiveReturnTypes() {
void reactiveReturnTypes() {
assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Mono.class))).isEqualTo("testObjectMono");
assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Flux.class))).isEqualTo("testObjectFlux");
assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Single.class))).isEqualTo("testObjectSingle");
@ -93,14 +93,14 @@ public class ConventionsTests {
}
@Test
public void attributeNameToPropertyName() {
void attributeNameToPropertyName() {
assertThat(Conventions.attributeNameToPropertyName("transaction-manager")).isEqualTo("transactionManager");
assertThat(Conventions.attributeNameToPropertyName("pointcut-ref")).isEqualTo("pointcutRef");
assertThat(Conventions.attributeNameToPropertyName("lookup-on-startup")).isEqualTo("lookupOnStartup");
}
@Test
public void getQualifiedAttributeName() {
void getQualifiedAttributeName() {
String baseName = "foo";
Class<String> cls = String.class;
String desiredResult = "java.lang.String.foo";

View File

@ -27,58 +27,58 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Shepperd
*/
@SuppressWarnings("unchecked")
public class ExceptionDepthComparatorTests {
class ExceptionDepthComparatorTests {
@Test
public void targetBeforeSameDepth() throws Exception {
void targetBeforeSameDepth() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(TargetException.class, SameDepthException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
public void sameDepthBeforeTarget() throws Exception {
void sameDepthBeforeTarget() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(SameDepthException.class, TargetException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
public void lowestDepthBeforeTarget() throws Exception {
void lowestDepthBeforeTarget() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(LowestDepthException.class, TargetException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
public void targetBeforeLowestDepth() throws Exception {
void targetBeforeLowestDepth() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(TargetException.class, LowestDepthException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
public void noDepthBeforeTarget() throws Exception {
void noDepthBeforeTarget() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(NoDepthException.class, TargetException.class);
assertThat(foundClass).isEqualTo(TargetException.class);
}
@Test
public void noDepthBeforeHighestDepth() throws Exception {
void noDepthBeforeHighestDepth() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(NoDepthException.class, HighestDepthException.class);
assertThat(foundClass).isEqualTo(HighestDepthException.class);
}
@Test
public void highestDepthBeforeNoDepth() throws Exception {
void highestDepthBeforeNoDepth() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(HighestDepthException.class, NoDepthException.class);
assertThat(foundClass).isEqualTo(HighestDepthException.class);
}
@Test
public void highestDepthBeforeLowestDepth() throws Exception {
void highestDepthBeforeLowestDepth() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(HighestDepthException.class, LowestDepthException.class);
assertThat(foundClass).isEqualTo(LowestDepthException.class);
}
@Test
public void lowestDepthBeforeHighestDepth() throws Exception {
void lowestDepthBeforeHighestDepth() throws Exception {
Class<? extends Throwable> foundClass = findClosestMatch(LowestDepthException.class, HighestDepthException.class);
assertThat(foundClass).isEqualTo(LowestDepthException.class);
}

View File

@ -39,36 +39,36 @@ import static org.springframework.util.ReflectionUtils.findMethod;
* @author Sam Brannen
*/
@SuppressWarnings({"unchecked", "rawtypes"})
public class GenericTypeResolverTests {
class GenericTypeResolverTests {
@Test
public void simpleInterfaceType() {
void simpleInterfaceType() {
assertThat(resolveTypeArgument(MySimpleInterfaceType.class, MyInterfaceType.class)).isEqualTo(String.class);
}
@Test
public void simpleCollectionInterfaceType() {
void simpleCollectionInterfaceType() {
assertThat(resolveTypeArgument(MyCollectionInterfaceType.class, MyInterfaceType.class)).isEqualTo(Collection.class);
}
@Test
public void simpleSuperclassType() {
void simpleSuperclassType() {
assertThat(resolveTypeArgument(MySimpleSuperclassType.class, MySuperclassType.class)).isEqualTo(String.class);
}
@Test
public void simpleCollectionSuperclassType() {
void simpleCollectionSuperclassType() {
assertThat(resolveTypeArgument(MyCollectionSuperclassType.class, MySuperclassType.class)).isEqualTo(Collection.class);
}
@Test
public void nullIfNotResolvable() {
void nullIfNotResolvable() {
GenericClass<String> obj = new GenericClass<>();
assertThat((Object) resolveTypeArgument(obj.getClass(), GenericClass.class)).isNull();
}
@Test
public void methodReturnTypes() {
void methodReturnTypes() {
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class)).isEqualTo(Integer.class);
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class)).isEqualTo(String.class);
assertThat(resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class)).isEqualTo(null);
@ -76,7 +76,7 @@ public class GenericTypeResolverTests {
}
@Test
public void testResolveType() {
void testResolveType() {
Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class);
MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0);
assertThat(resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<>())).isEqualTo(MyInterfaceType.class);
@ -94,12 +94,12 @@ public class GenericTypeResolverTests {
}
@Test
public void testBoundParameterizedType() {
void boundParameterizedType() {
assertThat(resolveTypeArgument(TestImpl.class, TestIfc.class)).isEqualTo(B.class);
}
@Test
public void testGetTypeVariableMap() throws Exception {
void testGetTypeVariableMap() throws Exception {
Map<TypeVariable, Type> map;
map = GenericTypeResolver.getTypeVariableMap(MySimpleInterfaceType.class);
@ -137,19 +137,19 @@ public class GenericTypeResolverTests {
}
@Test // SPR-11030
public void getGenericsCannotBeResolved() throws Exception {
void getGenericsCannotBeResolved() throws Exception {
Class<?>[] resolved = GenericTypeResolver.resolveTypeArguments(List.class, Iterable.class);
assertThat((Object) resolved).isNull();
}
@Test // SPR-11052
public void getRawMapTypeCannotBeResolved() throws Exception {
void getRawMapTypeCannotBeResolved() throws Exception {
Class<?>[] resolved = GenericTypeResolver.resolveTypeArguments(Map.class, Map.class);
assertThat((Object) resolved).isNull();
}
@Test // SPR-11044
public void getGenericsOnArrayFromParamCannotBeResolved() throws Exception {
void getGenericsOnArrayFromParamCannotBeResolved() throws Exception {
MethodParameter methodParameter = MethodParameter.forExecutable(
WithArrayBase.class.getDeclaredMethod("array", Object[].class), 0);
Class<?> resolved = GenericTypeResolver.resolveParameterType(methodParameter, WithArray.class);
@ -157,14 +157,14 @@ public class GenericTypeResolverTests {
}
@Test // SPR-11044
public void getGenericsOnArrayFromReturnCannotBeResolved() throws Exception {
void getGenericsOnArrayFromReturnCannotBeResolved() throws Exception {
Class<?> resolved = GenericTypeResolver.resolveReturnType(
WithArrayBase.class.getDeclaredMethod("array", Object[].class), WithArray.class);
assertThat(resolved).isEqualTo(Object[].class);
}
@Test // SPR-11763
public void resolveIncompleteTypeVariables() {
void resolveIncompleteTypeVariables() {
Class<?>[] resolved = GenericTypeResolver.resolveTypeArguments(IdFixingRepository.class, Repository.class);
assertThat(resolved).isNotNull();
assertThat(resolved.length).isEqualTo(2);

View File

@ -32,13 +32,13 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Adrian Colyer
*/
public class LocalVariableTableParameterNameDiscovererTests {
class LocalVariableTableParameterNameDiscovererTests {
private final LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
@Test
public void methodParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
void methodParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
Method getName = TestObject.class.getMethod("getName");
String[] names = discoverer.getParameterNames(getName);
assertThat(names).as("should find method info").isNotNull();
@ -46,7 +46,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void methodParameterNameDiscoveryWithArgs() throws NoSuchMethodException {
void methodParameterNameDiscoveryWithArgs() throws NoSuchMethodException {
Method setName = TestObject.class.getMethod("setName", String.class);
String[] names = discoverer.getParameterNames(setName);
assertThat(names).as("should find method info").isNotNull();
@ -55,7 +55,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void consParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
void consParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
Constructor<TestObject> noArgsCons = TestObject.class.getConstructor();
String[] names = discoverer.getParameterNames(noArgsCons);
assertThat(names).as("should find cons info").isNotNull();
@ -63,7 +63,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void consParameterNameDiscoveryArgs() throws NoSuchMethodException {
void consParameterNameDiscoveryArgs() throws NoSuchMethodException {
Constructor<TestObject> twoArgCons = TestObject.class.getConstructor(String.class, int.class);
String[] names = discoverer.getParameterNames(twoArgCons);
assertThat(names).as("should find cons info").isNotNull();
@ -73,7 +73,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void staticMethodParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
void staticMethodParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
Method m = getClass().getMethod("staticMethodNoLocalVars");
String[] names = discoverer.getParameterNames(m);
assertThat(names).as("should find method info").isNotNull();
@ -81,7 +81,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void overloadedStaticMethod() throws Exception {
void overloadedStaticMethod() throws Exception {
Class<? extends LocalVariableTableParameterNameDiscovererTests> clazz = this.getClass();
Method m1 = clazz.getMethod("staticMethod", Long.TYPE, Long.TYPE);
@ -101,7 +101,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void overloadedStaticMethodInInnerClass() throws Exception {
void overloadedStaticMethodInInnerClass() throws Exception {
Class<InnerClass> clazz = InnerClass.class;
Method m1 = clazz.getMethod("staticMethod", Long.TYPE);
@ -119,7 +119,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void overloadedMethod() throws Exception {
void overloadedMethod() throws Exception {
Class<? extends LocalVariableTableParameterNameDiscovererTests> clazz = this.getClass();
Method m1 = clazz.getMethod("instanceMethod", Double.TYPE, Double.TYPE);
@ -139,7 +139,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void overloadedMethodInInnerClass() throws Exception {
void overloadedMethodInInnerClass() throws Exception {
Class<InnerClass> clazz = InnerClass.class;
Method m1 = clazz.getMethod("instanceMethod", String.class);
@ -157,7 +157,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
}
@Test
public void generifiedClass() throws Exception {
void generifiedClass() throws Exception {
Class<?> clazz = GenerifiedClass.class;
Constructor<?> ctor = clazz.getDeclaredConstructor(Object.class);
@ -205,7 +205,7 @@ public class LocalVariableTableParameterNameDiscovererTests {
@Disabled("Ignored because Ubuntu packages OpenJDK with debug symbols enabled. See SPR-8078.")
@Test
public void classesWithoutDebugSymbols() throws Exception {
void classesWithoutDebugSymbols() throws Exception {
// JDK classes don't have debug information (usually)
Class<Component> clazz = Component.class;
String methodName = "list";

View File

@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Sam Brannen
* @author Phillip Webb
*/
public class MethodParameterTests {
class MethodParameterTests {
private Method method;
@ -51,7 +51,7 @@ public class MethodParameterTests {
@BeforeEach
public void setup() throws NoSuchMethodException {
void setup() throws NoSuchMethodException {
method = getClass().getMethod("method", String.class, Long.TYPE);
stringParameter = new MethodParameter(method, 0);
longParameter = new MethodParameter(method, 1);
@ -60,7 +60,7 @@ public class MethodParameterTests {
@Test
public void testEquals() throws NoSuchMethodException {
void equals() throws NoSuchMethodException {
assertThat(stringParameter).isEqualTo(stringParameter);
assertThat(longParameter).isEqualTo(longParameter);
assertThat(intReturnType).isEqualTo(intReturnType);
@ -81,7 +81,7 @@ public class MethodParameterTests {
}
@Test
public void testHashCode() throws NoSuchMethodException {
void testHashCode() throws NoSuchMethodException {
assertThat(stringParameter.hashCode()).isEqualTo(stringParameter.hashCode());
assertThat(longParameter.hashCode()).isEqualTo(longParameter.hashCode());
assertThat(intReturnType.hashCode()).isEqualTo(intReturnType.hashCode());
@ -94,7 +94,7 @@ public class MethodParameterTests {
@Test
@SuppressWarnings("deprecation")
public void testFactoryMethods() {
void testFactoryMethods() {
assertThat(MethodParameter.forMethodOrConstructor(method, 0)).isEqualTo(stringParameter);
assertThat(MethodParameter.forMethodOrConstructor(method, 1)).isEqualTo(longParameter);
@ -106,13 +106,13 @@ public class MethodParameterTests {
}
@Test
public void testIndexValidation() {
void indexValidation() {
assertThatIllegalArgumentException().isThrownBy(() ->
new MethodParameter(method, 2));
}
@Test
public void annotatedConstructorParameterInStaticNestedClass() throws Exception {
void annotatedConstructorParameterInStaticNestedClass() throws Exception {
Constructor<?> constructor = NestedClass.class.getDeclaredConstructor(String.class);
MethodParameter methodParameter = MethodParameter.forExecutable(constructor, 0);
assertThat(methodParameter.getParameterType()).isEqualTo(String.class);
@ -120,7 +120,7 @@ public class MethodParameterTests {
}
@Test // SPR-16652
public void annotatedConstructorParameterInInnerClass() throws Exception {
void annotatedConstructorParameterInInnerClass() throws Exception {
Constructor<?> constructor = InnerClass.class.getConstructor(getClass(), String.class, Callable.class);
MethodParameter methodParameter = MethodParameter.forExecutable(constructor, 0);
@ -137,7 +137,7 @@ public class MethodParameterTests {
}
@Test // SPR-16734
public void genericConstructorParameterInInnerClass() throws Exception {
void genericConstructorParameterInInnerClass() throws Exception {
Constructor<?> constructor = InnerClass.class.getConstructor(getClass(), String.class, Callable.class);
MethodParameter methodParameter = MethodParameter.forExecutable(constructor, 0);
@ -155,7 +155,7 @@ public class MethodParameterTests {
@Test
@Deprecated
public void multipleResolveParameterTypeCalls() throws Exception {
void multipleResolveParameterTypeCalls() throws Exception {
Method method = ArrayList.class.getMethod("get", int.class);
MethodParameter methodParameter = MethodParameter.forExecutable(method, -1);
assertThat(methodParameter.getParameterType()).isEqualTo(Object.class);
@ -166,7 +166,7 @@ public class MethodParameterTests {
}
@Test
public void equalsAndHashCodeConsidersContainingClass() throws Exception {
void equalsAndHashCodeConsidersContainingClass() throws Exception {
Method method = ArrayList.class.getMethod("get", int.class);
MethodParameter m1 = MethodParameter.forExecutable(method, -1);
MethodParameter m2 = MethodParameter.forExecutable(method, -1);
@ -176,7 +176,7 @@ public class MethodParameterTests {
}
@Test
public void equalsAndHashCodeConsidersNesting() throws Exception {
void equalsAndHashCodeConsidersNesting() throws Exception {
Method method = ArrayList.class.getMethod("get", int.class);
MethodParameter m1 = MethodParameter.forExecutable(method, -1)
.withContainingClass(StringList.class);
@ -189,7 +189,8 @@ public class MethodParameterTests {
assertThat(m1.hashCode()).isEqualTo(m2.hashCode());
}
public void withContainingClassReturnsNewInstance() throws Exception {
@Test
void withContainingClassReturnsNewInstance() throws Exception {
Method method = ArrayList.class.getMethod("get", int.class);
MethodParameter m1 = MethodParameter.forExecutable(method, -1);
MethodParameter m2 = m1.withContainingClass(StringList.class);
@ -201,7 +202,7 @@ public class MethodParameterTests {
}
@Test
public void withTypeIndexReturnsNewInstance() throws Exception {
void withTypeIndexReturnsNewInstance() throws Exception {
Method method = ArrayList.class.getMethod("get", int.class);
MethodParameter m1 = MethodParameter.forExecutable(method, -1);
MethodParameter m2 = m1.withTypeIndex(2);
@ -214,7 +215,7 @@ public class MethodParameterTests {
@Test
@SuppressWarnings("deprecation")
public void mutatingNestingLevelShouldNotChangeNewInstance() throws Exception {
void mutatingNestingLevelShouldNotChangeNewInstance() throws Exception {
Method method = ArrayList.class.getMethod("get", int.class);
MethodParameter m1 = MethodParameter.forExecutable(method, -1);
MethodParameter m2 = m1.withTypeIndex(2);
@ -225,7 +226,7 @@ public class MethodParameterTests {
}
@Test
public void nestedWithTypeIndexReturnsNewInstance() throws Exception {
void nestedWithTypeIndexReturnsNewInstance() throws Exception {
Method method = ArrayList.class.getMethod("get", int.class);
MethodParameter m1 = MethodParameter.forExecutable(method, -1);
MethodParameter m2 = m1.nested(2);

View File

@ -28,10 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
*/
@SuppressWarnings("serial")
public class NestedExceptionTests {
class NestedExceptionTests {
@Test
public void nestedRuntimeExceptionWithNoRootCause() {
void nestedRuntimeExceptionWithNoRootCause() {
String mesg = "mesg of mine";
// Making a class abstract doesn't _really_ prevent instantiation :-)
NestedRuntimeException nex = new NestedRuntimeException(mesg) {};
@ -48,7 +48,7 @@ public class NestedExceptionTests {
}
@Test
public void nestedRuntimeExceptionWithRootCause() {
void nestedRuntimeExceptionWithRootCause() {
String myMessage = "mesg for this exception";
String rootCauseMsg = "this is the obscure message of the root cause";
Exception rootCause = new Exception(rootCauseMsg);
@ -69,7 +69,7 @@ public class NestedExceptionTests {
}
@Test
public void nestedCheckedExceptionWithNoRootCause() {
void nestedCheckedExceptionWithNoRootCause() {
String mesg = "mesg of mine";
// Making a class abstract doesn't _really_ prevent instantiation :-)
NestedCheckedException nex = new NestedCheckedException(mesg) {};
@ -86,7 +86,7 @@ public class NestedExceptionTests {
}
@Test
public void nestedCheckedExceptionWithRootCause() {
void nestedCheckedExceptionWithRootCause() {
String myMessage = "mesg for this exception";
String rootCauseMsg = "this is the obscure message of the root cause";
Exception rootCause = new Exception(rootCauseMsg);

View File

@ -30,73 +30,73 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Sam Brannen
*/
public class OrderComparatorTests {
class OrderComparatorTests {
private final OrderComparator comparator = new OrderComparator();
@Test
public void compareOrderedInstancesBefore() {
void compareOrderedInstancesBefore() {
assertThat(this.comparator.compare(new StubOrdered(100), new StubOrdered(2000))).isEqualTo(-1);
}
@Test
public void compareOrderedInstancesSame() {
void compareOrderedInstancesSame() {
assertThat(this.comparator.compare(new StubOrdered(100), new StubOrdered(100))).isEqualTo(0);
}
@Test
public void compareOrderedInstancesAfter() {
void compareOrderedInstancesAfter() {
assertThat(this.comparator.compare(new StubOrdered(982300), new StubOrdered(100))).isEqualTo(1);
}
@Test
public void compareOrderedInstancesNullFirst() {
void compareOrderedInstancesNullFirst() {
assertThat(this.comparator.compare(null, new StubOrdered(100))).isEqualTo(1);
}
@Test
public void compareOrderedInstancesNullLast() {
void compareOrderedInstancesNullLast() {
assertThat(this.comparator.compare(new StubOrdered(100), null)).isEqualTo(-1);
}
@Test
public void compareOrderedInstancesDoubleNull() {
void compareOrderedInstancesDoubleNull() {
assertThat(this.comparator.compare(null, null)).isEqualTo(0);
}
@Test
public void compareTwoNonOrderedInstancesEndsUpAsSame() {
void compareTwoNonOrderedInstancesEndsUpAsSame() {
assertThat(this.comparator.compare(new Object(), new Object())).isEqualTo(0);
}
@Test
public void comparePriorityOrderedInstancesBefore() {
void comparePriorityOrderedInstancesBefore() {
assertThat(this.comparator.compare(new StubPriorityOrdered(100), new StubPriorityOrdered(2000))).isEqualTo(-1);
}
@Test
public void comparePriorityOrderedInstancesSame() {
void comparePriorityOrderedInstancesSame() {
assertThat(this.comparator.compare(new StubPriorityOrdered(100), new StubPriorityOrdered(100))).isEqualTo(0);
}
@Test
public void comparePriorityOrderedInstancesAfter() {
void comparePriorityOrderedInstancesAfter() {
assertThat(this.comparator.compare(new StubPriorityOrdered(982300), new StubPriorityOrdered(100))).isEqualTo(1);
}
@Test
public void comparePriorityOrderedInstanceToStandardOrderedInstanceWithHigherPriority() {
void comparePriorityOrderedInstanceToStandardOrderedInstanceWithHigherPriority() {
assertThatPriorityOrderedAlwaysWins(new StubPriorityOrdered(200), new StubOrdered(100));
}
@Test
public void comparePriorityOrderedInstanceToStandardOrderedInstanceWithSamePriority() {
void comparePriorityOrderedInstanceToStandardOrderedInstanceWithSamePriority() {
assertThatPriorityOrderedAlwaysWins(new StubPriorityOrdered(100), new StubOrdered(100));
}
@Test
public void comparePriorityOrderedInstanceToStandardOrderedInstanceWithLowerPriority() {
void comparePriorityOrderedInstanceToStandardOrderedInstanceWithLowerPriority() {
assertThatPriorityOrderedAlwaysWins(new StubPriorityOrdered(100), new StubOrdered(200));
}
@ -106,28 +106,28 @@ public class OrderComparatorTests {
}
@Test
public void compareWithSimpleSourceProvider() {
void compareWithSimpleSourceProvider() {
Comparator<Object> customComparator = this.comparator.withSourceProvider(
new TestSourceProvider(5L, new StubOrdered(25)));
assertThat(customComparator.compare(new StubOrdered(10), 5L)).isEqualTo(-1);
}
@Test
public void compareWithSourceProviderArray() {
void compareWithSourceProviderArray() {
Comparator<Object> customComparator = this.comparator.withSourceProvider(
new TestSourceProvider(5L, new Object[] {new StubOrdered(10), new StubOrdered(-25)}));
assertThat(customComparator.compare(5L, new Object())).isEqualTo(-1);
}
@Test
public void compareWithSourceProviderArrayNoMatch() {
void compareWithSourceProviderArrayNoMatch() {
Comparator<Object> customComparator = this.comparator.withSourceProvider(
new TestSourceProvider(5L, new Object[] {new Object(), new Object()}));
assertThat(customComparator.compare(new Object(), 5L)).isEqualTo(0);
}
@Test
public void compareWithSourceProviderEmpty() {
void compareWithSourceProviderEmpty() {
Comparator<Object> customComparator = this.comparator.withSourceProvider(
new TestSourceProvider(50L, new Object()));
assertThat(customComparator.compare(new Object(), 5L)).isEqualTo(0);

View File

@ -30,37 +30,37 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Arjen Poutsma
* @author Rossen Stoyanchev
*/
public class ParameterizedTypeReferenceTests {
class ParameterizedTypeReferenceTests {
@Test
public void stringTypeReference() {
void stringTypeReference() {
ParameterizedTypeReference<String> typeReference = new ParameterizedTypeReference<String>() {};
assertThat(typeReference.getType()).isEqualTo(String.class);
}
@Test
public void mapTypeReference() throws Exception {
void mapTypeReference() throws Exception {
Type mapType = getClass().getMethod("mapMethod").getGenericReturnType();
ParameterizedTypeReference<Map<Object,String>> typeReference = new ParameterizedTypeReference<Map<Object,String>>() {};
assertThat(typeReference.getType()).isEqualTo(mapType);
}
@Test
public void listTypeReference() throws Exception {
void listTypeReference() throws Exception {
Type listType = getClass().getMethod("listMethod").getGenericReturnType();
ParameterizedTypeReference<List<String>> typeReference = new ParameterizedTypeReference<List<String>>() {};
assertThat(typeReference.getType()).isEqualTo(listType);
}
@Test
public void reflectiveTypeReferenceWithSpecificDeclaration() throws Exception{
void reflectiveTypeReferenceWithSpecificDeclaration() throws Exception{
Type listType = getClass().getMethod("listMethod").getGenericReturnType();
ParameterizedTypeReference<List<String>> typeReference = ParameterizedTypeReference.forType(listType);
assertThat(typeReference.getType()).isEqualTo(listType);
}
@Test
public void reflectiveTypeReferenceWithGenericDeclaration() throws Exception{
void reflectiveTypeReferenceWithGenericDeclaration() throws Exception{
Type listType = getClass().getMethod("listMethod").getGenericReturnType();
ParameterizedTypeReference<?> typeReference = ParameterizedTypeReference.forType(listType);
assertThat(typeReference.getType()).isEqualTo(listType);

View File

@ -26,7 +26,7 @@ import org.springframework.tests.sample.objects.TestObject;
import static org.assertj.core.api.Assertions.assertThat;
public class PrioritizedParameterNameDiscovererTests {
class PrioritizedParameterNameDiscovererTests {
private static final String[] FOO_BAR = new String[] { "foo", "bar" };
@ -61,14 +61,14 @@ public class PrioritizedParameterNameDiscovererTests {
}
@Test
public void noParametersDiscoverers() {
void noParametersDiscoverers() {
ParameterNameDiscoverer pnd = new PrioritizedParameterNameDiscoverer();
assertThat(pnd.getParameterNames(anyMethod)).isNull();
assertThat(pnd.getParameterNames((Constructor<?>) null)).isNull();
}
@Test
public void orderedParameterDiscoverers1() {
void orderedParameterDiscoverers1() {
PrioritizedParameterNameDiscoverer pnd = new PrioritizedParameterNameDiscoverer();
pnd.addDiscoverer(returnsFooBar);
assertThat(Arrays.equals(FOO_BAR, pnd.getParameterNames(anyMethod))).isTrue();
@ -79,7 +79,7 @@ public class PrioritizedParameterNameDiscovererTests {
}
@Test
public void orderedParameterDiscoverers2() {
void orderedParameterDiscoverers2() {
PrioritizedParameterNameDiscoverer pnd = new PrioritizedParameterNameDiscoverer();
pnd.addDiscoverer(returnsSomethingElse);
assertThat(Arrays.equals(SOMETHING_ELSE, pnd.getParameterNames(anyMethod))).isTrue();

View File

@ -40,13 +40,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Rossen Stoyanchev
*/
@SuppressWarnings("unchecked")
public class ReactiveAdapterRegistryTests {
class ReactiveAdapterRegistryTests {
private final ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance();
@Test
public void defaultAdapterRegistrations() {
void defaultAdapterRegistrations() {
// Reactor
assertThat(getAdapter(Mono.class)).isNotNull();
@ -75,7 +75,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void getAdapterForReactiveSubType() {
void getAdapterForReactiveSubType() {
ReactiveAdapter adapter1 = getAdapter(Flux.class);
ReactiveAdapter adapter2 = getAdapter(FluxProcessor.class);
@ -94,7 +94,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToFlux() {
void publisherToFlux() {
List<Integer> sequence = Arrays.asList(1, 2, 3);
Publisher<Integer> source = Flowable.fromIterable(sequence);
Object target = getAdapter(Flux.class).fromPublisher(source);
@ -106,7 +106,7 @@ public class ReactiveAdapterRegistryTests {
// TODO: publisherToMono/CompletableFuture vs Single (ISE on multiple elements)?
@Test
public void publisherToMono() {
void publisherToMono() {
Publisher<Integer> source = Flowable.fromArray(1, 2, 3);
Object target = getAdapter(Mono.class).fromPublisher(source);
boolean condition = target instanceof Mono;
@ -115,7 +115,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToCompletableFuture() throws Exception {
void publisherToCompletableFuture() throws Exception {
Publisher<Integer> source = Flowable.fromArray(1, 2, 3);
Object target = getAdapter(CompletableFuture.class).fromPublisher(source);
boolean condition = target instanceof CompletableFuture;
@ -124,7 +124,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToRxObservable() {
void publisherToRxObservable() {
List<Integer> sequence = Arrays.asList(1, 2, 3);
Publisher<Integer> source = Flowable.fromIterable(sequence);
Object target = getAdapter(rx.Observable.class).fromPublisher(source);
@ -134,7 +134,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToRxSingle() {
void publisherToRxSingle() {
Publisher<Integer> source = Flowable.fromArray(1);
Object target = getAdapter(rx.Single.class).fromPublisher(source);
boolean condition = target instanceof Single;
@ -143,7 +143,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToRxCompletable() {
void publisherToRxCompletable() {
Publisher<Integer> source = Flowable.fromArray(1, 2, 3);
Object target = getAdapter(rx.Completable.class).fromPublisher(source);
boolean condition = target instanceof Completable;
@ -152,7 +152,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToReactivexFlowable() {
void publisherToReactivexFlowable() {
List<Integer> sequence = Arrays.asList(1, 2, 3);
Publisher<Integer> source = Flux.fromIterable(sequence);
Object target = getAdapter(io.reactivex.Flowable.class).fromPublisher(source);
@ -162,7 +162,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToReactivexObservable() {
void publisherToReactivexObservable() {
List<Integer> sequence = Arrays.asList(1, 2, 3);
Publisher<Integer> source = Flowable.fromIterable(sequence);
Object target = getAdapter(io.reactivex.Observable.class).fromPublisher(source);
@ -172,7 +172,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToReactivexSingle() {
void publisherToReactivexSingle() {
Publisher<Integer> source = Flowable.fromArray(1);
Object target = getAdapter(io.reactivex.Single.class).fromPublisher(source);
boolean condition = target instanceof io.reactivex.Single;
@ -181,7 +181,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void publisherToReactivexCompletable() {
void publisherToReactivexCompletable() {
Publisher<Integer> source = Flowable.fromArray(1, 2, 3);
Object target = getAdapter(io.reactivex.Completable.class).fromPublisher(source);
boolean condition = target instanceof io.reactivex.Completable;
@ -190,7 +190,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void rxObservableToPublisher() {
void rxObservableToPublisher() {
List<Integer> sequence = Arrays.asList(1, 2, 3);
Object source = rx.Observable.from(sequence);
Object target = getAdapter(rx.Observable.class).toPublisher(source);
@ -200,7 +200,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void rxSingleToPublisher() {
void rxSingleToPublisher() {
Object source = rx.Single.just(1);
Object target = getAdapter(rx.Single.class).toPublisher(source);
boolean condition = target instanceof Mono;
@ -209,7 +209,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void rxCompletableToPublisher() {
void rxCompletableToPublisher() {
Object source = rx.Completable.complete();
Object target = getAdapter(rx.Completable.class).toPublisher(source);
boolean condition = target instanceof Mono;
@ -218,7 +218,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void reactivexFlowableToPublisher() {
void reactivexFlowableToPublisher() {
List<Integer> sequence = Arrays.asList(1, 2, 3);
Object source = io.reactivex.Flowable.fromIterable(sequence);
Object target = getAdapter(io.reactivex.Flowable.class).toPublisher(source);
@ -228,7 +228,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void reactivexObservableToPublisher() {
void reactivexObservableToPublisher() {
List<Integer> sequence = Arrays.asList(1, 2, 3);
Object source = io.reactivex.Observable.fromIterable(sequence);
Object target = getAdapter(io.reactivex.Observable.class).toPublisher(source);
@ -238,7 +238,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void reactivexSingleToPublisher() {
void reactivexSingleToPublisher() {
Object source = io.reactivex.Single.just(1);
Object target = getAdapter(io.reactivex.Single.class).toPublisher(source);
boolean condition = target instanceof Mono;
@ -247,7 +247,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void reactivexCompletableToPublisher() {
void reactivexCompletableToPublisher() {
Object source = io.reactivex.Completable.complete();
Object target = getAdapter(io.reactivex.Completable.class).toPublisher(source);
boolean condition = target instanceof Mono;
@ -256,7 +256,7 @@ public class ReactiveAdapterRegistryTests {
}
@Test
public void CompletableFutureToPublisher() {
void completableFutureToPublisher() {
CompletableFuture<Integer> future = new CompletableFuture<>();
future.complete(1);
Object target = getAdapter(CompletableFuture.class).toPublisher(future);

View File

@ -38,17 +38,17 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
public class SerializableTypeWrapperTests {
class SerializableTypeWrapperTests {
@Test
public void forField() throws Exception {
void forField() throws Exception {
Type type = SerializableTypeWrapper.forField(Fields.class.getField("parameterizedType"));
assertThat(type.toString()).isEqualTo("java.util.List<java.lang.String>");
assertSerializable(type);
}
@Test
public void forMethodParameter() throws Exception {
void forMethodParameter() throws Exception {
Method method = Methods.class.getDeclaredMethod("method", Class.class, Object.class);
Type type = SerializableTypeWrapper.forMethodParameter(MethodParameter.forExecutable(method, 0));
assertThat(type.toString()).isEqualTo("java.lang.Class<T>");
@ -56,7 +56,7 @@ public class SerializableTypeWrapperTests {
}
@Test
public void forConstructor() throws Exception {
void forConstructor() throws Exception {
Constructor<?> constructor = Constructors.class.getDeclaredConstructor(List.class);
Type type = SerializableTypeWrapper.forMethodParameter(MethodParameter.forExecutable(constructor, 0));
assertThat(type.toString()).isEqualTo("java.util.List<java.lang.String>");
@ -64,14 +64,14 @@ public class SerializableTypeWrapperTests {
}
@Test
public void classType() throws Exception {
void classType() throws Exception {
Type type = SerializableTypeWrapper.forField(Fields.class.getField("classType"));
assertThat(type.toString()).isEqualTo("class java.lang.String");
assertSerializable(type);
}
@Test
public void genericArrayType() throws Exception {
void genericArrayType() throws Exception {
GenericArrayType type = (GenericArrayType) SerializableTypeWrapper.forField(Fields.class.getField("genericArrayType"));
assertThat(type.toString()).isEqualTo("java.util.List<java.lang.String>[]");
assertSerializable(type);
@ -79,7 +79,7 @@ public class SerializableTypeWrapperTests {
}
@Test
public void parameterizedType() throws Exception {
void parameterizedType() throws Exception {
ParameterizedType type = (ParameterizedType) SerializableTypeWrapper.forField(Fields.class.getField("parameterizedType"));
assertThat(type.toString()).isEqualTo("java.util.List<java.lang.String>");
assertSerializable(type);
@ -90,7 +90,7 @@ public class SerializableTypeWrapperTests {
}
@Test
public void typeVariableType() throws Exception {
void typeVariableType() throws Exception {
TypeVariable<?> type = (TypeVariable<?>) SerializableTypeWrapper.forField(Fields.class.getField("typeVariableType"));
assertThat(type.toString()).isEqualTo("T");
assertSerializable(type);
@ -98,7 +98,7 @@ public class SerializableTypeWrapperTests {
}
@Test
public void wildcardType() throws Exception {
void wildcardType() throws Exception {
ParameterizedType typeSource = (ParameterizedType) SerializableTypeWrapper.forField(Fields.class.getField("wildcardType"));
WildcardType type = (WildcardType) typeSource.getActualTypeArguments()[0];
assertThat(type.toString()).isEqualTo("? extends java.lang.CharSequence");

View File

@ -23,10 +23,10 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Juergen Hoeller
*/
public class SimpleAliasRegistryTests {
class SimpleAliasRegistryTests {
@Test
public void testAliasChaining() {
void aliasChaining() {
SimpleAliasRegistry registry = new SimpleAliasRegistry();
registry.registerAlias("test", "testAlias");
registry.registerAlias("testAlias", "testAlias2");
@ -41,7 +41,7 @@ public class SimpleAliasRegistryTests {
}
@Test // SPR-17191
public void testAliasChainingWithMultipleAliases() {
void testAliasChainingWithMultipleAliases() {
SimpleAliasRegistry registry = new SimpleAliasRegistry();
registry.registerAlias("name", "alias_a");
registry.registerAlias("name", "alias_b");

View File

@ -35,40 +35,40 @@ import static org.assertj.core.api.Assertions.entry;
* @author Sam Brannen
* @since 5.2
*/
public class SortedPropertiesTests {
class SortedPropertiesTests {
@Test
public void keys() {
void keys() {
assertKeys(createSortedProps());
}
@Test
public void keysFromPrototype() {
void keysFromPrototype() {
assertKeys(createSortedPropsFromPrototype());
}
@Test
public void keySet() {
void keySet() {
assertKeySet(createSortedProps());
}
@Test
public void keySetFromPrototype() {
void keySetFromPrototype() {
assertKeySet(createSortedPropsFromPrototype());
}
@Test
public void entrySet() {
void entrySet() {
assertEntrySet(createSortedProps());
}
@Test
public void entrySetFromPrototype() {
void entrySetFromPrototype() {
assertEntrySet(createSortedPropsFromPrototype());
}
@Test
public void sortsPropertiesUsingOutputStream() throws IOException {
void sortsPropertiesUsingOutputStream() throws IOException {
SortedProperties sortedProperties = createSortedProps();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -83,7 +83,7 @@ public class SortedPropertiesTests {
}
@Test
public void sortsPropertiesUsingWriter() throws IOException {
void sortsPropertiesUsingWriter() throws IOException {
SortedProperties sortedProperties = createSortedProps();
StringWriter writer = new StringWriter();
@ -98,7 +98,7 @@ public class SortedPropertiesTests {
}
@Test
public void sortsPropertiesAndOmitsCommentsUsingOutputStream() throws IOException {
void sortsPropertiesAndOmitsCommentsUsingOutputStream() throws IOException {
SortedProperties sortedProperties = createSortedProps(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -111,7 +111,7 @@ public class SortedPropertiesTests {
}
@Test
public void sortsPropertiesAndOmitsCommentsUsingWriter() throws IOException {
void sortsPropertiesAndOmitsCommentsUsingWriter() throws IOException {
SortedProperties sortedProperties = createSortedProps(true);
StringWriter writer = new StringWriter();
@ -124,7 +124,7 @@ public class SortedPropertiesTests {
}
@Test
public void storingAsXmlSortsPropertiesAndOmitsComments() throws IOException {
void storingAsXmlSortsPropertiesAndOmitsComments() throws IOException {
SortedProperties sortedProperties = createSortedProps(true);
ByteArrayOutputStream baos = new ByteArrayOutputStream();

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.core;
import java.lang.reflect.Method;
@ -24,22 +25,22 @@ import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for StandardReflectionParameterNameDiscoverer
*
* @author Rob Winch
*/
public class StandardReflectionParameterNameDiscoverTests {
class StandardReflectionParameterNameDiscoverTests {
private ParameterNameDiscoverer parameterNameDiscoverer;
@BeforeEach
public void setup() {
void setup() {
parameterNameDiscoverer = new StandardReflectionParameterNameDiscoverer();
}
@Test
public void getParameterNamesOnInterface() {
void getParameterNamesOnInterface() {
Method method = ReflectionUtils.findMethod(MessageService.class,"sendMessage", String.class);
String[] actualParams = parameterNameDiscoverer.getParameterNames(method);
assertThat(actualParams).isEqualTo(new String[]{"message"});
@ -48,4 +49,5 @@ public class StandardReflectionParameterNameDiscoverTests {
public interface MessageService {
void sendMessage(String message);
}
}

View File

@ -76,19 +76,19 @@ import static org.springframework.core.annotation.AnnotationUtilsTests.asArray;
* @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests
* @see ComposedRepeatableAnnotationsTests
*/
public class AnnotatedElementUtilsTests {
class AnnotatedElementUtilsTests {
private static final String TX_NAME = Transactional.class.getName();
@Test
public void getMetaAnnotationTypesOnNonAnnotatedClass() {
void getMetaAnnotationTypesOnNonAnnotatedClass() {
assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class).isEmpty()).isTrue();
assertThat(getMetaAnnotationTypes(NonAnnotatedClass.class, TransactionalComponent.class.getName()).isEmpty()).isTrue();
}
@Test
public void getMetaAnnotationTypesOnClassWithMetaDepth1() {
void getMetaAnnotationTypesOnClassWithMetaDepth1() {
Set<String> names = getMetaAnnotationTypes(TransactionalComponentClass.class, TransactionalComponent.class);
assertThat(names).isEqualTo(names(Transactional.class, Component.class, Indexed.class));
@ -97,7 +97,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMetaAnnotationTypesOnClassWithMetaDepth2() {
void getMetaAnnotationTypesOnClassWithMetaDepth2() {
Set<String> names = getMetaAnnotationTypes(ComposedTransactionalComponentClass.class, ComposedTransactionalComponent.class);
assertThat(names).isEqualTo(names(TransactionalComponent.class, Transactional.class, Component.class, Indexed.class));
@ -110,35 +110,35 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void hasMetaAnnotationTypesOnNonAnnotatedClass() {
void hasMetaAnnotationTypesOnNonAnnotatedClass() {
assertThat(hasMetaAnnotationTypes(NonAnnotatedClass.class, TX_NAME)).isFalse();
}
@Test
public void hasMetaAnnotationTypesOnClassWithMetaDepth0() {
void hasMetaAnnotationTypesOnClassWithMetaDepth0() {
assertThat(hasMetaAnnotationTypes(TransactionalComponentClass.class, TransactionalComponent.class.getName())).isFalse();
}
@Test
public void hasMetaAnnotationTypesOnClassWithMetaDepth1() {
void hasMetaAnnotationTypesOnClassWithMetaDepth1() {
assertThat(hasMetaAnnotationTypes(TransactionalComponentClass.class, TX_NAME)).isTrue();
assertThat(hasMetaAnnotationTypes(TransactionalComponentClass.class, Component.class.getName())).isTrue();
}
@Test
public void hasMetaAnnotationTypesOnClassWithMetaDepth2() {
void hasMetaAnnotationTypesOnClassWithMetaDepth2() {
assertThat(hasMetaAnnotationTypes(ComposedTransactionalComponentClass.class, TX_NAME)).isTrue();
assertThat(hasMetaAnnotationTypes(ComposedTransactionalComponentClass.class, Component.class.getName())).isTrue();
assertThat(hasMetaAnnotationTypes(ComposedTransactionalComponentClass.class, ComposedTransactionalComponent.class.getName())).isFalse();
}
@Test
public void isAnnotatedOnNonAnnotatedClass() {
void isAnnotatedOnNonAnnotatedClass() {
assertThat(isAnnotated(NonAnnotatedClass.class, Transactional.class)).isFalse();
}
@Test
public void isAnnotatedOnClassWithMetaDepth() {
void isAnnotatedOnClassWithMetaDepth() {
assertThat(isAnnotated(TransactionalComponentClass.class, TransactionalComponent.class)).isTrue();
assertThat(isAnnotated(SubTransactionalComponentClass.class, TransactionalComponent.class)).as("isAnnotated() does not search the class hierarchy.").isFalse();
assertThat(isAnnotated(TransactionalComponentClass.class, Transactional.class)).isTrue();
@ -149,7 +149,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void isAnnotatedForPlainTypes() {
void isAnnotatedForPlainTypes() {
assertThat(isAnnotated(Order.class, Documented.class)).isTrue();
assertThat(isAnnotated(NonNullApi.class, Documented.class)).isTrue();
assertThat(isAnnotated(NonNullApi.class, Nonnull.class)).isTrue();
@ -157,12 +157,12 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void isAnnotatedWithNameOnNonAnnotatedClass() {
void isAnnotatedWithNameOnNonAnnotatedClass() {
assertThat(isAnnotated(NonAnnotatedClass.class, TX_NAME)).isFalse();
}
@Test
public void isAnnotatedWithNameOnClassWithMetaDepth() {
void isAnnotatedWithNameOnClassWithMetaDepth() {
assertThat(isAnnotated(TransactionalComponentClass.class, TransactionalComponent.class.getName())).isTrue();
assertThat(isAnnotated(SubTransactionalComponentClass.class, TransactionalComponent.class.getName())).as("isAnnotated() does not search the class hierarchy.").isFalse();
assertThat(isAnnotated(TransactionalComponentClass.class, TX_NAME)).isTrue();
@ -173,12 +173,12 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void hasAnnotationOnNonAnnotatedClass() {
void hasAnnotationOnNonAnnotatedClass() {
assertThat(hasAnnotation(NonAnnotatedClass.class, Transactional.class)).isFalse();
}
@Test
public void hasAnnotationOnClassWithMetaDepth() {
void hasAnnotationOnClassWithMetaDepth() {
assertThat(hasAnnotation(TransactionalComponentClass.class, TransactionalComponent.class)).isTrue();
assertThat(hasAnnotation(SubTransactionalComponentClass.class, TransactionalComponent.class)).isTrue();
assertThat(hasAnnotation(TransactionalComponentClass.class, Transactional.class)).isTrue();
@ -189,7 +189,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void hasAnnotationForPlainTypes() {
void hasAnnotationForPlainTypes() {
assertThat(hasAnnotation(Order.class, Documented.class)).isTrue();
assertThat(hasAnnotation(NonNullApi.class, Documented.class)).isTrue();
assertThat(hasAnnotation(NonNullApi.class, Nonnull.class)).isTrue();
@ -197,33 +197,33 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getAllAnnotationAttributesOnNonAnnotatedClass() {
void getAllAnnotationAttributesOnNonAnnotatedClass() {
assertThat(getAllAnnotationAttributes(NonAnnotatedClass.class, TX_NAME)).isNull();
}
@Test
public void getAllAnnotationAttributesOnClassWithLocalAnnotation() {
void getAllAnnotationAttributesOnClassWithLocalAnnotation() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(TxConfig.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on TxConfig").isNotNull();
assertThat(attributes.get("value")).as("value for TxConfig").isEqualTo(asList("TxConfig"));
}
@Test
public void getAllAnnotationAttributesOnClassWithLocalComposedAnnotationAndInheritedAnnotation() {
void getAllAnnotationAttributesOnClassWithLocalComposedAnnotationAndInheritedAnnotation() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(SubClassWithInheritedAnnotation.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on SubClassWithInheritedAnnotation").isNotNull();
assertThat(attributes.get("qualifier")).isEqualTo(asList("composed2", "transactionManager"));
}
@Test
public void getAllAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
void getAllAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(SubSubClassWithInheritedAnnotation.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on SubSubClassWithInheritedAnnotation").isNotNull();
assertThat(attributes.get("qualifier")).isEqualTo(asList("transactionManager"));
}
@Test
public void getAllAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
void getAllAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes( SubSubClassWithInheritedComposedAnnotation.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on SubSubClassWithInheritedComposedAnnotation").isNotNull();
assertThat(attributes.get("qualifier")).isEqualTo(asList("composed1"));
@ -237,7 +237,7 @@ public class AnnotatedElementUtilsTests {
* to fail.
*/
@Test
public void getAllAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() {
void getAllAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() {
// See org.springframework.core.env.EnvironmentSystemIntegrationTests#mostSpecificDerivedClassDrivesEnvironment_withDevEnvAndDerivedDevConfigClass
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(DerivedTxConfig.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on DerivedTxConfig").isNotNull();
@ -248,7 +248,7 @@ public class AnnotatedElementUtilsTests {
* Note: this functionality is required by {@code org.springframework.context.annotation.ProfileCondition}.
*/
@Test
public void getAllAnnotationAttributesOnClassWithMultipleComposedAnnotations() {
void getAllAnnotationAttributesOnClassWithMultipleComposedAnnotations() {
// See org.springframework.core.env.EnvironmentSystemIntegrationTests
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(TxFromMultipleComposedAnnotations.class, TX_NAME);
assertThat(attributes).as("Annotation attributes map for @Transactional on TxFromMultipleComposedAnnotations").isNotNull();
@ -256,7 +256,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getAllAnnotationAttributesOnLangType() {
void getAllAnnotationAttributesOnLangType() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(
NonNullApi.class, Nonnull.class.getName());
assertThat(attributes).as("Annotation attributes map for @Nonnull on NonNullApi").isNotNull();
@ -264,7 +264,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getAllAnnotationAttributesOnJavaxType() {
void getAllAnnotationAttributesOnJavaxType() {
MultiValueMap<String, Object> attributes = getAllAnnotationAttributes(
ParametersAreNonnullByDefault.class, Nonnull.class.getName());
assertThat(attributes).as("Annotation attributes map for @Nonnull on NonNullApi").isNotNull();
@ -272,7 +272,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesOnClassWithLocalAnnotation() {
void getMergedAnnotationAttributesOnClassWithLocalAnnotation() {
Class<?> element = TxConfig.class;
String name = TX_NAME;
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -283,7 +283,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() {
void getMergedAnnotationAttributesOnClassWithLocalAnnotationThatShadowsAnnotationFromSuperclass() {
Class<?> element = DerivedTxConfig.class;
String name = TX_NAME;
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -294,13 +294,13 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
void getMergedAnnotationAttributesOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
AnnotationAttributes attributes = getMergedAnnotationAttributes(MetaCycleAnnotatedClass.class, TX_NAME);
assertThat(attributes).as("Should not find annotation attributes for @Transactional on MetaCycleAnnotatedClass").isNull();
}
@Test
public void getMergedAnnotationAttributesFavorsLocalComposedAnnotationOverInheritedAnnotation() {
void getMergedAnnotationAttributesFavorsLocalComposedAnnotationOverInheritedAnnotation() {
Class<?> element = SubClassWithInheritedAnnotation.class;
String name = TX_NAME;
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -311,7 +311,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
void getMergedAnnotationAttributesFavorsInheritedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
Class<?> element = SubSubClassWithInheritedAnnotation.class;
String name = TX_NAME;
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -322,7 +322,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
void getMergedAnnotationAttributesFavorsInheritedComposedAnnotationsOverMoreLocallyDeclaredComposedAnnotations() {
Class<?> element = SubSubClassWithInheritedComposedAnnotation.class;
String name = TX_NAME;
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -333,7 +333,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesFromInterfaceImplementedBySuperclass() {
void getMergedAnnotationAttributesFromInterfaceImplementedBySuperclass() {
Class<?> element = ConcreteClassWithInheritedAnnotation.class;
String name = TX_NAME;
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -343,7 +343,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesOnInheritedAnnotationInterface() {
void getMergedAnnotationAttributesOnInheritedAnnotationInterface() {
Class<?> element = InheritedAnnotationInterface.class;
String name = TX_NAME;
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -353,7 +353,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesOnNonInheritedAnnotationInterface() {
void getMergedAnnotationAttributesOnNonInheritedAnnotationInterface() {
Class<?> element = NonInheritedAnnotationInterface.class;
String name = Order.class.getName();
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -363,7 +363,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesWithConventionBasedComposedAnnotation() {
void getMergedAnnotationAttributesWithConventionBasedComposedAnnotation() {
Class<?> element = ConventionBasedComposedContextConfigClass.class;
String name = ContextConfig.class.getName();
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -386,7 +386,7 @@ public class AnnotatedElementUtilsTests {
*/
@Disabled("Permanently disabled but left in place for illustrative purposes")
@Test
public void getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation() {
void getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation() {
for (Class<?> clazz : asList(HalfConventionBasedAndHalfAliasedComposedContextConfigClassV1.class,
HalfConventionBasedAndHalfAliasedComposedContextConfigClassV2.class)) {
getMergedAnnotationAttributesWithHalfConventionBasedAndHalfAliasedComposedAnnotation(clazz);
@ -408,7 +408,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesWithAliasedComposedAnnotation() {
void getMergedAnnotationAttributesWithAliasedComposedAnnotation() {
Class<?> element = AliasedComposedContextConfigClass.class;
String name = ContextConfig.class.getName();
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -422,7 +422,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesWithAliasedValueComposedAnnotation() {
void getMergedAnnotationAttributesWithAliasedValueComposedAnnotation() {
Class<?> element = AliasedValueComposedContextConfigClass.class;
String name = ContextConfig.class.getName();
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -436,7 +436,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() {
void getMergedAnnotationAttributesWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() {
Class<?> element = ComposedImplicitAliasesContextConfigClass.class;
String name = ImplicitAliasesContextConfig.class.getName();
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, name);
@ -453,34 +453,34 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationWithAliasedValueComposedAnnotation() {
void getMergedAnnotationWithAliasedValueComposedAnnotation() {
assertGetMergedAnnotation(AliasedValueComposedContextConfigClass.class, "test.xml");
}
@Test
public void getMergedAnnotationWithImplicitAliasesForSameAttributeInComposedAnnotation() {
void getMergedAnnotationWithImplicitAliasesForSameAttributeInComposedAnnotation() {
assertGetMergedAnnotation(ImplicitAliasesContextConfigClass1.class, "foo.xml");
assertGetMergedAnnotation(ImplicitAliasesContextConfigClass2.class, "bar.xml");
assertGetMergedAnnotation(ImplicitAliasesContextConfigClass3.class, "baz.xml");
}
@Test
public void getMergedAnnotationWithTransitiveImplicitAliases() {
void getMergedAnnotationWithTransitiveImplicitAliases() {
assertGetMergedAnnotation(TransitiveImplicitAliasesContextConfigClass.class, "test.groovy");
}
@Test
public void getMergedAnnotationWithTransitiveImplicitAliasesWithSingleElementOverridingAnArrayViaAliasFor() {
void getMergedAnnotationWithTransitiveImplicitAliasesWithSingleElementOverridingAnArrayViaAliasFor() {
assertGetMergedAnnotation(SingleLocationTransitiveImplicitAliasesContextConfigClass.class, "test.groovy");
}
@Test
public void getMergedAnnotationWithTransitiveImplicitAliasesWithSkippedLevel() {
void getMergedAnnotationWithTransitiveImplicitAliasesWithSkippedLevel() {
assertGetMergedAnnotation(TransitiveImplicitAliasesWithSkippedLevelContextConfigClass.class, "test.xml");
}
@Test
public void getMergedAnnotationWithTransitiveImplicitAliasesWithSkippedLevelWithSingleElementOverridingAnArrayViaAliasFor() {
void getMergedAnnotationWithTransitiveImplicitAliasesWithSkippedLevelWithSingleElementOverridingAnArrayViaAliasFor() {
assertGetMergedAnnotation(SingleLocationTransitiveImplicitAliasesWithSkippedLevelContextConfigClass.class, "test.xml");
}
@ -499,7 +499,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() {
void getMergedAnnotationWithImplicitAliasesInMetaAnnotationOnComposedAnnotation() {
Class<?> element = ComposedImplicitAliasesContextConfigClass.class;
String name = ImplicitAliasesContextConfig.class.getName();
ImplicitAliasesContextConfig config = getMergedAnnotation(element, ImplicitAliasesContextConfig.class);
@ -516,7 +516,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesWithInvalidConventionBasedComposedAnnotation() {
void getMergedAnnotationAttributesWithInvalidConventionBasedComposedAnnotation() {
Class<?> element = InvalidConventionBasedComposedContextConfigClass.class;
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
getMergedAnnotationAttributes(element, ContextConfig.class))
@ -526,7 +526,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void getMergedAnnotationAttributesWithShadowedAliasComposedAnnotation() {
void getMergedAnnotationAttributesWithShadowedAliasComposedAnnotation() {
Class<?> element = ShadowedAliasComposedContextConfigClass.class;
AnnotationAttributes attributes = getMergedAnnotationAttributes(element, ContextConfig.class);
@ -538,57 +538,57 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void findMergedAnnotationAttributesOnInheritedAnnotationInterface() {
void findMergedAnnotationAttributesOnInheritedAnnotationInterface() {
AnnotationAttributes attributes = findMergedAnnotationAttributes(InheritedAnnotationInterface.class, Transactional.class);
assertThat(attributes).as("Should find @Transactional on InheritedAnnotationInterface").isNotNull();
}
@Test
public void findMergedAnnotationAttributesOnSubInheritedAnnotationInterface() {
void findMergedAnnotationAttributesOnSubInheritedAnnotationInterface() {
AnnotationAttributes attributes = findMergedAnnotationAttributes(SubInheritedAnnotationInterface.class, Transactional.class);
assertThat(attributes).as("Should find @Transactional on SubInheritedAnnotationInterface").isNotNull();
}
@Test
public void findMergedAnnotationAttributesOnSubSubInheritedAnnotationInterface() {
void findMergedAnnotationAttributesOnSubSubInheritedAnnotationInterface() {
AnnotationAttributes attributes = findMergedAnnotationAttributes(SubSubInheritedAnnotationInterface.class, Transactional.class);
assertThat(attributes).as("Should find @Transactional on SubSubInheritedAnnotationInterface").isNotNull();
}
@Test
public void findMergedAnnotationAttributesOnNonInheritedAnnotationInterface() {
void findMergedAnnotationAttributesOnNonInheritedAnnotationInterface() {
AnnotationAttributes attributes = findMergedAnnotationAttributes(NonInheritedAnnotationInterface.class, Order.class);
assertThat(attributes).as("Should find @Order on NonInheritedAnnotationInterface").isNotNull();
}
@Test
public void findMergedAnnotationAttributesOnSubNonInheritedAnnotationInterface() {
void findMergedAnnotationAttributesOnSubNonInheritedAnnotationInterface() {
AnnotationAttributes attributes = findMergedAnnotationAttributes(SubNonInheritedAnnotationInterface.class, Order.class);
assertThat(attributes).as("Should find @Order on SubNonInheritedAnnotationInterface").isNotNull();
}
@Test
public void findMergedAnnotationAttributesOnSubSubNonInheritedAnnotationInterface() {
void findMergedAnnotationAttributesOnSubSubNonInheritedAnnotationInterface() {
AnnotationAttributes attributes = findMergedAnnotationAttributes(SubSubNonInheritedAnnotationInterface.class, Order.class);
assertThat(attributes).as("Should find @Order on SubSubNonInheritedAnnotationInterface").isNotNull();
}
@Test
public void findMergedAnnotationAttributesInheritedFromInterfaceMethod() throws NoSuchMethodException {
void findMergedAnnotationAttributesInheritedFromInterfaceMethod() throws NoSuchMethodException {
Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handleFromInterface");
AnnotationAttributes attributes = findMergedAnnotationAttributes(method, Order.class);
assertThat(attributes).as("Should find @Order on ConcreteClassWithInheritedAnnotation.handleFromInterface() method").isNotNull();
}
@Test
public void findMergedAnnotationAttributesInheritedFromAbstractMethod() throws NoSuchMethodException {
void findMergedAnnotationAttributesInheritedFromAbstractMethod() throws NoSuchMethodException {
Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handle");
AnnotationAttributes attributes = findMergedAnnotationAttributes(method, Transactional.class);
assertThat(attributes).as("Should find @Transactional on ConcreteClassWithInheritedAnnotation.handle() method").isNotNull();
}
@Test
public void findMergedAnnotationAttributesInheritedFromBridgedMethod() throws NoSuchMethodException {
void findMergedAnnotationAttributesInheritedFromBridgedMethod() throws NoSuchMethodException {
Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handleParameterized", String.class);
AnnotationAttributes attributes = findMergedAnnotationAttributes(method, Transactional.class);
assertThat(attributes).as("Should find @Transactional on bridged ConcreteClassWithInheritedAnnotation.handleParameterized()").isNotNull();
@ -600,7 +600,7 @@ public class AnnotatedElementUtilsTests {
* @since 4.2
*/
@Test
public void findMergedAnnotationAttributesFromBridgeMethod() {
void findMergedAnnotationAttributesFromBridgeMethod() {
Method[] methods = StringGenericParameter.class.getMethods();
Method bridgeMethod = null;
Method bridgedMethod = null;
@ -624,14 +624,14 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void findMergedAnnotationAttributesOnClassWithMetaAndLocalTxConfig() {
void findMergedAnnotationAttributesOnClassWithMetaAndLocalTxConfig() {
AnnotationAttributes attributes = findMergedAnnotationAttributes(MetaAndLocalTxConfigClass.class, Transactional.class);
assertThat(attributes).as("Should find @Transactional on MetaAndLocalTxConfigClass").isNotNull();
assertThat(attributes.getString("qualifier")).as("TX qualifier for MetaAndLocalTxConfigClass.").isEqualTo("localTxMgr");
}
@Test
public void findAndSynthesizeAnnotationAttributesOnClassWithAttributeAliasesInTargetAnnotation() {
void findAndSynthesizeAnnotationAttributesOnClassWithAttributeAliasesInTargetAnnotation() {
String qualifier = "aliasForQualifier";
// 1) Find and merge AnnotationAttributes from the annotation hierarchy
@ -652,7 +652,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void findMergedAnnotationAttributesOnClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() {
void findMergedAnnotationAttributesOnClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() {
AnnotationAttributes attributes = assertComponentScanAttributes(TestComponentScanClass.class, "com.example.app.test");
Filter[] excludeFilters = attributes.getAnnotationArray("excludeFilters", Filter.class);
@ -668,17 +668,17 @@ public class AnnotatedElementUtilsTests {
* attributes since attributes may be arrays.
*/
@Test
public void findMergedAnnotationAttributesOnClassWithBothAttributesOfAnAliasPairDeclared() {
void findMergedAnnotationAttributesOnClassWithBothAttributesOfAnAliasPairDeclared() {
assertComponentScanAttributes(ComponentScanWithBasePackagesAndValueAliasClass.class, "com.example.app.test");
}
@Test
public void findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaConvention() {
void findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaConvention() {
assertComponentScanAttributes(ConventionBasedSinglePackageComponentScanClass.class, "com.example.app.test");
}
@Test
public void findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaAliasFor() {
void findMergedAnnotationAttributesWithSingleElementOverridingAnArrayViaAliasFor() {
assertComponentScanAttributes(AliasForBasedSinglePackageComponentScanClass.class, "com.example.app.test");
}
@ -697,7 +697,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void findMergedAnnotationWithAttributeAliasesInTargetAnnotation() {
void findMergedAnnotationWithAttributeAliasesInTargetAnnotation() {
Class<?> element = AliasedTransactionalComponentClass.class;
AliasedTransactional annotation = findMergedAnnotation(element, AliasedTransactional.class);
assertThat(annotation).as("@AliasedTransactional on " + element).isNotNull();
@ -706,7 +706,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void findMergedAnnotationForMultipleMetaAnnotationsWithClashingAttributeNames() {
void findMergedAnnotationForMultipleMetaAnnotationsWithClashingAttributeNames() {
String[] xmlLocations = asArray("test.xml");
String[] propFiles = asArray("test.properties");
@ -730,7 +730,7 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void findMergedAnnotationWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention() {
void findMergedAnnotationWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention() {
final String[] EMPTY = new String[0];
Class<?> element = SpringAppConfigClass.class;
ContextConfig contextConfig = findMergedAnnotation(element, ContextConfig.class);
@ -743,12 +743,12 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void findMergedAnnotationWithSingleElementOverridingAnArrayViaConvention() throws Exception {
void findMergedAnnotationWithSingleElementOverridingAnArrayViaConvention() throws Exception {
assertWebMapping(WebController.class.getMethod("postMappedWithPathAttribute"));
}
@Test
public void findMergedAnnotationWithSingleElementOverridingAnArrayViaAliasFor() throws Exception {
void findMergedAnnotationWithSingleElementOverridingAnArrayViaAliasFor() throws Exception {
assertWebMapping(WebController.class.getMethod("getMappedWithValueAttribute"));
assertWebMapping(WebController.class.getMethod("getMappedWithPathAttribute"));
}
@ -761,60 +761,60 @@ public class AnnotatedElementUtilsTests {
}
@Test
public void javaLangAnnotationTypeViaFindMergedAnnotation() throws Exception {
void javaLangAnnotationTypeViaFindMergedAnnotation() throws Exception {
Constructor<?> deprecatedCtor = Date.class.getConstructor(String.class);
assertThat(findMergedAnnotation(deprecatedCtor, Deprecated.class)).isEqualTo(deprecatedCtor.getAnnotation(Deprecated.class));
assertThat(findMergedAnnotation(Date.class, Deprecated.class)).isEqualTo(Date.class.getAnnotation(Deprecated.class));
}
@Test
public void javaxAnnotationTypeViaFindMergedAnnotation() throws Exception {
void javaxAnnotationTypeViaFindMergedAnnotation() throws Exception {
assertThat(findMergedAnnotation(ResourceHolder.class, Resource.class)).isEqualTo(ResourceHolder.class.getAnnotation(Resource.class));
assertThat(findMergedAnnotation(SpringAppConfigClass.class, Resource.class)).isEqualTo(SpringAppConfigClass.class.getAnnotation(Resource.class));
}
@Test
public void javaxMetaAnnotationTypeViaFindMergedAnnotation() throws Exception {
void javaxMetaAnnotationTypeViaFindMergedAnnotation() throws Exception {
assertThat(findMergedAnnotation(ParametersAreNonnullByDefault.class, Nonnull.class)).isEqualTo(ParametersAreNonnullByDefault.class.getAnnotation(Nonnull.class));
assertThat(findMergedAnnotation(ResourceHolder.class, Nonnull.class)).isEqualTo(ParametersAreNonnullByDefault.class.getAnnotation(Nonnull.class));
}
@Test
public void nullableAnnotationTypeViaFindMergedAnnotation() throws Exception {
void nullableAnnotationTypeViaFindMergedAnnotation() throws Exception {
Method method = TransactionalServiceImpl.class.getMethod("doIt");
assertThat(findMergedAnnotation(method, Resource.class)).isEqualTo(method.getAnnotation(Resource.class));
}
@Test
public void getAllMergedAnnotationsOnClassWithInterface() throws Exception {
void getAllMergedAnnotationsOnClassWithInterface() throws Exception {
Method method = TransactionalServiceImpl.class.getMethod("doIt");
Set<Transactional> allMergedAnnotations = getAllMergedAnnotations(method, Transactional.class);
assertThat(allMergedAnnotations.isEmpty()).isTrue();
}
@Test
public void findAllMergedAnnotationsOnClassWithInterface() throws Exception {
void findAllMergedAnnotationsOnClassWithInterface() throws Exception {
Method method = TransactionalServiceImpl.class.getMethod("doIt");
Set<Transactional> allMergedAnnotations = findAllMergedAnnotations(method, Transactional.class);
assertThat(allMergedAnnotations.size()).isEqualTo(1);
}
@Test // SPR-16060
public void findMethodAnnotationFromGenericInterface() throws Exception {
void findMethodAnnotationFromGenericInterface() throws Exception {
Method method = ImplementsInterfaceWithGenericAnnotatedMethod.class.getMethod("foo", String.class);
Order order = findMergedAnnotation(method, Order.class);
assertThat(order).isNotNull();
}
@Test // SPR-17146
public void findMethodAnnotationFromGenericSuperclass() throws Exception {
void findMethodAnnotationFromGenericSuperclass() throws Exception {
Method method = ExtendsBaseClassWithGenericAnnotatedMethod.class.getMethod("foo", String.class);
Order order = findMergedAnnotation(method, Order.class);
assertThat(order).isNotNull();
}
@Test // gh-22655
public void forAnnotationsCreatesCopyOfArrayOnEachCall() {
void forAnnotationsCreatesCopyOfArrayOnEachCall() {
AnnotatedElement element = AnnotatedElementUtils.forAnnotations(ForAnnotationsClass.class.getDeclaredAnnotations());
// Trigger the NPE as originally reported in the bug
AnnotationsScanner.getDeclaredAnnotations(element, false);
@ -824,7 +824,7 @@ public class AnnotatedElementUtilsTests {
}
@Test // gh-22703
public void getMergedAnnotationOnThreeDeepMetaWithValue() {
void getMergedAnnotationOnThreeDeepMetaWithValue() {
ValueAttribute annotation = AnnotatedElementUtils.getMergedAnnotation(
ValueAttributeMetaMetaClass.class, ValueAttribute.class);
assertThat(annotation.value()).containsExactly("FromValueAttributeMeta");

View File

@ -36,13 +36,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Juergen Hoeller
* @since 3.1.1
*/
public class AnnotationAttributesTests {
class AnnotationAttributesTests {
private AnnotationAttributes attributes = new AnnotationAttributes();
@Test
public void typeSafeAttributeAccess() {
void typeSafeAttributeAccess() {
AnnotationAttributes nestedAttributes = new AnnotationAttributes();
nestedAttributes.put("value", 10);
nestedAttributes.put("name", "algernon");
@ -72,7 +72,7 @@ public class AnnotationAttributesTests {
}
@Test
public void unresolvableClassWithClassNotFoundException() throws Exception {
void unresolvableClassWithClassNotFoundException() throws Exception {
attributes.put("unresolvableClass", new ClassNotFoundException("myclass"));
assertThatIllegalArgumentException()
.isThrownBy(() -> attributes.getClass("unresolvableClass"))
@ -81,7 +81,7 @@ public class AnnotationAttributesTests {
}
@Test
public void unresolvableClassWithLinkageError() throws Exception {
void unresolvableClassWithLinkageError() throws Exception {
attributes.put("unresolvableClass", new LinkageError("myclass"));
assertThatIllegalArgumentException()
.isThrownBy(() -> attributes.getClass("unresolvableClass"))
@ -90,7 +90,7 @@ public class AnnotationAttributesTests {
}
@Test
public void singleElementToSingleElementArrayConversionSupport() throws Exception {
void singleElementToSingleElementArrayConversionSupport() throws Exception {
Filter filter = FilteredClass.class.getAnnotation(Filter.class);
AnnotationAttributes nestedAttributes = new AnnotationAttributes();
@ -118,7 +118,7 @@ public class AnnotationAttributesTests {
}
@Test
public void nestedAnnotations() throws Exception {
void nestedAnnotations() throws Exception {
Filter filter = FilteredClass.class.getAnnotation(Filter.class);
attributes.put("filter", filter);
@ -135,28 +135,28 @@ public class AnnotationAttributesTests {
}
@Test
public void getEnumWithNullAttributeName() {
void getEnumWithNullAttributeName() {
assertThatIllegalArgumentException()
.isThrownBy(() -> attributes.getEnum(null))
.withMessageContaining("must not be null or empty");
}
@Test
public void getEnumWithEmptyAttributeName() {
void getEnumWithEmptyAttributeName() {
assertThatIllegalArgumentException()
.isThrownBy(() -> attributes.getEnum(""))
.withMessageContaining("must not be null or empty");
}
@Test
public void getEnumWithUnknownAttributeName() {
void getEnumWithUnknownAttributeName() {
assertThatIllegalArgumentException()
.isThrownBy(() -> attributes.getEnum("bogus"))
.withMessageContaining("Attribute 'bogus' not found");
}
@Test
public void getEnumWithTypeMismatch() {
void getEnumWithTypeMismatch() {
attributes.put("color", "RED");
assertThatIllegalArgumentException()
.isThrownBy(() -> attributes.getEnum("color"))
@ -164,7 +164,7 @@ public class AnnotationAttributesTests {
}
@Test
public void getAliasedStringWithImplicitAliases() {
void getAliasedStringWithImplicitAliases() {
String value = "metaverse";
List<String> aliases = Arrays.asList("value", "location1", "location2", "location3", "xmlFile", "groovyScript");
@ -188,7 +188,7 @@ public class AnnotationAttributesTests {
}
@Test
public void getAliasedStringArrayWithImplicitAliases() {
void getAliasedStringArrayWithImplicitAliases() {
String[] value = new String[] {"test.xml"};
List<String> aliases = Arrays.asList("value", "location1", "location2", "location3", "xmlFile", "groovyScript");

View File

@ -28,15 +28,15 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @author Oliver Gierke
*/
public class AnnotationAwareOrderComparatorTests {
class AnnotationAwareOrderComparatorTests {
@Test
public void instanceVariableIsAnAnnotationAwareOrderComparator() {
void instanceVariableIsAnAnnotationAwareOrderComparator() {
assertThat(AnnotationAwareOrderComparator.INSTANCE).isInstanceOf(AnnotationAwareOrderComparator.class);
}
@Test
public void sortInstances() {
void sortInstances() {
List<Object> list = new ArrayList<>();
list.add(new B());
list.add(new A());
@ -46,7 +46,7 @@ public class AnnotationAwareOrderComparatorTests {
}
@Test
public void sortInstancesWithPriority() {
void sortInstancesWithPriority() {
List<Object> list = new ArrayList<>();
list.add(new B2());
list.add(new A2());
@ -56,7 +56,7 @@ public class AnnotationAwareOrderComparatorTests {
}
@Test
public void sortInstancesWithOrderAndPriority() {
void sortInstancesWithOrderAndPriority() {
List<Object> list = new ArrayList<>();
list.add(new B());
list.add(new A2());
@ -66,7 +66,7 @@ public class AnnotationAwareOrderComparatorTests {
}
@Test
public void sortInstancesWithSubclass() {
void sortInstancesWithSubclass() {
List<Object> list = new ArrayList<>();
list.add(new B());
list.add(new C());
@ -76,7 +76,7 @@ public class AnnotationAwareOrderComparatorTests {
}
@Test
public void sortClasses() {
void sortClasses() {
List<Object> list = new ArrayList<>();
list.add(B.class);
list.add(A.class);
@ -86,7 +86,7 @@ public class AnnotationAwareOrderComparatorTests {
}
@Test
public void sortClassesWithSubclass() {
void sortClassesWithSubclass() {
List<Object> list = new ArrayList<>();
list.add(B.class);
list.add(C.class);
@ -96,7 +96,7 @@ public class AnnotationAwareOrderComparatorTests {
}
@Test
public void sortWithNulls() {
void sortWithNulls() {
List<Object> list = new ArrayList<>();
list.add(null);
list.add(B.class);

View File

@ -29,10 +29,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @since 5.2
*/
public class AnnotationBackCompatibiltyTests {
class AnnotationBackCompatibiltyTests {
@Test
public void multiplRoutesToMetaAnnotation() {
void multiplRoutesToMetaAnnotation() {
Class<WithMetaMetaTestAnnotation1AndMetaTestAnnotation2> source = WithMetaMetaTestAnnotation1AndMetaTestAnnotation2.class;
// Merged annotation chooses lowest depth
MergedAnnotation<TestAnnotation> mergedAnnotation = MergedAnnotations.from(source).get(TestAnnotation.class);
@ -43,7 +43,7 @@ public class AnnotationBackCompatibiltyTests {
}
@Test
public void defaultValue() {
void defaultValue() {
DefaultValueAnnotation synthesized = MergedAnnotations.from(WithDefaultValue.class).get(DefaultValueAnnotation.class).synthesize();
assertThat(synthesized).isInstanceOf(SynthesizedAnnotation.class);
Object defaultValue = AnnotationUtils.getDefaultValue(synthesized, "enumValue");

View File

@ -32,73 +32,73 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
public class AnnotationFilterTests {
class AnnotationFilterTests {
private static final AnnotationFilter FILTER = annotationType ->
ObjectUtils.nullSafeEquals(annotationType, TestAnnotation.class.getName());
@Test
public void matchesAnnotationWhenMatchReturnsTrue() {
void matchesAnnotationWhenMatchReturnsTrue() {
TestAnnotation annotation = WithTestAnnotation.class.getDeclaredAnnotation(TestAnnotation.class);
assertThat(FILTER.matches(annotation)).isTrue();
}
@Test
public void matchesAnnotationWhenNoMatchReturnsFalse() {
void matchesAnnotationWhenNoMatchReturnsFalse() {
OtherAnnotation annotation = WithOtherAnnotation.class.getDeclaredAnnotation(OtherAnnotation.class);
assertThat(FILTER.matches(annotation)).isFalse();
}
@Test
public void matchesAnnotationClassWhenMatchReturnsTrue() {
void matchesAnnotationClassWhenMatchReturnsTrue() {
Class<TestAnnotation> annotationType = TestAnnotation.class;
assertThat(FILTER.matches(annotationType)).isTrue();
}
@Test
public void matchesAnnotationClassWhenNoMatchReturnsFalse() {
void matchesAnnotationClassWhenNoMatchReturnsFalse() {
Class<OtherAnnotation> annotationType = OtherAnnotation.class;
assertThat(FILTER.matches(annotationType)).isFalse();
}
@Test
public void plainWhenJavaLangAnnotationReturnsTrue() {
void plainWhenJavaLangAnnotationReturnsTrue() {
assertThat(AnnotationFilter.PLAIN.matches(Retention.class)).isTrue();
}
@Test
public void plainWhenSpringLangAnnotationReturnsTrue() {
void plainWhenSpringLangAnnotationReturnsTrue() {
assertThat(AnnotationFilter.PLAIN.matches(Nullable.class)).isTrue();
}
@Test
public void plainWhenOtherAnnotationReturnsFalse() {
void plainWhenOtherAnnotationReturnsFalse() {
assertThat(AnnotationFilter.PLAIN.matches(TestAnnotation.class)).isFalse();
}
@Test
public void javaWhenJavaLangAnnotationReturnsTrue() {
void javaWhenJavaLangAnnotationReturnsTrue() {
assertThat(AnnotationFilter.JAVA.matches(Retention.class)).isTrue();
}
@Test
public void javaWhenJavaxAnnotationReturnsTrue() {
void javaWhenJavaxAnnotationReturnsTrue() {
assertThat(AnnotationFilter.JAVA.matches(Nonnull.class)).isTrue();
}
@Test
public void javaWhenSpringLangAnnotationReturnsFalse() {
void javaWhenSpringLangAnnotationReturnsFalse() {
assertThat(AnnotationFilter.JAVA.matches(Nullable.class)).isFalse();
}
@Test
public void javaWhenOtherAnnotationReturnsFalse() {
void javaWhenOtherAnnotationReturnsFalse() {
assertThat(AnnotationFilter.JAVA.matches(TestAnnotation.class)).isFalse();
}
@Test
public void noneReturnsFalse() {
void noneReturnsFalse() {
assertThat(AnnotationFilter.NONE.matches(Retention.class)).isFalse();
assertThat(AnnotationFilter.NONE.matches(Nullable.class)).isFalse();
assertThat(AnnotationFilter.NONE.matches(TestAnnotation.class)).isFalse();

View File

@ -39,10 +39,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @see AnnotationUtils
* @see AnnotatedElementUtils
*/
public class AnnotationIntrospectionFailureTests {
class AnnotationIntrospectionFailureTests {
@Test
public void filteredTypeThrowsTypeNotPresentException() throws Exception {
void filteredTypeThrowsTypeNotPresentException() throws Exception {
FilteringClassLoader classLoader = new FilteringClassLoader(
getClass().getClassLoader());
Class<?> withExampleAnnotation = ClassUtils.forName(
@ -57,7 +57,7 @@ public class AnnotationIntrospectionFailureTests {
@Test
@SuppressWarnings("unchecked")
public void filteredTypeInMetaAnnotationWhenUsingAnnotatedElementUtilsHandlesException() throws Exception {
void filteredTypeInMetaAnnotationWhenUsingAnnotatedElementUtilsHandlesException() throws Exception {
FilteringClassLoader classLoader = new FilteringClassLoader(
getClass().getClassLoader());
Class<?> withExampleMetaAnnotation = ClassUtils.forName(
@ -78,7 +78,7 @@ public class AnnotationIntrospectionFailureTests {
@Test
@SuppressWarnings("unchecked")
public void filteredTypeInMetaAnnotationWhenUsingMergedAnnotationsHandlesException() throws Exception {
void filteredTypeInMetaAnnotationWhenUsingMergedAnnotationsHandlesException() throws Exception {
FilteringClassLoader classLoader = new FilteringClassLoader(
getClass().getClassLoader());
Class<?> withExampleMetaAnnotation = ClassUtils.forName(

View File

@ -45,10 +45,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Phillip Webb
*/
public class AnnotationTypeMappingsTests {
class AnnotationTypeMappingsTests {
@Test
public void forAnnotationTypeWhenNoMetaAnnotationsReturnsMappings() {
void forAnnotationTypeWhenNoMetaAnnotationsReturnsMappings() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SimpleAnnotation.class);
assertThat(mappings.size()).isEqualTo(1);
assertThat(mappings.get(0).getAnnotationType()).isEqualTo(SimpleAnnotation.class);
@ -57,13 +57,13 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationWhenHasSpringAnnotationReturnsFilteredMappings() {
void forAnnotationWhenHasSpringAnnotationReturnsFilteredMappings() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithSpringLangAnnotation.class);
assertThat(mappings.size()).isEqualTo(1);
}
@Test
public void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() {
void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MetaAnnotated.class);
assertThat(mappings.size()).isEqualTo(6);
assertThat(getAll(mappings)).flatExtracting(
@ -73,7 +73,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenHasRepeatingMetaAnnotationReturnsMapping() {
void forAnnotationTypeWhenHasRepeatingMetaAnnotationReturnsMapping() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class);
assertThat(mappings.size()).isEqualTo(3);
assertThat(getAll(mappings)).flatExtracting(
@ -82,7 +82,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenSelfAnnotatedReturnsMapping() {
void forAnnotationTypeWhenSelfAnnotatedReturnsMapping() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SelfAnnotated.class);
assertThat(mappings.size()).isEqualTo(1);
assertThat(getAll(mappings)).flatExtracting(
@ -90,7 +90,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenFormsLoopReturnsMapping() {
void forAnnotationTypeWhenFormsLoopReturnsMapping() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(LoopA.class);
assertThat(mappings.size()).isEqualTo(2);
assertThat(getAll(mappings)).flatExtracting(
@ -98,7 +98,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenHasAliasForWithBothValueAndAttributeThrowsException() {
void forAnnotationTypeWhenHasAliasForWithBothValueAndAttributeThrowsException() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForWithBothValueAndAttribute.class))
.withMessage("In @AliasFor declared on attribute 'test' in annotation ["
@ -107,7 +107,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForToSelfNonExistingAttribute() {
void forAnnotationTypeWhenAliasForToSelfNonExistingAttribute() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonExistingAttribute.class))
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
@ -116,7 +116,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForToOtherNonExistingAttribute() {
void forAnnotationTypeWhenAliasForToOtherNonExistingAttribute() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForToOtherNonExistingAttribute.class))
.withMessage("Attribute 'test' in annotation ["
@ -128,7 +128,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForToSelf() {
void forAnnotationTypeWhenAliasForToSelf() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForToSelf.class))
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
@ -138,7 +138,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForWithArrayCompatibleReturnTypes() {
void forAnnotationTypeWhenAliasForWithArrayCompatibleReturnTypes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
AliasForWithArrayCompatibleReturnTypes.class);
AnnotationTypeMapping mapping = getMapping(mappings,
@ -147,7 +147,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() {
void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForWithIncompatibleReturnTypes.class))
.withMessage("Misconfigured aliases: attribute 'test' in annotation ["
@ -158,7 +158,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForToSelfNonAnnotatedAttribute() {
void forAnnotationTypeWhenAliasForToSelfNonAnnotatedAttribute() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonAnnotatedAttribute.class))
.withMessage("Attribute 'other' in annotation ["
@ -167,7 +167,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForToSelfAnnotatedToOtherAttribute() {
void forAnnotationTypeWhenAliasForToSelfAnnotatedToOtherAttribute() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForToSelfAnnotatedToOtherAttribute.class))
.withMessage("Attribute 'b' in annotation ["
@ -176,7 +176,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForNonMetaAnnotated() {
void forAnnotationTypeWhenAliasForNonMetaAnnotated() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForNonMetaAnnotated.class))
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
@ -187,7 +187,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForSelfWithDifferentDefaults() {
void forAnnotationTypeWhenAliasForSelfWithDifferentDefaults() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForSelfWithDifferentDefaults.class))
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
@ -198,7 +198,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasForSelfWithMissingDefault() {
void forAnnotationTypeWhenAliasForSelfWithMissingDefault() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasForSelfWithMissingDefault.class))
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
@ -209,7 +209,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() {
void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
AnnotationTypeMappings.forAnnotationType(AliasWithExplicitMirrorAndDifferentDefaults.class))
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
@ -220,7 +220,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getDistanceReturnsDistance() {
void getDistanceReturnsDistance() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
Mapped.class);
assertThat(mappings.get(0).getDistance()).isEqualTo(0);
@ -228,7 +228,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getAnnotationTypeReturnsAnnotationType() {
void getAnnotationTypeReturnsAnnotationType() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
Mapped.class);
assertThat(mappings.get(0).getAnnotationType()).isEqualTo(Mapped.class);
@ -236,7 +236,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getMetaTypeReturnsTypes() {
void getMetaTypeReturnsTypes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
ThreeDeepA.class);
AnnotationTypeMapping mappingC = mappings.get(2);
@ -245,14 +245,14 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getAnnotationWhenRootReturnsNull() {
void getAnnotationWhenRootReturnsNull() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
Mapped.class);
assertThat(mappings.get(0).getAnnotation()).isNull();
}
@Test
public void getAnnotationWhenMetaAnnotationReturnsAnnotation() {
void getAnnotationWhenMetaAnnotationReturnsAnnotation() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
Mapped.class);
assertThat(mappings.get(1).getAnnotation()).isEqualTo(
@ -261,7 +261,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getAttributesReturnsAttributes() {
void getAttributesReturnsAttributes() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
Mapped.class).get(0);
AttributeMethods attributes = mapping.getAttributes();
@ -271,7 +271,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getAliasMappingReturnsAttributes() throws Exception {
void getAliasMappingReturnsAttributes() throws Exception {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
Mapped.class).get(1);
assertThat(getAliasMapping(mapping, 0)).isEqualTo(
@ -279,7 +279,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getConventionMappingReturnsAttributes() throws Exception {
void getConventionMappingReturnsAttributes() throws Exception {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
Mapped.class).get(1);
assertThat(getConventionMapping(mapping, 1)).isEqualTo(
@ -287,7 +287,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getMirrorSetWhenAliasPairReturnsMirrors() {
void getMirrorSetWhenAliasPairReturnsMirrors() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
MirrorSets mirrorSets = mapping.getMirrorSets();
@ -298,7 +298,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getMirrorSetWhenImplicitMirrorsReturnsMirrors() {
void getMirrorSetWhenImplicitMirrorsReturnsMirrors() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ImplicitMirrors.class).get(0);
MirrorSets mirrorSets = mapping.getMirrorSets();
@ -309,7 +309,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getMirrorSetWhenThreeDeepReturnsMirrors() {
void getMirrorSetWhenThreeDeepReturnsMirrors() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
ThreeDeepA.class);
AnnotationTypeMapping mappingA = mappings.get(0);
@ -326,7 +326,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getAliasMappingWhenThreeDeepReturnsMappedAttributes() {
void getAliasMappingWhenThreeDeepReturnsMappedAttributes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
ThreeDeepA.class);
AnnotationTypeMapping mappingA = mappings.get(0);
@ -344,7 +344,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getAliasMappingsWhenHasDefinedAttributesReturnsMappedAttributes() {
void getAliasMappingsWhenHasDefinedAttributesReturnsMappedAttributes() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
DefinedAttributes.class).get(1);
assertThat(getAliasMapping(mapping, 0)).isNull();
@ -352,7 +352,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void resolveMirrorsWhenAliasPairResolves() {
void resolveMirrorsWhenAliasPairResolves() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
Method[] resolvedA = resolveMirrorSets(mapping, WithAliasPairA.class,
@ -366,7 +366,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void resolveMirrorsWhenHasSameValuesUsesFirst() {
void resolveMirrorsWhenHasSameValuesUsesFirst() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
Method[] resolved = resolveMirrorSets(mapping, WithSameValueAliasPair.class,
@ -376,7 +376,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void resolveMirrorsWhenOnlyHasDefaultValuesResolvesNone() {
void resolveMirrorsWhenOnlyHasDefaultValuesResolvesNone() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
Method[] resolved = resolveMirrorSets(mapping, WithDefaultValueAliasPair.class,
@ -386,7 +386,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void resolveMirrorsWhenHasDifferentValuesThrowsException() {
void resolveMirrorsWhenHasDifferentValuesThrowsException() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
AliasPair.class).get(0);
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
@ -398,7 +398,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void resolveMirrorsWhenHasWithMulipleRoutesToAliasReturnsMirrors() {
void resolveMirrorsWhenHasWithMulipleRoutesToAliasReturnsMirrors() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
MulipleRoutesToAliasA.class);
AnnotationTypeMapping mappingsA = getMapping(mappings,
@ -415,7 +415,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getAliasMappingWhenHasWithMulipleRoutesToAliasReturnsMappedAttributes() {
void getAliasMappingWhenHasWithMulipleRoutesToAliasReturnsMappedAttributes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
MulipleRoutesToAliasA.class);
AnnotationTypeMapping mappingsA = getMapping(mappings,
@ -433,7 +433,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void getConventionMappingWhenConventionToExplicitAliasesReturnsMappedAttributes() {
void getConventionMappingWhenConventionToExplicitAliasesReturnsMappedAttributes() {
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
ConventionToExplicitAliases.class);
AnnotationTypeMapping mapping = getMapping(mappings,
@ -443,7 +443,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void isEquivalentToDefaultValueWhenValueAndDefaultAreNullReturnsTrue() {
void isEquivalentToDefaultValueWhenValueAndDefaultAreNullReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassValue.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, null,
@ -451,7 +451,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void isEquivalentToDefaultValueWhenValueAndDefaultMatchReturnsTrue() {
void isEquivalentToDefaultValueWhenValueAndDefaultMatchReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, InputStream.class,
@ -459,7 +459,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void isEquivalentToDefaultValueWhenClassAndStringNamesMatchReturnsTrue() {
void isEquivalentToDefaultValueWhenClassAndStringNamesMatchReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, "java.io.InputStream",
@ -467,7 +467,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void isEquivalentToDefaultValueWhenClassArrayAndStringArrayNamesMatchReturnsTrue() {
void isEquivalentToDefaultValueWhenClassArrayAndStringArrayNamesMatchReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassArrayValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0,
@ -476,7 +476,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrue() {
void isEquivalentToDefaultValueWhenNestedAnnotationAndExtractedValuesMatchReturnsTrue() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
NestedValue.class).get(0);
Map<String, Object> value = Collections.singletonMap("value",
@ -486,7 +486,7 @@ public class AnnotationTypeMappingsTests {
}
@Test
public void isEquivalentToDefaultValueWhenNotMatchingReturnsFalse() {
void isEquivalentToDefaultValueWhenNotMatchingReturnsFalse() {
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(
ClassValueWithDefault.class).get(0);
assertThat(mapping.isEquivalentToDefaultValue(0, OutputStream.class,

View File

@ -72,16 +72,16 @@ import static org.springframework.core.annotation.AnnotationUtils.synthesizeAnno
* @author Oleg Zhurakousky
*/
@SuppressWarnings("deprecation")
public class AnnotationUtilsTests {
class AnnotationUtilsTests {
@BeforeEach
public void clearCacheBeforeTests() {
void clearCacheBeforeTests() {
AnnotationUtils.clearCache();
}
@Test
public void findMethodAnnotationOnLeaf() throws Exception {
void findMethodAnnotationOnLeaf() throws Exception {
Method m = Leaf.class.getMethod("annotatedOnLeaf");
assertThat(m.getAnnotation(Order.class)).isNotNull();
assertThat(getAnnotation(m, Order.class)).isNotNull();
@ -90,7 +90,7 @@ public class AnnotationUtilsTests {
// @since 4.2
@Test
public void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Exception {
void findMethodAnnotationWithAnnotationOnMethodInInterface() throws Exception {
Method m = Leaf.class.getMethod("fromInterfaceImplementedByRoot");
// @Order is not @Inherited
assertThat(m.getAnnotation(Order.class)).isNull();
@ -102,7 +102,7 @@ public class AnnotationUtilsTests {
// @since 4.2
@Test
public void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception {
void findMethodAnnotationWithMetaAnnotationOnLeaf() throws Exception {
Method m = Leaf.class.getMethod("metaAnnotatedOnLeaf");
assertThat(m.getAnnotation(Order.class)).isNull();
assertThat(getAnnotation(m, Order.class)).isNotNull();
@ -111,7 +111,7 @@ public class AnnotationUtilsTests {
// @since 4.2
@Test
public void findMethodAnnotationWithMetaMetaAnnotationOnLeaf() throws Exception {
void findMethodAnnotationWithMetaMetaAnnotationOnLeaf() throws Exception {
Method m = Leaf.class.getMethod("metaMetaAnnotatedOnLeaf");
assertThat(m.getAnnotation(Component.class)).isNull();
assertThat(getAnnotation(m, Component.class)).isNull();
@ -119,7 +119,7 @@ public class AnnotationUtilsTests {
}
@Test
public void findMethodAnnotationOnRoot() throws Exception {
void findMethodAnnotationOnRoot() throws Exception {
Method m = Leaf.class.getMethod("annotatedOnRoot");
assertThat(m.getAnnotation(Order.class)).isNotNull();
assertThat(getAnnotation(m, Order.class)).isNotNull();
@ -128,7 +128,7 @@ public class AnnotationUtilsTests {
// @since 4.2
@Test
public void findMethodAnnotationWithMetaAnnotationOnRoot() throws Exception {
void findMethodAnnotationWithMetaAnnotationOnRoot() throws Exception {
Method m = Leaf.class.getMethod("metaAnnotatedOnRoot");
assertThat(m.getAnnotation(Order.class)).isNull();
assertThat(getAnnotation(m, Order.class)).isNotNull();
@ -136,7 +136,7 @@ public class AnnotationUtilsTests {
}
@Test
public void findMethodAnnotationOnRootButOverridden() throws Exception {
void findMethodAnnotationOnRootButOverridden() throws Exception {
Method m = Leaf.class.getMethod("overrideWithoutNewAnnotation");
assertThat(m.getAnnotation(Order.class)).isNull();
assertThat(getAnnotation(m, Order.class)).isNull();
@ -144,13 +144,13 @@ public class AnnotationUtilsTests {
}
@Test
public void findMethodAnnotationNotAnnotated() throws Exception {
void findMethodAnnotationNotAnnotated() throws Exception {
Method m = Leaf.class.getMethod("notAnnotated");
assertThat(findAnnotation(m, Order.class)).isNull();
}
@Test
public void findMethodAnnotationOnBridgeMethod() throws Exception {
void findMethodAnnotationOnBridgeMethod() throws Exception {
Method bridgeMethod = SimpleFoo.class.getMethod("something", Object.class);
assertThat(bridgeMethod.isBridge()).isTrue();
@ -177,7 +177,7 @@ public class AnnotationUtilsTests {
}
@Test
public void findMethodAnnotationOnBridgedMethod() throws Exception {
void findMethodAnnotationOnBridgedMethod() throws Exception {
Method bridgedMethod = SimpleFoo.class.getMethod("something", String.class);
assertThat(bridgedMethod.isBridge()).isFalse();
@ -191,35 +191,35 @@ public class AnnotationUtilsTests {
}
@Test
public void findMethodAnnotationFromInterface() throws Exception {
void findMethodAnnotationFromInterface() throws Exception {
Method method = ImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo");
Order order = findAnnotation(method, Order.class);
assertThat(order).isNotNull();
}
@Test // SPR-16060
public void findMethodAnnotationFromGenericInterface() throws Exception {
void findMethodAnnotationFromGenericInterface() throws Exception {
Method method = ImplementsInterfaceWithGenericAnnotatedMethod.class.getMethod("foo", String.class);
Order order = findAnnotation(method, Order.class);
assertThat(order).isNotNull();
}
@Test // SPR-17146
public void findMethodAnnotationFromGenericSuperclass() throws Exception {
void findMethodAnnotationFromGenericSuperclass() throws Exception {
Method method = ExtendsBaseClassWithGenericAnnotatedMethod.class.getMethod("foo", String.class);
Order order = findAnnotation(method, Order.class);
assertThat(order).isNotNull();
}
@Test
public void findMethodAnnotationFromInterfaceOnSuper() throws Exception {
void findMethodAnnotationFromInterfaceOnSuper() throws Exception {
Method method = SubOfImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo");
Order order = findAnnotation(method, Order.class);
assertThat(order).isNotNull();
}
@Test
public void findMethodAnnotationFromInterfaceWhenSuperDoesNotImplementMethod() throws Exception {
void findMethodAnnotationFromInterfaceWhenSuperDoesNotImplementMethod() throws Exception {
Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo");
Order order = findAnnotation(method, Order.class);
assertThat(order).isNotNull();
@ -227,7 +227,7 @@ public class AnnotationUtilsTests {
// @since 4.1.2
@Test
public void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverAnnotationsOnInterfaces() {
void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverAnnotationsOnInterfaces() {
Component component = findAnnotation(ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class, Component.class);
assertThat(component).isNotNull();
assertThat(component.value()).isEqualTo("meta2");
@ -235,7 +235,7 @@ public class AnnotationUtilsTests {
// @since 4.0.3
@Test
public void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedAnnotations() {
void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedAnnotations() {
Transactional transactional = findAnnotation(SubSubClassWithInheritedAnnotation.class, Transactional.class);
assertThat(transactional).isNotNull();
assertThat(transactional.readOnly()).as("readOnly flag for SubSubClassWithInheritedAnnotation").isTrue();
@ -243,83 +243,83 @@ public class AnnotationUtilsTests {
// @since 4.0.3
@Test
public void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations() {
void findClassAnnotationFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations() {
Component component = findAnnotation(SubSubClassWithInheritedMetaAnnotation.class, Component.class);
assertThat(component).isNotNull();
assertThat(component.value()).isEqualTo("meta2");
}
@Test
public void findClassAnnotationOnMetaMetaAnnotatedClass() {
void findClassAnnotationOnMetaMetaAnnotatedClass() {
Component component = findAnnotation(MetaMetaAnnotatedClass.class, Component.class);
assertThat(component).as("Should find meta-annotation on composed annotation on class").isNotNull();
assertThat(component.value()).isEqualTo("meta2");
}
@Test
public void findClassAnnotationOnMetaMetaMetaAnnotatedClass() {
void findClassAnnotationOnMetaMetaMetaAnnotatedClass() {
Component component = findAnnotation(MetaMetaMetaAnnotatedClass.class, Component.class);
assertThat(component).as("Should find meta-annotation on meta-annotation on composed annotation on class").isNotNull();
assertThat(component.value()).isEqualTo("meta2");
}
@Test
public void findClassAnnotationOnAnnotatedClassWithMissingTargetMetaAnnotation() {
void findClassAnnotationOnAnnotatedClassWithMissingTargetMetaAnnotation() {
// TransactionalClass is NOT annotated or meta-annotated with @Component
Component component = findAnnotation(TransactionalClass.class, Component.class);
assertThat(component).as("Should not find @Component on TransactionalClass").isNull();
}
@Test
public void findClassAnnotationOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
void findClassAnnotationOnMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
Component component = findAnnotation(MetaCycleAnnotatedClass.class, Component.class);
assertThat(component).as("Should not find @Component on MetaCycleAnnotatedClass").isNull();
}
// @since 4.2
@Test
public void findClassAnnotationOnInheritedAnnotationInterface() {
void findClassAnnotationOnInheritedAnnotationInterface() {
Transactional tx = findAnnotation(InheritedAnnotationInterface.class, Transactional.class);
assertThat(tx).as("Should find @Transactional on InheritedAnnotationInterface").isNotNull();
}
// @since 4.2
@Test
public void findClassAnnotationOnSubInheritedAnnotationInterface() {
void findClassAnnotationOnSubInheritedAnnotationInterface() {
Transactional tx = findAnnotation(SubInheritedAnnotationInterface.class, Transactional.class);
assertThat(tx).as("Should find @Transactional on SubInheritedAnnotationInterface").isNotNull();
}
// @since 4.2
@Test
public void findClassAnnotationOnSubSubInheritedAnnotationInterface() {
void findClassAnnotationOnSubSubInheritedAnnotationInterface() {
Transactional tx = findAnnotation(SubSubInheritedAnnotationInterface.class, Transactional.class);
assertThat(tx).as("Should find @Transactional on SubSubInheritedAnnotationInterface").isNotNull();
}
// @since 4.2
@Test
public void findClassAnnotationOnNonInheritedAnnotationInterface() {
void findClassAnnotationOnNonInheritedAnnotationInterface() {
Order order = findAnnotation(NonInheritedAnnotationInterface.class, Order.class);
assertThat(order).as("Should find @Order on NonInheritedAnnotationInterface").isNotNull();
}
// @since 4.2
@Test
public void findClassAnnotationOnSubNonInheritedAnnotationInterface() {
void findClassAnnotationOnSubNonInheritedAnnotationInterface() {
Order order = findAnnotation(SubNonInheritedAnnotationInterface.class, Order.class);
assertThat(order).as("Should find @Order on SubNonInheritedAnnotationInterface").isNotNull();
}
// @since 4.2
@Test
public void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() {
void findClassAnnotationOnSubSubNonInheritedAnnotationInterface() {
Order order = findAnnotation(SubSubNonInheritedAnnotationInterface.class, Order.class);
assertThat(order).as("Should find @Order on SubSubNonInheritedAnnotationInterface").isNotNull();
}
@Test
public void findAnnotationDeclaringClassForAllScenarios() {
void findAnnotationDeclaringClassForAllScenarios() {
// no class-level annotation
assertThat((Object) findAnnotationDeclaringClass(Transactional.class, NonAnnotatedInterface.class)).isNull();
assertThat((Object) findAnnotationDeclaringClass(Transactional.class, NonAnnotatedClass.class)).isNull();
@ -339,7 +339,7 @@ public class AnnotationUtilsTests {
}
@Test
public void findAnnotationDeclaringClassForTypesWithSingleCandidateType() {
void findAnnotationDeclaringClassForTypesWithSingleCandidateType() {
// no class-level annotation
List<Class<? extends Annotation>> transactionalCandidateList = Collections.singletonList(Transactional.class);
assertThat((Object) findAnnotationDeclaringClassForTypes(transactionalCandidateList, NonAnnotatedInterface.class)).isNull();
@ -361,7 +361,7 @@ public class AnnotationUtilsTests {
}
@Test
public void findAnnotationDeclaringClassForTypesWithMultipleCandidateTypes() {
void findAnnotationDeclaringClassForTypesWithMultipleCandidateTypes() {
List<Class<? extends Annotation>> candidates = asList(Transactional.class, Order.class);
// no class-level annotation
@ -388,7 +388,7 @@ public class AnnotationUtilsTests {
}
@Test
public void isAnnotationDeclaredLocallyForAllScenarios() {
void isAnnotationDeclaredLocallyForAllScenarios() {
// no class-level annotation
assertThat(isAnnotationDeclaredLocally(Transactional.class, NonAnnotatedInterface.class)).isFalse();
assertThat(isAnnotationDeclaredLocally(Transactional.class, NonAnnotatedClass.class)).isFalse();
@ -407,7 +407,7 @@ public class AnnotationUtilsTests {
}
@Test
public void isAnnotationInheritedForAllScenarios() {
void isAnnotationInheritedForAllScenarios() {
// no class-level annotation
assertThat(isAnnotationInherited(Transactional.class, NonAnnotatedInterface.class)).isFalse();
assertThat(isAnnotationInherited(Transactional.class, NonAnnotatedClass.class)).isFalse();
@ -428,7 +428,7 @@ public class AnnotationUtilsTests {
}
@Test
public void isAnnotationMetaPresentForPlainType() {
void isAnnotationMetaPresentForPlainType() {
assertThat(isAnnotationMetaPresent(Order.class, Documented.class)).isTrue();
assertThat(isAnnotationMetaPresent(NonNullApi.class, Documented.class)).isTrue();
assertThat(isAnnotationMetaPresent(NonNullApi.class, Nonnull.class)).isTrue();
@ -436,7 +436,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getAnnotationAttributesWithoutAttributeAliases() {
void getAnnotationAttributesWithoutAttributeAliases() {
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
@ -447,7 +447,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getAnnotationAttributesWithNestedAnnotations() {
void getAnnotationAttributesWithNestedAnnotations() {
ComponentScan componentScan = ComponentScanClass.class.getAnnotation(ComponentScan.class);
assertThat(componentScan).isNotNull();
@ -463,7 +463,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getAnnotationAttributesWithAttributeAliases() throws Exception {
void getAnnotationAttributesWithAttributeAliases() throws Exception {
Method method = WebController.class.getMethod("handleMappedWithValueAttribute");
WebMapping webMapping = method.getAnnotation(WebMapping.class);
AnnotationAttributes attributes = (AnnotationAttributes) getAnnotationAttributes(webMapping);
@ -484,7 +484,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getAnnotationAttributesWithAttributeAliasesWithDifferentValues() throws Exception {
void getAnnotationAttributesWithAttributeAliasesWithDifferentValues() throws Exception {
Method method = WebController.class.getMethod("handleMappedWithDifferentPathAndValueAttributes");
WebMapping webMapping = method.getAnnotation(WebMapping.class);
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
@ -494,7 +494,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getValueFromAnnotation() throws Exception {
void getValueFromAnnotation() throws Exception {
Method method = SimpleFoo.class.getMethod("something", Object.class);
Order order = findAnnotation(method, Order.class);
@ -503,7 +503,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getValueFromNonPublicAnnotation() throws Exception {
void getValueFromNonPublicAnnotation() throws Exception {
Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
assertThat(declaredAnnotations.length).isEqualTo(1);
Annotation annotation = declaredAnnotations[0];
@ -514,7 +514,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getDefaultValueFromAnnotation() throws Exception {
void getDefaultValueFromAnnotation() throws Exception {
Method method = SimpleFoo.class.getMethod("something", Object.class);
Order order = findAnnotation(method, Order.class);
@ -523,7 +523,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getDefaultValueFromNonPublicAnnotation() {
void getDefaultValueFromNonPublicAnnotation() {
Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
assertThat(declaredAnnotations.length).isEqualTo(1);
Annotation annotation = declaredAnnotations[0];
@ -534,20 +534,20 @@ public class AnnotationUtilsTests {
}
@Test
public void getDefaultValueFromAnnotationType() {
void getDefaultValueFromAnnotationType() {
assertThat(getDefaultValue(Order.class, VALUE)).isEqualTo(Ordered.LOWEST_PRECEDENCE);
assertThat(getDefaultValue(Order.class)).isEqualTo(Ordered.LOWEST_PRECEDENCE);
}
@Test
public void findRepeatableAnnotation() {
void findRepeatableAnnotation() {
Repeatable repeatable = findAnnotation(MyRepeatable.class, Repeatable.class);
assertThat(repeatable).isNotNull();
assertThat(repeatable.value()).isEqualTo(MyRepeatableContainer.class);
}
@Test
public void getRepeatableAnnotationsDeclaredOnMethod() throws Exception {
void getRepeatableAnnotationsDeclaredOnMethod() throws Exception {
Method method = InterfaceWithRepeated.class.getMethod("foo");
Set<MyRepeatable> annotations = getRepeatableAnnotations(method, MyRepeatable.class, MyRepeatableContainer.class);
assertThat(annotations).isNotNull();
@ -556,7 +556,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getRepeatableAnnotationsDeclaredOnClassWithMissingAttributeAliasDeclaration() throws Exception {
void getRepeatableAnnotationsDeclaredOnClassWithMissingAttributeAliasDeclaration() throws Exception {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
getRepeatableAnnotations(BrokenConfigHierarchyTestCase.class, BrokenContextConfig.class, BrokenHierarchy.class))
.withMessageStartingWith("Attribute 'value' in")
@ -566,7 +566,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() {
void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() {
final List<String> expectedLocations = asList("A", "B");
Set<ContextConfig> annotations = getRepeatableAnnotations(ConfigHierarchyTestCase.class, ContextConfig.class, null);
@ -584,7 +584,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getRepeatableAnnotationsDeclaredOnClass() {
void getRepeatableAnnotationsDeclaredOnClass() {
final List<String> expectedValuesJava = asList("A", "B", "C");
final List<String> expectedValuesSpring = asList("A", "B", "C", "meta1");
@ -608,7 +608,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getRepeatableAnnotationsDeclaredOnSuperclass() {
void getRepeatableAnnotationsDeclaredOnSuperclass() {
final Class<?> clazz = SubMyRepeatableClass.class;
final List<String> expectedValuesJava = asList("A", "B", "C");
final List<String> expectedValuesSpring = asList("A", "B", "C", "meta1");
@ -633,7 +633,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getRepeatableAnnotationsDeclaredOnClassAndSuperclass() {
void getRepeatableAnnotationsDeclaredOnClassAndSuperclass() {
final Class<?> clazz = SubMyRepeatableWithAdditionalLocalDeclarationsClass.class;
final List<String> expectedValuesJava = asList("X", "Y", "Z");
final List<String> expectedValuesSpring = asList("X", "Y", "Z", "meta2");
@ -658,7 +658,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getRepeatableAnnotationsDeclaredOnMultipleSuperclasses() {
void getRepeatableAnnotationsDeclaredOnMultipleSuperclasses() {
final Class<?> clazz = SubSubMyRepeatableWithAdditionalLocalDeclarationsClass.class;
final List<String> expectedValuesJava = asList("X", "Y", "Z");
final List<String> expectedValuesSpring = asList("X", "Y", "Z", "meta2");
@ -683,7 +683,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getDeclaredRepeatableAnnotationsDeclaredOnClass() {
void getDeclaredRepeatableAnnotationsDeclaredOnClass() {
final List<String> expectedValuesJava = asList("A", "B", "C");
final List<String> expectedValuesSpring = asList("A", "B", "C", "meta1");
@ -707,7 +707,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getDeclaredRepeatableAnnotationsDeclaredOnSuperclass() {
void getDeclaredRepeatableAnnotationsDeclaredOnSuperclass() {
final Class<?> clazz = SubMyRepeatableClass.class;
// Java 8
@ -727,7 +727,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() throws Exception {
void synthesizeAnnotationWithImplicitAliasesWithMissingDefaultValues() throws Exception {
Class<?> clazz = ImplicitAliasesWithMissingDefaultValuesContextConfigClass.class;
Class<ImplicitAliasesWithMissingDefaultValuesContextConfig> annotationType = ImplicitAliasesWithMissingDefaultValuesContextConfig.class;
ImplicitAliasesWithMissingDefaultValuesContextConfig config = clazz.getAnnotation(annotationType);
@ -742,7 +742,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() throws Exception {
void synthesizeAnnotationWithImplicitAliasesWithDifferentDefaultValues() throws Exception {
Class<?> clazz = ImplicitAliasesWithDifferentDefaultValuesContextConfigClass.class;
Class<ImplicitAliasesWithDifferentDefaultValuesContextConfig> annotationType = ImplicitAliasesWithDifferentDefaultValuesContextConfig.class;
ImplicitAliasesWithDifferentDefaultValuesContextConfig config = clazz.getAnnotation(annotationType);
@ -756,7 +756,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws Exception {
void synthesizeAnnotationWithImplicitAliasesWithDuplicateValues() throws Exception {
Class<?> clazz = ImplicitAliasesWithDuplicateValuesContextConfigClass.class;
Class<ImplicitAliasesWithDuplicateValuesContextConfig> annotationType = ImplicitAliasesWithDuplicateValuesContextConfig.class;
ImplicitAliasesWithDuplicateValuesContextConfig config = clazz.getAnnotation(annotationType);
@ -773,7 +773,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromMapWithoutAttributeAliases() throws Exception {
void synthesizeAnnotationFromMapWithoutAttributeAliases() throws Exception {
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
@ -788,7 +788,7 @@ public class AnnotationUtilsTests {
@Test
@SuppressWarnings("unchecked")
public void synthesizeAnnotationFromMapWithNestedMap() throws Exception {
void synthesizeAnnotationFromMapWithNestedMap() throws Exception {
ComponentScanSingleFilter componentScan = ComponentScanSingleFilterClass.class.getAnnotation(ComponentScanSingleFilter.class);
assertThat(componentScan).isNotNull();
assertThat(componentScan.value().pattern()).as("value from ComponentScan: ").isEqualTo("*Foo");
@ -816,7 +816,7 @@ public class AnnotationUtilsTests {
@Test
@SuppressWarnings("unchecked")
public void synthesizeAnnotationFromMapWithNestedArrayOfMaps() throws Exception {
void synthesizeAnnotationFromMapWithNestedArrayOfMaps() throws Exception {
ComponentScan componentScan = ComponentScanClass.class.getAnnotation(ComponentScan.class);
assertThat(componentScan).isNotNull();
@ -845,7 +845,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromDefaultsWithoutAttributeAliases() throws Exception {
void synthesizeAnnotationFromDefaultsWithoutAttributeAliases() throws Exception {
AnnotationWithDefaults annotationWithDefaults = synthesizeAnnotation(AnnotationWithDefaults.class);
assertThat(annotationWithDefaults).isNotNull();
assertThat(annotationWithDefaults.text()).as("text: ").isEqualTo("enigma");
@ -854,7 +854,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromDefaultsWithAttributeAliases() throws Exception {
void synthesizeAnnotationFromDefaultsWithAttributeAliases() throws Exception {
ContextConfig contextConfig = synthesizeAnnotation(ContextConfig.class);
assertThat(contextConfig).isNotNull();
assertThat(contextConfig.value()).as("value: ").isEqualTo("");
@ -862,7 +862,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception {
void synthesizeAnnotationFromMapWithMinimalAttributesWithAttributeAliases() throws Exception {
Map<String, Object> map = Collections.singletonMap("location", "test.xml");
ContextConfig contextConfig = synthesizeAnnotation(map, ContextConfig.class, null);
assertThat(contextConfig).isNotNull();
@ -871,7 +871,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() throws Exception {
void synthesizeAnnotationFromMapWithAttributeAliasesThatOverrideArraysWithSingleElements() throws Exception {
Map<String, Object> map = Collections.singletonMap("value", "/foo");
Get get = synthesizeAnnotation(map, Get.class, null);
assertThat(get).isNotNull();
@ -886,7 +886,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromMapWithImplicitAttributeAliases() throws Exception {
void synthesizeAnnotationFromMapWithImplicitAttributeAliases() throws Exception {
assertAnnotationSynthesisFromMapWithImplicitAliases("value");
assertAnnotationSynthesisFromMapWithImplicitAliases("location1");
assertAnnotationSynthesisFromMapWithImplicitAliases("location2");
@ -908,12 +908,12 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromMapWithMissingAttributeValue() throws Exception {
void synthesizeAnnotationFromMapWithMissingAttributeValue() throws Exception {
assertMissingTextAttribute(Collections.emptyMap());
}
@Test
public void synthesizeAnnotationFromMapWithNullAttributeValue() throws Exception {
void synthesizeAnnotationFromMapWithNullAttributeValue() throws Exception {
Map<String, Object> map = Collections.singletonMap("text", null);
assertThat(map.containsKey("text")).isTrue();
assertMissingTextAttribute(map);
@ -926,7 +926,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception {
void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception {
Map<String, Object> map = Collections.singletonMap(VALUE, 42L);
assertThatIllegalArgumentException().isThrownBy(() ->
synthesizeAnnotation(map, Component.class, null))
@ -935,7 +935,7 @@ public class AnnotationUtilsTests {
}
@Test
public void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() throws Exception {
void synthesizeAnnotationFromAnnotationAttributesWithoutAttributeAliases() throws Exception {
// 1) Get an annotation
Component component = WebController.class.getAnnotation(Component.class);
assertThat(component).isNotNull();
@ -956,7 +956,7 @@ public class AnnotationUtilsTests {
}
@Test // gh-22702
public void findAnnotationWithRepeatablesElements() {
void findAnnotationWithRepeatablesElements() {
assertThat(AnnotationUtils.findAnnotation(TestRepeatablesClass.class,
TestRepeatable.class)).isNull();
assertThat(AnnotationUtils.findAnnotation(TestRepeatablesClass.class,
@ -1216,6 +1216,7 @@ public class AnnotationUtilsTests {
public static class ImplementsInterfaceWithGenericAnnotatedMethod implements InterfaceWithGenericAnnotatedMethod<String> {
@Override
public void foo(String t) {
}
}
@ -1228,6 +1229,7 @@ public class AnnotationUtilsTests {
public static class ExtendsBaseClassWithGenericAnnotatedMethod extends BaseClassWithGenericAnnotatedMethod<String> {
@Override
public void foo(String t) {
}
}

View File

@ -42,92 +42,92 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
public class AnnotationsScannerTests {
class AnnotationsScannerTests {
@Test
public void directStrategyOnClassWhenNotAnnoatedScansNone() {
void directStrategyOnClassWhenNotAnnoatedScansNone() {
Class<?> source = WithNoAnnotations.class;
assertThat(scan(source, SearchStrategy.DIRECT)).isEmpty();
}
@Test
public void directStrategyOnClassScansAnnotations() {
void directStrategyOnClassScansAnnotations() {
Class<?> source = WithSingleAnnotation.class;
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void directStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
void directStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
Class<?> source = WithMultipleAnnotations.class;
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void directStrategyOnClassWhenHasSuperclassScansOnlyDirect() {
void directStrategyOnClassWhenHasSuperclassScansOnlyDirect() {
Class<?> source = WithSingleSuperclass.class;
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void directStrategyOnClassWhenHasInterfaceScansOnlyDirect() {
void directStrategyOnClassWhenHasInterfaceScansOnlyDirect() {
Class<?> source = WithSingleInterface.class;
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void directStrategyOnClassHierarchyScansInCorrectOrder() {
void directStrategyOnClassHierarchyScansInCorrectOrder() {
Class<?> source = WithHierarchy.class;
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void inheritedAnnotationsStrategyOnClassWhenNotAnnoatedScansNone() {
void inheritedAnnotationsStrategyOnClassWhenNotAnnoatedScansNone() {
Class<?> source = WithNoAnnotations.class;
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).isEmpty();
}
@Test
public void inheritedAnnotationsStrategyOnClassScansAnnotations() {
void inheritedAnnotationsStrategyOnClassScansAnnotations() {
Class<?> source = WithSingleAnnotation.class;
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void inheritedAnnotationsStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
void inheritedAnnotationsStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
Class<?> source = WithMultipleAnnotations.class;
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void inheritedAnnotationsStrategyOnClassWhenHasSuperclassScansOnlyInherited() {
void inheritedAnnotationsStrategyOnClassWhenHasSuperclassScansOnlyInherited() {
Class<?> source = WithSingleSuperclass.class;
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1", "1:TestInheritedAnnotation2");
}
@Test
public void inheritedAnnotationsStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() {
void inheritedAnnotationsStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() {
Class<?> source = WithSingleInterface.class;
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void inheritedAnnotationsStrategyOnClassHierarchyScansInCorrectOrder() {
void inheritedAnnotationsStrategyOnClassHierarchyScansInCorrectOrder() {
Class<?> source = WithHierarchy.class;
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1", "1:TestInheritedAnnotation2");
}
@Test
public void inheritedAnnotationsStrategyOnClassWhenHasAnnotationOnBothClassesIncudesOnlyOne() {
void inheritedAnnotationsStrategyOnClassWhenHasAnnotationOnBothClassesIncudesOnlyOne() {
Class<?> source = WithSingleSuperclassAndDoubleInherited.class;
assertThat(Arrays.stream(source.getAnnotations()).map(
Annotation::annotationType).map(Class::getName)).containsExactly(
@ -137,41 +137,41 @@ public class AnnotationsScannerTests {
}
@Test
public void superclassStrategyOnClassWhenNotAnnoatedScansNone() {
void superclassStrategyOnClassWhenNotAnnoatedScansNone() {
Class<?> source = WithNoAnnotations.class;
assertThat(scan(source, SearchStrategy.SUPERCLASS)).isEmpty();
}
@Test
public void superclassStrategyOnClassScansAnnotations() {
void superclassStrategyOnClassScansAnnotations() {
Class<?> source = WithSingleAnnotation.class;
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void superclassStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
void superclassStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
Class<?> source = WithMultipleAnnotations.class;
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void superclassStrategyOnClassWhenHasSuperclassScansSuperclass() {
void superclassStrategyOnClassWhenHasSuperclassScansSuperclass() {
Class<?> source = WithSingleSuperclass.class;
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void superclassStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() {
void superclassStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() {
Class<?> source = WithSingleInterface.class;
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void superclassStrategyOnClassHierarchyScansInCorrectOrder() {
void superclassStrategyOnClassHierarchyScansInCorrectOrder() {
Class<?> source = WithHierarchy.class;
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2",
@ -179,41 +179,41 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyStrategyOnClassWhenNotAnnoatedScansNone() {
void typeHierarchyStrategyOnClassWhenNotAnnoatedScansNone() {
Class<?> source = WithNoAnnotations.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).isEmpty();
}
@Test
public void typeHierarchyStrategyOnClassScansAnnotations() {
void typeHierarchyStrategyOnClassScansAnnotations() {
Class<?> source = WithSingleAnnotation.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void typeHierarchyStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
void typeHierarchyStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
Class<?> source = WithMultipleAnnotations.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void typeHierarchyStrategyOnClassWhenHasSuperclassScansSuperclass() {
void typeHierarchyStrategyOnClassWhenHasSuperclassScansSuperclass() {
Class<?> source = WithSingleSuperclass.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void typeHierarchyStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() {
void typeHierarchyStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() {
Class<?> source = WithSingleInterface.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void typeHierarchyStrategyOnClassHierarchyScansInCorrectOrder() {
void typeHierarchyStrategyOnClassHierarchyScansInCorrectOrder() {
Class<?> source = WithHierarchy.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5",
@ -222,123 +222,123 @@ public class AnnotationsScannerTests {
}
@Test
public void directStrategyOnMethodWhenNotAnnoatedScansNone() {
void directStrategyOnMethodWhenNotAnnoatedScansNone() {
Method source = methodFrom(WithNoAnnotations.class);
assertThat(scan(source, SearchStrategy.DIRECT)).isEmpty();
}
@Test
public void directStrategyOnMethodScansAnnotations() {
void directStrategyOnMethodScansAnnotations() {
Method source = methodFrom(WithSingleAnnotation.class);
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void directStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
void directStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
Method source = methodFrom(WithMultipleAnnotations.class);
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void directStrategyOnMethodWhenHasSuperclassScansOnlyDirect() {
void directStrategyOnMethodWhenHasSuperclassScansOnlyDirect() {
Method source = methodFrom(WithSingleSuperclass.class);
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void directStrategyOnMethodWhenHasInterfaceScansOnlyDirect() {
void directStrategyOnMethodWhenHasInterfaceScansOnlyDirect() {
Method source = methodFrom(WithSingleInterface.class);
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void directStrategyOnMethodHierarchyScansInCorrectOrder() {
void directStrategyOnMethodHierarchyScansInCorrectOrder() {
Method source = methodFrom(WithHierarchy.class);
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void inheritedAnnotationsStrategyOnMethodWhenNotAnnoatedScansNone() {
void inheritedAnnotationsStrategyOnMethodWhenNotAnnoatedScansNone() {
Method source = methodFrom(WithNoAnnotations.class);
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).isEmpty();
}
@Test
public void inheritedAnnotationsStrategyOnMethodScansAnnotations() {
void inheritedAnnotationsStrategyOnMethodScansAnnotations() {
Method source = methodFrom(WithSingleAnnotation.class);
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void inheritedAnnotationsStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
void inheritedAnnotationsStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
Method source = methodFrom(WithMultipleAnnotations.class);
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void inheritedAnnotationsMethodOnMethodWhenHasSuperclassIgnoresInherited() {
void inheritedAnnotationsMethodOnMethodWhenHasSuperclassIgnoresInherited() {
Method source = methodFrom(WithSingleSuperclass.class);
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void inheritedAnnotationsStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() {
void inheritedAnnotationsStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() {
Method source = methodFrom(WithSingleInterface.class);
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void inheritedAnnotationsStrategyOnMethodHierarchyScansInCorrectOrder() {
void inheritedAnnotationsStrategyOnMethodHierarchyScansInCorrectOrder() {
Method source = methodFrom(WithHierarchy.class);
assertThat(scan(source, SearchStrategy.INHERITED_ANNOTATIONS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void superclassStrategyOnMethodWhenNotAnnoatedScansNone() {
void superclassStrategyOnMethodWhenNotAnnoatedScansNone() {
Method source = methodFrom(WithNoAnnotations.class);
assertThat(scan(source, SearchStrategy.SUPERCLASS)).isEmpty();
}
@Test
public void superclassStrategyOnMethodScansAnnotations() {
void superclassStrategyOnMethodScansAnnotations() {
Method source = methodFrom(WithSingleAnnotation.class);
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void superclassStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
void superclassStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
Method source = methodFrom(WithMultipleAnnotations.class);
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void superclassStrategyOnMethodWhenHasSuperclassScansSuperclass() {
void superclassStrategyOnMethodWhenHasSuperclassScansSuperclass() {
Method source = methodFrom(WithSingleSuperclass.class);
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void superclassStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() {
void superclassStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() {
Method source = methodFrom(WithSingleInterface.class);
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void superclassStrategyOnMethodHierarchyScansInCorrectOrder() {
void superclassStrategyOnMethodHierarchyScansInCorrectOrder() {
Method source = methodFrom(WithHierarchy.class);
assertThat(scan(source, SearchStrategy.SUPERCLASS)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2",
@ -346,41 +346,41 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyStrategyOnMethodWhenNotAnnoatedScansNone() {
void typeHierarchyStrategyOnMethodWhenNotAnnoatedScansNone() {
Method source = methodFrom(WithNoAnnotations.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).isEmpty();
}
@Test
public void typeHierarchyStrategyOnMethodScansAnnotations() {
void typeHierarchyStrategyOnMethodScansAnnotations() {
Method source = methodFrom(WithSingleAnnotation.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void typeHierarchyStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
void typeHierarchyStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
Method source = methodFrom(WithMultipleAnnotations.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void typeHierarchyStrategyOnMethodWhenHasSuperclassScansSuperclass() {
void typeHierarchyStrategyOnMethodWhenHasSuperclassScansSuperclass() {
Method source = methodFrom(WithSingleSuperclass.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void typeHierarchyStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() {
void typeHierarchyStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() {
Method source = methodFrom(WithSingleInterface.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void typeHierarchyStrategyOnMethodHierarchyScansInCorrectOrder() {
void typeHierarchyStrategyOnMethodHierarchyScansInCorrectOrder() {
Method source = methodFrom(WithHierarchy.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5",
@ -389,7 +389,7 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyStrategyOnBridgeMethodScansAnnotations() throws Exception {
void typeHierarchyStrategyOnBridgeMethodScansAnnotations() throws Exception {
Method source = BridgedMethod.class.getDeclaredMethod("method", Object.class);
assertThat(source.isBridge()).isTrue();
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
@ -397,7 +397,7 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyStrategyOnBridgedMethodScansAnnotations() throws Exception {
void typeHierarchyStrategyOnBridgedMethodScansAnnotations() throws Exception {
Method source = BridgedMethod.class.getDeclaredMethod("method", String.class);
assertThat(source.isBridge()).isFalse();
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
@ -405,7 +405,7 @@ public class AnnotationsScannerTests {
}
@Test
public void directStrategyOnBridgeMethodScansAnnotations() throws Exception {
void directStrategyOnBridgeMethodScansAnnotations() throws Exception {
Method source = BridgedMethod.class.getDeclaredMethod("method", Object.class);
assertThat(source.isBridge()).isTrue();
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
@ -413,7 +413,7 @@ public class AnnotationsScannerTests {
}
@Test
public void dirextStrategyOnBridgedMethodScansAnnotations() throws Exception {
void dirextStrategyOnBridgedMethodScansAnnotations() throws Exception {
Method source = BridgedMethod.class.getDeclaredMethod("method", String.class);
assertThat(source.isBridge()).isFalse();
assertThat(scan(source, SearchStrategy.DIRECT)).containsExactly(
@ -421,7 +421,7 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyStrategyOnMethodWithIgnorablesScansAnnotations()
void typeHierarchyStrategyOnMethodWithIgnorablesScansAnnotations()
throws Exception {
Method source = methodFrom(Ignoreable.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
@ -429,7 +429,7 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyStrategyOnMethodWithMultipleCandidatesScansAnnotations()
void typeHierarchyStrategyOnMethodWithMultipleCandidatesScansAnnotations()
throws Exception {
Method source = methodFrom(MultipleMethods.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
@ -437,7 +437,7 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyStrategyOnMethodWithGenericParameterOverrideScansAnnotations()
void typeHierarchyStrategyOnMethodWithGenericParameterOverrideScansAnnotations()
throws Exception {
Method source = ReflectionUtils.findMethod(GenericOverride.class, "method",
String.class);
@ -446,7 +446,7 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyStrategyOnMethodWithGenericParameterNonOverrideScansAnnotations()
void typeHierarchyStrategyOnMethodWithGenericParameterNonOverrideScansAnnotations()
throws Exception {
Method source = ReflectionUtils.findMethod(GenericNonOverride.class, "method",
StringBuilder.class);
@ -455,21 +455,21 @@ public class AnnotationsScannerTests {
}
@Test
public void typeHierarchyWithEnclosedStrategyOnEnclosedStaticClassScansAnnotations() {
void typeHierarchyWithEnclosedStrategyOnEnclosedStaticClassScansAnnotations() {
Class<?> source = AnnotationEnclosingClassSample.EnclosedStatic.EnclosedStaticStatic.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES))
.containsExactly("0:EnclosedThree", "1:EnclosedTwo", "2:EnclosedOne");
}
@Test
public void typeHierarchyWithEnclosedStrategyOnEnclosedInnerClassScansAnnotations() {
void typeHierarchyWithEnclosedStrategyOnEnclosedInnerClassScansAnnotations() {
Class<?> source = AnnotationEnclosingClassSample.EnclosedInner.EnclosedInnerInner.class;
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES))
.containsExactly("0:EnclosedThree", "1:EnclosedTwo", "2:EnclosedOne");
}
@Test
public void typeHierarchyWithEnclosedStrategyOnMethodHierarchyUsesTypeHierarchyScan() {
void typeHierarchyWithEnclosedStrategyOnMethodHierarchyUsesTypeHierarchyScan() {
Method source = methodFrom(WithHierarchy.class);
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY_AND_ENCLOSING_CLASSES)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5",
@ -478,7 +478,7 @@ public class AnnotationsScannerTests {
}
@Test
public void scanWhenProcessorReturnsFromDoWithAggregateExitsEarly() {
void scanWhenProcessorReturnsFromDoWithAggregateExitsEarly() {
String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class,
SearchStrategy.TYPE_HIERARCHY, new AnnotationsProcessor<Object, String>() {
@ -500,7 +500,7 @@ public class AnnotationsScannerTests {
}
@Test
public void scanWhenProcessorReturnsFromDoWithAnnotationsExitsEarly() {
void scanWhenProcessorReturnsFromDoWithAnnotationsExitsEarly() {
List<Integer> indexes = new ArrayList<>();
String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class,
SearchStrategy.TYPE_HIERARCHY,
@ -513,7 +513,7 @@ public class AnnotationsScannerTests {
}
@Test
public void scanWhenProcessorHasFinishMethodUsesFinishResult() {
void scanWhenProcessorHasFinishMethodUsesFinishResult() {
String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class,
SearchStrategy.TYPE_HIERARCHY, new AnnotationsProcessor<Object, String>() {
@ -651,6 +651,7 @@ public class AnnotationsScannerTests {
@TestAnnotation1
static class WithSingleSuperclass extends SingleSuperclass {
@Override
@TestAnnotation1
public void method() {
}
@ -659,6 +660,7 @@ public class AnnotationsScannerTests {
@TestInheritedAnnotation2
static class WithSingleSuperclassAndDoubleInherited extends SingleSuperclass {
@Override
@TestAnnotation1
public void method() {
}
@ -667,6 +669,7 @@ public class AnnotationsScannerTests {
@TestAnnotation1
static class WithSingleInterface implements SingleInterface {
@Override
@TestAnnotation1
public void method() {
}
@ -684,6 +687,7 @@ public class AnnotationsScannerTests {
@TestAnnotation1
static class WithHierarchy extends HierarchySuperclass implements HierarchyInterface {
@Override
@TestAnnotation1
public void method() {
}
@ -693,6 +697,7 @@ public class AnnotationsScannerTests {
@TestInheritedAnnotation2
static class HierarchySuperclass extends HierarchySuperSuperclass {
@Override
@TestAnnotation2
@TestInheritedAnnotation2
public void method() {
@ -702,6 +707,7 @@ public class AnnotationsScannerTests {
@TestAnnotation3
static class HierarchySuperSuperclass implements HierarchySuperSuperclassInterface {
@Override
@TestAnnotation3
public void method() {
}
@ -718,6 +724,7 @@ public class AnnotationsScannerTests {
@TestInheritedAnnotation5
interface HierarchyInterface extends HierarchyInterfaceInterface {
@Override
@TestAnnotation5
@TestInheritedAnnotation5
void method();
@ -747,6 +754,7 @@ public class AnnotationsScannerTests {
@SuppressWarnings("serial")
static class Ignoreable implements IgnoreableOverrideInterface1, IgnoreableOverrideInterface2, Serializable {
@Override
@TestAnnotation1
public void method() {
}
@ -782,6 +790,7 @@ public class AnnotationsScannerTests {
static class GenericOverride implements GenericOverrideInterface<String> {
@Override
@TestAnnotation1
public void method(String argument) {
}

View File

@ -36,22 +36,22 @@ import static org.mockito.Mockito.mock;
*
* @author Phillip Webb
*/
public class AttributeMethodsTests {
class AttributeMethodsTests {
@Test
public void forAnnotationTypeWhenNullReturnsNone() {
void forAnnotationTypeWhenNullReturnsNone() {
AttributeMethods methods = AttributeMethods.forAnnotationType(null);
assertThat(methods).isSameAs(AttributeMethods.NONE);
}
@Test
public void forAnnotationTypeWhenHasNoAttributesReturnsNone() {
void forAnnotationTypeWhenHasNoAttributesReturnsNone() {
AttributeMethods methods = AttributeMethods.forAnnotationType(NoAttributes.class);
assertThat(methods).isSameAs(AttributeMethods.NONE);
}
@Test
public void forAnnotationTypeWhenHasMultipleAttributesReturnsAttributes() {
void forAnnotationTypeWhenHasMultipleAttributesReturnsAttributes() {
AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class);
assertThat(methods.get("value").getName()).isEqualTo("value");
assertThat(methods.get("intValue").getName()).isEqualTo("intValue");
@ -59,74 +59,74 @@ public class AttributeMethodsTests {
}
@Test
public void hasOnlyValueAttributeWhenHasOnlyValueAttributeReturnsTrue() {
void hasOnlyValueAttributeWhenHasOnlyValueAttributeReturnsTrue() {
AttributeMethods methods = AttributeMethods.forAnnotationType(ValueOnly.class);
assertThat(methods.hasOnlyValueAttribute()).isTrue();
}
@Test
public void hasOnlyValueAttributeWhenHasOnlySingleNonValueAttributeReturnsFalse() {
void hasOnlyValueAttributeWhenHasOnlySingleNonValueAttributeReturnsFalse() {
AttributeMethods methods = AttributeMethods.forAnnotationType(NonValueOnly.class);
assertThat(methods.hasOnlyValueAttribute()).isFalse();
}
@Test
public void hasOnlyValueAttributeWhenHasOnlyMultipleAttributesIncludingValueReturnsFalse() {
void hasOnlyValueAttributeWhenHasOnlyMultipleAttributesIncludingValueReturnsFalse() {
AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class);
assertThat(methods.hasOnlyValueAttribute()).isFalse();
}
@Test
public void indexOfNameReturnsIndex() {
void indexOfNameReturnsIndex() {
AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class);
assertThat(methods.indexOf("value")).isEqualTo(1);
}
@Test
public void indexOfMethodReturnsIndex() throws Exception {
void indexOfMethodReturnsIndex() throws Exception {
AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class);
Method method = MultipleAttributes.class.getDeclaredMethod("value");
assertThat(methods.indexOf(method)).isEqualTo(1);
}
@Test
public void sizeReturnsSize() {
void sizeReturnsSize() {
AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class);
assertThat(methods.size()).isEqualTo(2);
}
@Test
public void canThrowTypeNotPresentExceptionWhenHasClassAttributeReturnsTrue() {
void canThrowTypeNotPresentExceptionWhenHasClassAttributeReturnsTrue() {
AttributeMethods methods = AttributeMethods.forAnnotationType(ClassValue.class);
assertThat(methods.canThrowTypeNotPresentException(0)).isTrue();
}
@Test
public void canThrowTypeNotPresentExceptionWhenHasClassArrayAttributeReturnsTrue() {
void canThrowTypeNotPresentExceptionWhenHasClassArrayAttributeReturnsTrue() {
AttributeMethods methods = AttributeMethods.forAnnotationType(ClassArrayValue.class);
assertThat(methods.canThrowTypeNotPresentException(0)).isTrue();
}
@Test
public void canThrowTypeNotPresentExceptionWhenNotClassOrClassArrayAttributeReturnsFalse() {
void canThrowTypeNotPresentExceptionWhenNotClassOrClassArrayAttributeReturnsFalse() {
AttributeMethods methods = AttributeMethods.forAnnotationType(ValueOnly.class);
assertThat(methods.canThrowTypeNotPresentException(0)).isFalse();
}
@Test
public void hasDefaultValueMethodWhenHasDefaultValueMethodReturnsTrue() {
void hasDefaultValueMethodWhenHasDefaultValueMethodReturnsTrue() {
AttributeMethods methods = AttributeMethods.forAnnotationType(DefaultValueAttribute.class);
assertThat(methods.hasDefaultValueMethod()).isTrue();
}
@Test
public void hasDefaultValueMethodWhenHasNoDefaultValueMethodsReturnsFalse() {
void hasDefaultValueMethodWhenHasNoDefaultValueMethodsReturnsFalse() {
AttributeMethods methods = AttributeMethods.forAnnotationType(MultipleAttributes.class);
assertThat(methods.hasDefaultValueMethod()).isFalse();
}
@Test
public void isValidWhenHasTypeNotPresentExceptionReturnsFalse() {
void isValidWhenHasTypeNotPresentExceptionReturnsFalse() {
ClassValue annotation = mockAnnotation(ClassValue.class);
given(annotation.value()).willThrow(TypeNotPresentException.class);
AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType());
@ -135,7 +135,7 @@ public class AttributeMethodsTests {
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void isValidWhenDoesNotHaveTypeNotPresentExceptionReturnsTrue() {
void isValidWhenDoesNotHaveTypeNotPresentExceptionReturnsTrue() {
ClassValue annotation = mock(ClassValue.class);
given(annotation.value()).willReturn((Class) InputStream.class);
AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType());
@ -143,7 +143,7 @@ public class AttributeMethodsTests {
}
@Test
public void validateWhenHasTypeNotPresentExceptionThrowsException() {
void validateWhenHasTypeNotPresentExceptionThrowsException() {
ClassValue annotation = mockAnnotation(ClassValue.class);
given(annotation.value()).willThrow(TypeNotPresentException.class);
AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType());
@ -152,7 +152,7 @@ public class AttributeMethodsTests {
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void validateWhenDoesNotHaveTypeNotPresentExceptionThrowsNothing() {
void validateWhenDoesNotHaveTypeNotPresentExceptionThrowsNothing() {
ClassValue annotation = mockAnnotation(ClassValue.class);
given(annotation.value()).willReturn((Class) InputStream.class);
AttributeMethods attributes = AttributeMethods.forAnnotationType(annotation.annotationType());

View File

@ -48,67 +48,67 @@ import static org.springframework.core.annotation.AnnotatedElementUtils.getMerge
* @see AnnotatedElementUtilsTests
* @see MultipleComposedAnnotationsOnSingleAnnotatedElementTests
*/
public class ComposedRepeatableAnnotationsTests {
class ComposedRepeatableAnnotationsTests {
@Test
public void getNonRepeatableAnnotation() {
void getNonRepeatableAnnotation() {
expectNonRepeatableAnnotation(() ->
getMergedRepeatableAnnotations(getClass(), NonRepeatable.class));
}
@Test
public void getInvalidRepeatableAnnotationContainerMissingValueAttribute() {
void getInvalidRepeatableAnnotationContainerMissingValueAttribute() {
expectContainerMissingValueAttribute(() ->
getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerMissingValueAttribute.class));
}
@Test
public void getInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() {
void getInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() {
expectContainerWithNonArrayValueAttribute(() ->
getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithNonArrayValueAttribute.class));
}
@Test
public void getInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() {
void getInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() {
expectContainerWithArrayValueAttributeButWrongComponentType(() ->
getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithArrayValueAttributeButWrongComponentType.class));
}
@Test
public void getRepeatableAnnotationsOnClass() {
void getRepeatableAnnotationsOnClass() {
assertGetRepeatableAnnotations(RepeatableClass.class);
}
@Test
public void getRepeatableAnnotationsOnSuperclass() {
void getRepeatableAnnotationsOnSuperclass() {
assertGetRepeatableAnnotations(SubRepeatableClass.class);
}
@Test
public void getComposedRepeatableAnnotationsOnClass() {
void getComposedRepeatableAnnotationsOnClass() {
assertGetRepeatableAnnotations(ComposedRepeatableClass.class);
}
@Test
public void getComposedRepeatableAnnotationsMixedWithContainerOnClass() {
void getComposedRepeatableAnnotationsMixedWithContainerOnClass() {
assertGetRepeatableAnnotations(ComposedRepeatableMixedWithContainerClass.class);
}
@Test
public void getComposedContainerForRepeatableAnnotationsOnClass() {
void getComposedContainerForRepeatableAnnotationsOnClass() {
assertGetRepeatableAnnotations(ComposedContainerClass.class);
}
@Test
public void getNoninheritedComposedRepeatableAnnotationsOnClass() {
void getNoninheritedComposedRepeatableAnnotationsOnClass() {
Class<?> element = NoninheritedRepeatableClass.class;
Set<Noninherited> annotations = getMergedRepeatableAnnotations(element, Noninherited.class);
assertNoninheritedRepeatableAnnotations(annotations);
}
@Test
public void getNoninheritedComposedRepeatableAnnotationsOnSuperclass() {
void getNoninheritedComposedRepeatableAnnotationsOnSuperclass() {
Class<?> element = SubNoninheritedRepeatableClass.class;
Set<Noninherited> annotations = getMergedRepeatableAnnotations(element, Noninherited.class);
assertThat(annotations).isNotNull();
@ -116,66 +116,66 @@ public class ComposedRepeatableAnnotationsTests {
}
@Test
public void findNonRepeatableAnnotation() {
void findNonRepeatableAnnotation() {
expectNonRepeatableAnnotation(() ->
findMergedRepeatableAnnotations(getClass(), NonRepeatable.class));
}
@Test
public void findInvalidRepeatableAnnotationContainerMissingValueAttribute() {
void findInvalidRepeatableAnnotationContainerMissingValueAttribute() {
expectContainerMissingValueAttribute(() ->
findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerMissingValueAttribute.class));
}
@Test
public void findInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() {
void findInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() {
expectContainerWithNonArrayValueAttribute(() ->
findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithNonArrayValueAttribute.class));
}
@Test
public void findInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() {
void findInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() {
expectContainerWithArrayValueAttributeButWrongComponentType(() ->
findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class,
ContainerWithArrayValueAttributeButWrongComponentType.class));
}
@Test
public void findRepeatableAnnotationsOnClass() {
void findRepeatableAnnotationsOnClass() {
assertFindRepeatableAnnotations(RepeatableClass.class);
}
@Test
public void findRepeatableAnnotationsOnSuperclass() {
void findRepeatableAnnotationsOnSuperclass() {
assertFindRepeatableAnnotations(SubRepeatableClass.class);
}
@Test
public void findComposedRepeatableAnnotationsOnClass() {
void findComposedRepeatableAnnotationsOnClass() {
assertFindRepeatableAnnotations(ComposedRepeatableClass.class);
}
@Test
public void findComposedRepeatableAnnotationsMixedWithContainerOnClass() {
void findComposedRepeatableAnnotationsMixedWithContainerOnClass() {
assertFindRepeatableAnnotations(ComposedRepeatableMixedWithContainerClass.class);
}
@Test
public void findNoninheritedComposedRepeatableAnnotationsOnClass() {
void findNoninheritedComposedRepeatableAnnotationsOnClass() {
Class<?> element = NoninheritedRepeatableClass.class;
Set<Noninherited> annotations = findMergedRepeatableAnnotations(element, Noninherited.class);
assertNoninheritedRepeatableAnnotations(annotations);
}
@Test
public void findNoninheritedComposedRepeatableAnnotationsOnSuperclass() {
void findNoninheritedComposedRepeatableAnnotationsOnSuperclass() {
Class<?> element = SubNoninheritedRepeatableClass.class;
Set<Noninherited> annotations = findMergedRepeatableAnnotations(element, Noninherited.class);
assertNoninheritedRepeatableAnnotations(annotations);
}
@Test
public void findComposedContainerForRepeatableAnnotationsOnClass() {
void findComposedContainerForRepeatableAnnotationsOnClass() {
assertFindRepeatableAnnotations(ComposedContainerClass.class);
}

View File

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @since 5.2
*/
public class MergedAnnotationClassLoaderTests {
class MergedAnnotationClassLoaderTests {
private static final String TEST_ANNOTATION = TestAnnotation.class.getName();
@ -45,7 +45,7 @@ public class MergedAnnotationClassLoaderTests {
private static final String TEST_REFERENCE = TestReference.class.getName();
@Test
public void synthesizedUsesCorrectClassLoader() throws Exception {
void synthesizedUsesCorrectClassLoader() throws Exception {
ClassLoader parent = getClass().getClassLoader();
TestClassLoader child = new TestClassLoader(parent);
Class<?> source = child.loadClass(WITH_TEST_ANNOTATION);

View File

@ -37,10 +37,10 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
public class MergedAnnotationCollectorsTests {
class MergedAnnotationCollectorsTests {
@Test
public void toAnnotationSetCollectsLinkedHashSetWithSynthesizedAnnotations() {
void toAnnotationSetCollectsLinkedHashSetWithSynthesizedAnnotations() {
Set<TestAnnotation> set = stream().collect(
MergedAnnotationCollectors.toAnnotationSet());
assertThat(set).isInstanceOf(LinkedHashSet.class).flatExtracting(
@ -49,7 +49,7 @@ public class MergedAnnotationCollectorsTests {
}
@Test
public void toAnnotationArrayCollectsAnnotationArrayWithSynthesizedAnnotations() {
void toAnnotationArrayCollectsAnnotationArrayWithSynthesizedAnnotations() {
Annotation[] array = stream().collect(
MergedAnnotationCollectors.toAnnotationArray());
assertThat(Arrays.stream(array).map(
@ -59,7 +59,7 @@ public class MergedAnnotationCollectorsTests {
}
@Test
public void toSuppliedAnnotationArrayCollectsAnnotationArrayWithSynthesizedAnnotations() {
void toSuppliedAnnotationArrayCollectsAnnotationArrayWithSynthesizedAnnotations() {
TestAnnotation[] array = stream().collect(
MergedAnnotationCollectors.toAnnotationArray(TestAnnotation[]::new));
assertThat(Arrays.stream(array).map(TestAnnotation::value)).containsExactly("a",
@ -68,7 +68,7 @@ public class MergedAnnotationCollectorsTests {
}
@Test
public void toMultiValueMapCollectsMultiValueMap() {
void toMultiValueMapCollectsMultiValueMap() {
MultiValueMap<String, Object> map = stream().map(
MergedAnnotation::filterDefaultValues).collect(
MergedAnnotationCollectors.toMultiValueMap(
@ -79,7 +79,7 @@ public class MergedAnnotationCollectorsTests {
}
@Test
public void toFinishedMultiValueMapCollectsMultiValueMap() {
void toFinishedMultiValueMapCollectsMultiValueMap() {
MultiValueMap<String, Object> map = stream().collect(
MergedAnnotationCollectors.toMultiValueMap(result -> {
result.add("finished", true);

View File

@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Phillip Webb
*/
public class MergedAnnotationPredicatesTests {
class MergedAnnotationPredicatesTests {
@Test
public void typeInStringArrayWhenNameMatchesAccepts() {
void typeInStringArrayWhenNameMatchesAccepts() {
MergedAnnotation<TestAnnotation> annotation = MergedAnnotations.from(
WithTestAnnotation.class).get(TestAnnotation.class);
assertThat(MergedAnnotationPredicates.typeIn(
@ -45,7 +45,7 @@ public class MergedAnnotationPredicatesTests {
}
@Test
public void typeInStringArrayWhenNameDoesNotMatchRejects() {
void typeInStringArrayWhenNameDoesNotMatchRejects() {
MergedAnnotation<TestAnnotation> annotation = MergedAnnotations.from(
WithTestAnnotation.class).get(TestAnnotation.class);
assertThat(MergedAnnotationPredicates.typeIn(
@ -53,21 +53,21 @@ public class MergedAnnotationPredicatesTests {
}
@Test
public void typeInClassArrayWhenNameMatchesAccepts() {
void typeInClassArrayWhenNameMatchesAccepts() {
MergedAnnotation<TestAnnotation> annotation =
MergedAnnotations.from(WithTestAnnotation.class).get(TestAnnotation.class);
assertThat(MergedAnnotationPredicates.typeIn(TestAnnotation.class)).accepts(annotation);
}
@Test
public void typeInClassArrayWhenNameDoesNotMatchRejects() {
void typeInClassArrayWhenNameDoesNotMatchRejects() {
MergedAnnotation<TestAnnotation> annotation =
MergedAnnotations.from(WithTestAnnotation.class).get(TestAnnotation.class);
assertThat(MergedAnnotationPredicates.typeIn(MissingAnnotation.class)).rejects(annotation);
}
@Test
public void typeInCollectionWhenMatchesStringInCollectionAccepts() {
void typeInCollectionWhenMatchesStringInCollectionAccepts() {
MergedAnnotation<TestAnnotation> annotation = MergedAnnotations.from(
WithTestAnnotation.class).get(TestAnnotation.class);
assertThat(MergedAnnotationPredicates.typeIn(
@ -75,7 +75,7 @@ public class MergedAnnotationPredicatesTests {
}
@Test
public void typeInCollectionWhenMatchesClassInCollectionAccepts() {
void typeInCollectionWhenMatchesClassInCollectionAccepts() {
MergedAnnotation<TestAnnotation> annotation = MergedAnnotations.from(
WithTestAnnotation.class).get(TestAnnotation.class);
assertThat(MergedAnnotationPredicates.typeIn(
@ -83,7 +83,7 @@ public class MergedAnnotationPredicatesTests {
}
@Test
public void typeInCollectionWhenDoesNotMatchAnyRejects() {
void typeInCollectionWhenDoesNotMatchAnyRejects() {
MergedAnnotation<TestAnnotation> annotation = MergedAnnotations.from(
WithTestAnnotation.class).get(TestAnnotation.class);
assertThat(MergedAnnotationPredicates.typeIn(Arrays.asList(
@ -91,7 +91,7 @@ public class MergedAnnotationPredicatesTests {
}
@Test
public void firstRunOfAcceptsOnlyFirstRun() {
void firstRunOfAcceptsOnlyFirstRun() {
List<MergedAnnotation<TestAnnotation>> filtered = MergedAnnotations.from(
WithMultipleTestAnnotation.class).stream(TestAnnotation.class).filter(
MergedAnnotationPredicates.firstRunOf(
@ -101,13 +101,13 @@ public class MergedAnnotationPredicatesTests {
}
@Test
public void firstRunOfWhenValueExtractorIsNullThrowsException() {
void firstRunOfWhenValueExtractorIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
MergedAnnotationPredicates.firstRunOf(null));
}
@Test
public void uniqueAcceptsUniquely() {
void uniqueAcceptsUniquely() {
List<MergedAnnotation<TestAnnotation>> filtered = MergedAnnotations.from(
WithMultipleTestAnnotation.class).stream(TestAnnotation.class).filter(
MergedAnnotationPredicates.unique(
@ -117,7 +117,7 @@ public class MergedAnnotationPredicatesTests {
}
@Test
public void uniqueWhenKeyExtractorIsNullThrowsException() {
void uniqueWhenKeyExtractorIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
MergedAnnotationPredicates.unique(null));
}

View File

@ -36,23 +36,23 @@ import static org.mockito.Mockito.mock;
*
* @author Phillip Webb
*/
public class MergedAnnotationsCollectionTests {
class MergedAnnotationsCollectionTests {
@Test
public void ofWhenDirectAnnotationsIsNullThrowsException() {
void ofWhenDirectAnnotationsIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(
() -> MergedAnnotationsCollection.of(null)).withMessage(
"Annotations must not be null");
}
@Test
public void ofWhenEmptyReturnsSharedNoneInstance() {
void ofWhenEmptyReturnsSharedNoneInstance() {
MergedAnnotations annotations = MergedAnnotationsCollection.of(new ArrayList<>());
assertThat(annotations).isSameAs(TypeMappedAnnotations.NONE);
}
@Test
public void createWhenAnnotationIsNotDirectlyPresentThrowsException() {
void createWhenAnnotationIsNotDirectlyPresentThrowsException() {
MergedAnnotation<?> annotation = mock(MergedAnnotation.class);
given(annotation.isDirectlyPresent()).willReturn(false);
assertThatIllegalArgumentException().isThrownBy(() ->
@ -61,7 +61,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void createWhenAnnotationAggregateIndexIsNotZeroThrowsException() {
void createWhenAnnotationAggregateIndexIsNotZeroThrowsException() {
MergedAnnotation<?> annotation = mock(MergedAnnotation.class);
given(annotation.isDirectlyPresent()).willReturn(true);
given(annotation.getAggregateIndex()).willReturn(1);
@ -71,7 +71,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void interateIteratesInCorrectOrder() {
void interateIteratesInCorrectOrder() {
MergedAnnotations annotations = getDirectAndSimple();
List<Class<?>> types = new ArrayList<>();
for (MergedAnnotation<?> annotation : annotations) {
@ -82,7 +82,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void spliteratorIteratesInCorrectOrder() {
void spliteratorIteratesInCorrectOrder() {
MergedAnnotations annotations = getDirectAndSimple();
Spliterator<MergedAnnotation<Annotation>> spliterator = annotations.spliterator();
List<Class<?>> types = new ArrayList<>();
@ -92,7 +92,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void spliteratorEstimatesSize() {
void spliteratorEstimatesSize() {
MergedAnnotations annotations = getDirectAndSimple();
Spliterator<MergedAnnotation<Annotation>> spliterator = annotations.spliterator();
assertThat(spliterator.estimateSize()).isEqualTo(5);
@ -102,21 +102,21 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void isPresentWhenDirectlyPresentReturnsTrue() {
void isPresentWhenDirectlyPresentReturnsTrue() {
MergedAnnotations annotations = getDirectAndSimple();
assertThat(annotations.isPresent(Direct.class)).isTrue();
assertThat(annotations.isPresent(Direct.class.getName())).isTrue();
}
@Test
public void isPresentWhenMetaPresentReturnsTrue() {
void isPresentWhenMetaPresentReturnsTrue() {
MergedAnnotations annotations = getDirectAndSimple();
assertThat(annotations.isPresent(Meta11.class)).isTrue();
assertThat(annotations.isPresent(Meta11.class.getName())).isTrue();
}
@Test
public void isPresentWhenNotPresentReturnsFalse() {
void isPresentWhenNotPresentReturnsFalse() {
MergedAnnotations annotations = getDirectAndSimple();
assertThat(annotations.isPresent(Missing.class)).isFalse();
assertThat(annotations.isPresent(Missing.class.getName())).isFalse();
@ -124,28 +124,28 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void isDirectlyPresentWhenDirectlyPresentReturnsTrue() {
void isDirectlyPresentWhenDirectlyPresentReturnsTrue() {
MergedAnnotations annotations = getDirectAndSimple();
assertThat(annotations.isDirectlyPresent(Direct.class)).isTrue();
assertThat(annotations.isDirectlyPresent(Direct.class.getName())).isTrue();
}
@Test
public void isDirectlyPresentWhenMetaPresentReturnsFalse() {
void isDirectlyPresentWhenMetaPresentReturnsFalse() {
MergedAnnotations annotations = getDirectAndSimple();
assertThat(annotations.isDirectlyPresent(Meta11.class)).isFalse();
assertThat(annotations.isDirectlyPresent(Meta11.class.getName())).isFalse();
}
@Test
public void isDirectlyPresentWhenNotPresentReturnsFalse() {
void isDirectlyPresentWhenNotPresentReturnsFalse() {
MergedAnnotations annotations = getDirectAndSimple();
assertThat(annotations.isDirectlyPresent(Missing.class)).isFalse();
assertThat(annotations.isDirectlyPresent(Missing.class.getName())).isFalse();
}
@Test
public void getReturnsAppropriateAnnotation() {
void getReturnsAppropriateAnnotation() {
MergedAnnotations annotations = getMutiRoute1();
assertThat(annotations.get(MutiRouteTarget.class).getString(
MergedAnnotation.VALUE)).isEqualTo("12");
@ -154,13 +154,13 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void getWhenNotPresentReturnsMissing() {
void getWhenNotPresentReturnsMissing() {
MergedAnnotations annotations = getDirectAndSimple();
assertThat(annotations.get(Missing.class)).isEqualTo(MergedAnnotation.missing());
}
@Test
public void getWithPredicateReturnsOnlyMatching() {
void getWithPredicateReturnsOnlyMatching() {
MergedAnnotations annotations = getMutiRoute1();
assertThat(annotations.get(MutiRouteTarget.class,
annotation -> annotation.getDistance() >= 3).getString(
@ -168,7 +168,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void getWithSelectorReturnsSelected() {
void getWithSelectorReturnsSelected() {
MergedAnnotations annotations = getMutiRoute1();
MergedAnnotationSelector<MutiRouteTarget> deepest = (existing,
candidate) -> candidate.getDistance() > existing.getDistance() ? candidate
@ -178,7 +178,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void streamStreamsInCorrectOrder() {
void streamStreamsInCorrectOrder() {
MergedAnnotations annotations = getDirectAndSimple();
List<Class<?>> types = new ArrayList<>();
annotations.stream().forEach(annotation -> types.add(annotation.getType()));
@ -187,7 +187,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void streamWithTypeStreamsInCorrectOrder() {
void streamWithTypeStreamsInCorrectOrder() {
MergedAnnotations annotations = getMutiRoute1();
List<String> values = new ArrayList<>();
annotations.stream(MutiRouteTarget.class).forEach(
@ -196,7 +196,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void getMetaWhenRootHasAttributeValuesShouldAlaisAttributes() {
void getMetaWhenRootHasAttributeValuesShouldAlaisAttributes() {
MergedAnnotation<Alaised> root = MergedAnnotation.of(null, null, Alaised.class,
Collections.singletonMap("testAlias", "test"));
MergedAnnotations annotations = MergedAnnotationsCollection.of(
@ -206,7 +206,7 @@ public class MergedAnnotationsCollectionTests {
}
@Test
public void getMetaWhenRootHasNoAttributeValuesShouldAlaisAttributes() {
void getMetaWhenRootHasNoAttributeValuesShouldAlaisAttributes() {
MergedAnnotation<Alaised> root = MergedAnnotation.of(null, null, Alaised.class,
Collections.emptyMap());
MergedAnnotations annotations = MergedAnnotationsCollection.of(

View File

@ -41,22 +41,22 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @author Sam Brannen
*/
public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
// See SPR-13486
@Test
public void inheritedStrategyMultipleComposedAnnotationsOnClass() {
void inheritedStrategyMultipleComposedAnnotationsOnClass() {
assertInheritedStrategyBehavior(MultipleComposedCachesClass.class);
}
@Test
public void inheritedStrategyMultipleInheritedComposedAnnotationsOnSuperclass() {
void inheritedStrategyMultipleInheritedComposedAnnotationsOnSuperclass() {
assertInheritedStrategyBehavior(SubMultipleComposedCachesClass.class);
}
@Test
public void inheritedStrategyMultipleNoninheritedComposedAnnotationsOnClass() {
void inheritedStrategyMultipleNoninheritedComposedAnnotationsOnClass() {
MergedAnnotations annotations = MergedAnnotations.from(
MultipleNoninheritedComposedCachesClass.class,
SearchStrategy.INHERITED_ANNOTATIONS);
@ -65,7 +65,7 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
public void inheritedStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() {
void inheritedStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() {
MergedAnnotations annotations = MergedAnnotations.from(
SubMultipleNoninheritedComposedCachesClass.class,
SearchStrategy.INHERITED_ANNOTATIONS);
@ -73,12 +73,12 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
public void inheritedStrategyComposedPlusLocalAnnotationsOnClass() {
void inheritedStrategyComposedPlusLocalAnnotationsOnClass() {
assertInheritedStrategyBehavior(ComposedPlusLocalCachesClass.class);
}
@Test
public void inheritedStrategyMultipleComposedAnnotationsOnInterface() {
void inheritedStrategyMultipleComposedAnnotationsOnInterface() {
MergedAnnotations annotations = MergedAnnotations.from(
MultipleComposedCachesOnInterfaceClass.class,
SearchStrategy.INHERITED_ANNOTATIONS);
@ -86,13 +86,13 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
public void inheritedStrategyMultipleComposedAnnotationsOnMethod() throws Exception {
void inheritedStrategyMultipleComposedAnnotationsOnMethod() throws Exception {
assertInheritedStrategyBehavior(
getClass().getDeclaredMethod("multipleComposedCachesMethod"));
}
@Test
public void inheritedStrategyComposedPlusLocalAnnotationsOnMethod() throws Exception {
void inheritedStrategyComposedPlusLocalAnnotationsOnMethod() throws Exception {
assertInheritedStrategyBehavior(
getClass().getDeclaredMethod("composedPlusLocalCachesMethod"));
}
@ -105,17 +105,17 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
public void typeHierarchyStrategyMultipleComposedAnnotationsOnClass() {
void typeHierarchyStrategyMultipleComposedAnnotationsOnClass() {
assertTypeHierarchyStrategyBehavior(MultipleComposedCachesClass.class);
}
@Test
public void typeHierarchyStrategyMultipleInheritedComposedAnnotationsOnSuperclass() {
void typeHierarchyStrategyMultipleInheritedComposedAnnotationsOnSuperclass() {
assertTypeHierarchyStrategyBehavior(SubMultipleComposedCachesClass.class);
}
@Test
public void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnClass() {
void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnClass() {
MergedAnnotations annotations = MergedAnnotations.from(
MultipleNoninheritedComposedCachesClass.class, SearchStrategy.TYPE_HIERARCHY);
assertThat(stream(annotations, "value")).containsExactly("noninheritedCache1",
@ -123,7 +123,7 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
public void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() {
void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() {
MergedAnnotations annotations = MergedAnnotations.from(
SubMultipleNoninheritedComposedCachesClass.class,
SearchStrategy.TYPE_HIERARCHY);
@ -132,36 +132,36 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
public void typeHierarchyStrategyComposedPlusLocalAnnotationsOnClass() {
void typeHierarchyStrategyComposedPlusLocalAnnotationsOnClass() {
assertTypeHierarchyStrategyBehavior(ComposedPlusLocalCachesClass.class);
}
@Test
public void typeHierarchyStrategyMultipleComposedAnnotationsOnInterface() {
void typeHierarchyStrategyMultipleComposedAnnotationsOnInterface() {
assertTypeHierarchyStrategyBehavior(MultipleComposedCachesOnInterfaceClass.class);
}
@Test
public void typeHierarchyStrategyComposedCacheOnInterfaceAndLocalCacheOnClass() {
void typeHierarchyStrategyComposedCacheOnInterfaceAndLocalCacheOnClass() {
assertTypeHierarchyStrategyBehavior(
ComposedCacheOnInterfaceAndLocalCacheClass.class);
}
@Test
public void typeHierarchyStrategyMultipleComposedAnnotationsOnMethod() throws Exception {
void typeHierarchyStrategyMultipleComposedAnnotationsOnMethod() throws Exception {
assertTypeHierarchyStrategyBehavior(
getClass().getDeclaredMethod("multipleComposedCachesMethod"));
}
@Test
public void typeHierarchyStrategyComposedPlusLocalAnnotationsOnMethod()
void typeHierarchyStrategyComposedPlusLocalAnnotationsOnMethod()
throws Exception {
assertTypeHierarchyStrategyBehavior(
getClass().getDeclaredMethod("composedPlusLocalCachesMethod"));
}
@Test
public void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod()
void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod()
throws Exception {
assertTypeHierarchyStrategyBehavior(getBridgeMethod());
}
@ -173,7 +173,7 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
assertThat(stream(annotations, "value")).containsExactly("fooCache", "barCache");
}
public Method getBridgeMethod() throws NoSuchMethodException {
Method getBridgeMethod() throws NoSuchMethodException {
List<Method> methods = new ArrayList<>();
ReflectionUtils.doWithLocalMethods(StringGenericParameter.class, method -> {
if ("getFor".equals(method.getName())) {

View File

@ -42,19 +42,19 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Phillip Webb
* @author Sam Brannen
*/
public class MergedAnnotationsRepeatableAnnotationTests {
class MergedAnnotationsRepeatableAnnotationTests {
// See SPR-13973
@Test
public void inheritedAnnotationsWhenNonRepeatableThrowsException() {
void inheritedAnnotationsWhenNonRepeatableThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
getAnnotations(null, NonRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, getClass()))
.satisfies(this::nonRepeatableRequirements);
}
@Test
public void inheritedAnnotationsWhenContainerMissingValueAttributeThrowsException() {
void inheritedAnnotationsWhenContainerMissingValueAttributeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerMissingValueAttribute.class, InvalidRepeatable.class,
SearchStrategy.INHERITED_ANNOTATIONS, getClass()))
@ -62,7 +62,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenWhenNonArrayValueAttributeThrowsException() {
void inheritedAnnotationsWhenWhenNonArrayValueAttributeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerWithNonArrayValueAttribute.class, InvalidRepeatable.class,
SearchStrategy.INHERITED_ANNOTATIONS, getClass()))
@ -70,7 +70,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenWrongComponentTypeThrowsException() {
void inheritedAnnotationsWhenWrongComponentTypeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerWithArrayValueAttributeButWrongComponentType.class,
InvalidRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, getClass()))
@ -78,7 +78,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenOnClassReturnsAnnotations() {
void inheritedAnnotationsWhenOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.INHERITED_ANNOTATIONS, RepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
@ -86,7 +86,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenWhenOnSuperclassReturnsAnnotations() {
void inheritedAnnotationsWhenWhenOnSuperclassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.INHERITED_ANNOTATIONS, SubRepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
@ -94,7 +94,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenComposedOnClassReturnsAnnotations() {
void inheritedAnnotationsWhenComposedOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.INHERITED_ANNOTATIONS, ComposedRepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
@ -102,7 +102,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenComposedMixedWithContainerOnClassReturnsAnnotations() {
void inheritedAnnotationsWhenComposedMixedWithContainerOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.INHERITED_ANNOTATIONS,
ComposedRepeatableMixedWithContainerClass.class);
@ -111,7 +111,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenComposedContainerForRepeatableOnClassReturnsAnnotations() {
void inheritedAnnotationsWhenComposedContainerForRepeatableOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.INHERITED_ANNOTATIONS, ComposedContainerClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
@ -119,7 +119,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() {
void inheritedAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() {
Set<Noninherited> annotations = getAnnotations(null, Noninherited.class,
SearchStrategy.INHERITED_ANNOTATIONS, NoninheritedRepeatableClass.class);
assertThat(annotations.stream().map(Noninherited::value)).containsExactly("A",
@ -127,7 +127,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void inheritedAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() {
void inheritedAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() {
Set<Noninherited> annotations = getAnnotations(null, Noninherited.class,
SearchStrategy.INHERITED_ANNOTATIONS,
SubNoninheritedRepeatableClass.class);
@ -135,14 +135,14 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyWhenNonRepeatableThrowsException() {
void typeHierarchyWhenNonRepeatableThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
getAnnotations(null, NonRepeatable.class, SearchStrategy.TYPE_HIERARCHY, getClass()))
.satisfies(this::nonRepeatableRequirements);
}
@Test
public void typeHierarchyWhenContainerMissingValueAttributeThrowsException() {
void typeHierarchyWhenContainerMissingValueAttributeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerMissingValueAttribute.class, InvalidRepeatable.class,
SearchStrategy.TYPE_HIERARCHY, getClass()))
@ -150,7 +150,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyWhenWhenNonArrayValueAttributeThrowsException() {
void typeHierarchyWhenWhenNonArrayValueAttributeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerWithNonArrayValueAttribute.class, InvalidRepeatable.class,
SearchStrategy.TYPE_HIERARCHY, getClass()))
@ -158,7 +158,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyWhenWrongComponentTypeThrowsException() {
void typeHierarchyWhenWrongComponentTypeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerWithArrayValueAttributeButWrongComponentType.class,
InvalidRepeatable.class, SearchStrategy.TYPE_HIERARCHY, getClass()))
@ -166,7 +166,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyWhenOnClassReturnsAnnotations() {
void typeHierarchyWhenOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.TYPE_HIERARCHY, RepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
@ -174,7 +174,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyWhenWhenOnSuperclassReturnsAnnotations() {
void typeHierarchyWhenWhenOnSuperclassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.TYPE_HIERARCHY, SubRepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
@ -182,7 +182,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyWhenComposedOnClassReturnsAnnotations() {
void typeHierarchyWhenComposedOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.TYPE_HIERARCHY, ComposedRepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
@ -190,7 +190,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyWhenComposedMixedWithContainerOnClassReturnsAnnotations() {
void typeHierarchyWhenComposedMixedWithContainerOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.TYPE_HIERARCHY,
ComposedRepeatableMixedWithContainerClass.class);
@ -199,7 +199,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyWhenComposedContainerForRepeatableOnClassReturnsAnnotations() {
void typeHierarchyWhenComposedContainerForRepeatableOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.TYPE_HIERARCHY, ComposedContainerClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
@ -207,7 +207,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() {
void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() {
Set<Noninherited> annotations = getAnnotations(null, Noninherited.class,
SearchStrategy.TYPE_HIERARCHY, NoninheritedRepeatableClass.class);
assertThat(annotations.stream().map(Noninherited::value)).containsExactly("A",
@ -215,7 +215,7 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() {
void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() {
Set<Noninherited> annotations = getAnnotations(null, Noninherited.class,
SearchStrategy.TYPE_HIERARCHY, SubNoninheritedRepeatableClass.class);
assertThat(annotations.stream().map(Noninherited::value)).containsExactly("A",

View File

@ -35,262 +35,262 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
*
* @author Phillip Webb
*/
public class MissingMergedAnnotationTests {
class MissingMergedAnnotationTests {
private final MergedAnnotation<?> missing = MissingMergedAnnotation.getInstance();
@Test
public void getTypeThrowsNoSuchElementException() {
void getTypeThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(this.missing::getType);
}
@Test
public void MetaTypesReturnsEmptyList() {
void metaTypesReturnsEmptyList() {
assertThat(this.missing.getMetaTypes()).isEmpty();
}
@Test
public void isPresentReturnsFalse() {
void isPresentReturnsFalse() {
assertThat(this.missing.isPresent()).isFalse();
}
@Test
public void isDirectlyPresentReturnsFalse() {
void isDirectlyPresentReturnsFalse() {
assertThat(this.missing.isDirectlyPresent()).isFalse();
}
@Test
public void isMetaPresentReturnsFalse() {
void isMetaPresentReturnsFalse() {
assertThat(this.missing.isMetaPresent()).isFalse();
}
@Test
public void getDistanceReturnsMinusOne() {
void getDistanceReturnsMinusOne() {
assertThat(this.missing.getDistance()).isEqualTo(-1);
}
@Test
public void getAggregateIndexReturnsMinusOne() {
void getAggregateIndexReturnsMinusOne() {
assertThat(this.missing.getAggregateIndex()).isEqualTo(-1);
}
@Test
public void getSourceReturnsNull() {
void getSourceReturnsNull() {
assertThat(this.missing.getSource()).isNull();
}
@Test
public void getMetaSourceReturnsNull() {
void getMetaSourceReturnsNull() {
assertThat(this.missing.getMetaSource()).isNull();
}
@Test
public void getRootReturnsEmptyAnnotation() {
void getRootReturnsEmptyAnnotation() {
assertThat(this.missing.getRoot()).isSameAs(this.missing);
}
@Test
public void hasNonDefaultValueThrowsNoSuchElementException() {
void hasNonDefaultValueThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.hasNonDefaultValue("value"));
}
@Test
public void hasDefaultValueThrowsNoSuchElementException() {
void hasDefaultValueThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.hasDefaultValue("value"));
}
@Test
public void getByteThrowsNoSuchElementException() {
void getByteThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getByte("value"));
}
@Test
public void getByteArrayThrowsNoSuchElementException() {
void getByteArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getByteArray("value"));
}
@Test
public void getBooleanThrowsNoSuchElementException() {
void getBooleanThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getBoolean("value"));
}
@Test
public void getBooleanArrayThrowsNoSuchElementException() {
void getBooleanArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getBooleanArray("value"));
}
@Test
public void getCharThrowsNoSuchElementException() {
void getCharThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getChar("value"));
}
@Test
public void getCharArrayThrowsNoSuchElementException() {
void getCharArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getCharArray("value"));
}
@Test
public void getShortThrowsNoSuchElementException() {
void getShortThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getShort("value"));
}
@Test
public void getShortArrayThrowsNoSuchElementException() {
void getShortArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getShortArray("value"));
}
@Test
public void getIntThrowsNoSuchElementException() {
void getIntThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(() -> this.missing.getInt("value"));
}
@Test
public void getIntArrayThrowsNoSuchElementException() {
void getIntArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getIntArray("value"));
}
@Test
public void getLongThrowsNoSuchElementException() {
void getLongThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getLong("value"));
}
@Test
public void getLongArrayThrowsNoSuchElementException() {
void getLongArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getLongArray("value"));
}
@Test
public void getDoubleThrowsNoSuchElementException() {
void getDoubleThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getDouble("value"));
}
@Test
public void getDoubleArrayThrowsNoSuchElementException() {
void getDoubleArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getDoubleArray("value"));
}
@Test
public void getFloatThrowsNoSuchElementException() {
void getFloatThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getFloat("value"));
}
@Test
public void getFloatArrayThrowsNoSuchElementException() {
void getFloatArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getFloatArray("value"));
}
@Test
public void getStringThrowsNoSuchElementException() {
void getStringThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getString("value"));
}
@Test
public void getStringArrayThrowsNoSuchElementException() {
void getStringArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getStringArray("value"));
}
@Test
public void getClassThrowsNoSuchElementException() {
void getClassThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getClass("value"));
}
@Test
public void getClassArrayThrowsNoSuchElementException() {
void getClassArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getClassArray("value"));
}
@Test
public void getEnumThrowsNoSuchElementException() {
void getEnumThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getEnum("value", TestEnum.class));
}
@Test
public void getEnumArrayThrowsNoSuchElementException() {
void getEnumArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getEnumArray("value", TestEnum.class));
}
@Test
public void getAnnotationThrowsNoSuchElementException() {
void getAnnotationThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getAnnotation("value", TestAnnotation.class));
}
@Test
public void getAnnotationArrayThrowsNoSuchElementException() {
void getAnnotationArrayThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.getAnnotationArray("value", TestAnnotation.class));
}
@Test
public void getValueReturnsEmpty() {
void getValueReturnsEmpty() {
assertThat(this.missing.getValue("value", Integer.class)).isEmpty();
}
@Test
public void getDefaultValueReturnsEmpty() {
void getDefaultValueReturnsEmpty() {
assertThat(this.missing.getDefaultValue("value", Integer.class)).isEmpty();
}
@Test
public void synthesizeThrowsNoSuchElementException() {
void synthesizeThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(() -> this.missing.synthesize());
}
@Test
public void synthesizeWithPredicateWhenPredicateMatchesThrowsNoSuchElementException() {
void synthesizeWithPredicateWhenPredicateMatchesThrowsNoSuchElementException() {
assertThatNoSuchElementException().isThrownBy(
() -> this.missing.synthesize(annotation -> true));
}
@Test
public void synthesizeWithPredicateWhenPredicateDoesNotMatchReturnsEmpty() {
void synthesizeWithPredicateWhenPredicateDoesNotMatchReturnsEmpty() {
assertThat(this.missing.synthesize(annotation -> false)).isEmpty();
}
@Test
public void toStringReturnsString() {
void toStringReturnsString() {
assertThat(this.missing.toString()).isEqualTo("(missing)");
}
@Test
public void asAnnotationAttributesReturnsNewAnnotationAttributes() {
void asAnnotationAttributesReturnsNewAnnotationAttributes() {
AnnotationAttributes attributes = this.missing.asAnnotationAttributes();
assertThat(attributes).isEmpty();
assertThat(this.missing.asAnnotationAttributes()).isNotSameAs(attributes);
}
@Test
public void asMapReturnsEmptyMap() {
void asMapReturnsEmptyMap() {
Map<String, Object> map = this.missing.asMap();
assertThat(map).isSameAs(Collections.EMPTY_MAP);
}
@Test
public void asMapWithFactoryReturnsNewMapFromFactory() {
void asMapWithFactoryReturnsNewMapFromFactory() {
Map<String, Object> map = this.missing.asMap(annotation->new ConcurrentReferenceHashMap<>());
assertThat(map).isInstanceOf(ConcurrentReferenceHashMap.class);
}

View File

@ -45,20 +45,20 @@ import static org.springframework.core.annotation.AnnotatedElementUtils.getAllMe
* @see AnnotatedElementUtilsTests
* @see ComposedRepeatableAnnotationsTests
*/
public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
@Test
public void getMultipleComposedAnnotationsOnClass() {
void getMultipleComposedAnnotationsOnClass() {
assertGetAllMergedAnnotationsBehavior(MultipleComposedCachesClass.class);
}
@Test
public void getMultipleInheritedComposedAnnotationsOnSuperclass() {
void getMultipleInheritedComposedAnnotationsOnSuperclass() {
assertGetAllMergedAnnotationsBehavior(SubMultipleComposedCachesClass.class);
}
@Test
public void getMultipleNoninheritedComposedAnnotationsOnClass() {
void getMultipleNoninheritedComposedAnnotationsOnClass() {
Class<?> element = MultipleNoninheritedComposedCachesClass.class;
Set<Cacheable> cacheables = getAllMergedAnnotations(element, Cacheable.class);
assertThat(cacheables).isNotNull();
@ -72,7 +72,7 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
}
@Test
public void getMultipleNoninheritedComposedAnnotationsOnSuperclass() {
void getMultipleNoninheritedComposedAnnotationsOnSuperclass() {
Class<?> element = SubMultipleNoninheritedComposedCachesClass.class;
Set<Cacheable> cacheables = getAllMergedAnnotations(element, Cacheable.class);
assertThat(cacheables).isNotNull();
@ -80,12 +80,12 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
}
@Test
public void getComposedPlusLocalAnnotationsOnClass() {
void getComposedPlusLocalAnnotationsOnClass() {
assertGetAllMergedAnnotationsBehavior(ComposedPlusLocalCachesClass.class);
}
@Test
public void getMultipleComposedAnnotationsOnInterface() {
void getMultipleComposedAnnotationsOnInterface() {
Class<MultipleComposedCachesOnInterfaceClass> element = MultipleComposedCachesOnInterfaceClass.class;
Set<Cacheable> cacheables = getAllMergedAnnotations(element, Cacheable.class);
assertThat(cacheables).isNotNull();
@ -93,37 +93,37 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
}
@Test
public void getMultipleComposedAnnotationsOnMethod() throws Exception {
void getMultipleComposedAnnotationsOnMethod() throws Exception {
AnnotatedElement element = getClass().getDeclaredMethod("multipleComposedCachesMethod");
assertGetAllMergedAnnotationsBehavior(element);
}
@Test
public void getComposedPlusLocalAnnotationsOnMethod() throws Exception {
void getComposedPlusLocalAnnotationsOnMethod() throws Exception {
AnnotatedElement element = getClass().getDeclaredMethod("composedPlusLocalCachesMethod");
assertGetAllMergedAnnotationsBehavior(element);
}
@Test
@Disabled("Disabled since some Java 8 updates handle the bridge method differently")
public void getMultipleComposedAnnotationsOnBridgeMethod() throws Exception {
void getMultipleComposedAnnotationsOnBridgeMethod() throws Exception {
Set<Cacheable> cacheables = getAllMergedAnnotations(getBridgeMethod(), Cacheable.class);
assertThat(cacheables).isNotNull();
assertThat(cacheables.size()).isEqualTo(0);
}
@Test
public void findMultipleComposedAnnotationsOnClass() {
void findMultipleComposedAnnotationsOnClass() {
assertFindAllMergedAnnotationsBehavior(MultipleComposedCachesClass.class);
}
@Test
public void findMultipleInheritedComposedAnnotationsOnSuperclass() {
void findMultipleInheritedComposedAnnotationsOnSuperclass() {
assertFindAllMergedAnnotationsBehavior(SubMultipleComposedCachesClass.class);
}
@Test
public void findMultipleNoninheritedComposedAnnotationsOnClass() {
void findMultipleNoninheritedComposedAnnotationsOnClass() {
Class<?> element = MultipleNoninheritedComposedCachesClass.class;
Set<Cacheable> cacheables = findAllMergedAnnotations(element, Cacheable.class);
assertThat(cacheables).isNotNull();
@ -137,7 +137,7 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
}
@Test
public void findMultipleNoninheritedComposedAnnotationsOnSuperclass() {
void findMultipleNoninheritedComposedAnnotationsOnSuperclass() {
Class<?> element = SubMultipleNoninheritedComposedCachesClass.class;
Set<Cacheable> cacheables = findAllMergedAnnotations(element, Cacheable.class);
assertThat(cacheables).isNotNull();
@ -151,34 +151,34 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
}
@Test
public void findComposedPlusLocalAnnotationsOnClass() {
void findComposedPlusLocalAnnotationsOnClass() {
assertFindAllMergedAnnotationsBehavior(ComposedPlusLocalCachesClass.class);
}
@Test
public void findMultipleComposedAnnotationsOnInterface() {
void findMultipleComposedAnnotationsOnInterface() {
assertFindAllMergedAnnotationsBehavior(MultipleComposedCachesOnInterfaceClass.class);
}
@Test
public void findComposedCacheOnInterfaceAndLocalCacheOnClass() {
void findComposedCacheOnInterfaceAndLocalCacheOnClass() {
assertFindAllMergedAnnotationsBehavior(ComposedCacheOnInterfaceAndLocalCacheClass.class);
}
@Test
public void findMultipleComposedAnnotationsOnMethod() throws Exception {
void findMultipleComposedAnnotationsOnMethod() throws Exception {
AnnotatedElement element = getClass().getDeclaredMethod("multipleComposedCachesMethod");
assertFindAllMergedAnnotationsBehavior(element);
}
@Test
public void findComposedPlusLocalAnnotationsOnMethod() throws Exception {
void findComposedPlusLocalAnnotationsOnMethod() throws Exception {
AnnotatedElement element = getClass().getDeclaredMethod("composedPlusLocalCachesMethod");
assertFindAllMergedAnnotationsBehavior(element);
}
@Test
public void findMultipleComposedAnnotationsOnBridgeMethod() throws Exception {
void findMultipleComposedAnnotationsOnBridgeMethod() throws Exception {
assertFindAllMergedAnnotationsBehavior(getBridgeMethod());
}
@ -186,7 +186,7 @@ public class MultipleComposedAnnotationsOnSingleAnnotatedElementTests {
* Bridge/bridged method setup code copied from
* {@link org.springframework.core.BridgeMethodResolverTests#testWithGenericParameter()}.
*/
public Method getBridgeMethod() throws NoSuchMethodException {
Method getBridgeMethod() throws NoSuchMethodException {
Method[] methods = StringGenericParameter.class.getMethods();
Method bridgeMethod = null;
Method bridgedMethod = null;

View File

@ -31,13 +31,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
* @author Juergen Hoeller
*/
public class OrderSourceProviderTests {
class OrderSourceProviderTests {
private final AnnotationAwareOrderComparator comparator = AnnotationAwareOrderComparator.INSTANCE;
@Test
public void plainComparator() {
void plainComparator() {
List<Object> items = new ArrayList<>();
C c = new C(5);
C c2 = new C(-5);
@ -48,7 +48,7 @@ public class OrderSourceProviderTests {
}
@Test
public void listNoFactoryMethod() {
void listNoFactoryMethod() {
A a = new A();
C c = new C(-50);
B b = new B();
@ -59,7 +59,7 @@ public class OrderSourceProviderTests {
}
@Test
public void listFactoryMethod() {
void listFactoryMethod() {
A a = new A();
C c = new C(3);
B b = new B();
@ -78,7 +78,7 @@ public class OrderSourceProviderTests {
}
@Test
public void listFactoryMethodOverridesStaticOrder() {
void listFactoryMethodOverridesStaticOrder() {
A a = new A();
C c = new C(5);
C c2 = new C(-5);
@ -97,7 +97,7 @@ public class OrderSourceProviderTests {
}
@Test
public void arrayNoFactoryMethod() {
void arrayNoFactoryMethod() {
A a = new A();
C c = new C(-50);
B b = new B();
@ -108,7 +108,7 @@ public class OrderSourceProviderTests {
}
@Test
public void arrayFactoryMethod() {
void arrayFactoryMethod() {
A a = new A();
C c = new C(3);
B b = new B();
@ -127,7 +127,7 @@ public class OrderSourceProviderTests {
}
@Test
public void arrayFactoryMethodOverridesStaticOrder() {
void arrayFactoryMethodOverridesStaticOrder() {
A a = new A();
C c = new C(5);
C c2 = new C(-5);

View File

@ -26,40 +26,40 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
* @author Juergen Hoeller
*/
public class OrderUtilsTests {
class OrderUtilsTests {
@Test
public void getSimpleOrder() {
void getSimpleOrder() {
assertThat(OrderUtils.getOrder(SimpleOrder.class, null)).isEqualTo(Integer.valueOf(50));
assertThat(OrderUtils.getOrder(SimpleOrder.class, null)).isEqualTo(Integer.valueOf(50));
}
@Test
public void getPriorityOrder() {
void getPriorityOrder() {
assertThat(OrderUtils.getOrder(SimplePriority.class, null)).isEqualTo(Integer.valueOf(55));
assertThat(OrderUtils.getOrder(SimplePriority.class, null)).isEqualTo(Integer.valueOf(55));
}
@Test
public void getOrderWithBoth() {
void getOrderWithBoth() {
assertThat(OrderUtils.getOrder(OrderAndPriority.class, null)).isEqualTo(Integer.valueOf(50));
assertThat(OrderUtils.getOrder(OrderAndPriority.class, null)).isEqualTo(Integer.valueOf(50));
}
@Test
public void getDefaultOrder() {
void getDefaultOrder() {
assertThat(OrderUtils.getOrder(NoOrder.class, 33)).isEqualTo(33);
assertThat(OrderUtils.getOrder(NoOrder.class, 33)).isEqualTo(33);
}
@Test
public void getPriorityValueNoAnnotation() {
void getPriorityValueNoAnnotation() {
assertThat(OrderUtils.getPriority(SimpleOrder.class)).isNull();
assertThat(OrderUtils.getPriority(SimpleOrder.class)).isNull();
}
@Test
public void getPriorityValue() {
void getPriorityValue() {
assertThat(OrderUtils.getPriority(OrderAndPriority.class)).isEqualTo(Integer.valueOf(55));
assertThat(OrderUtils.getPriority(OrderAndPriority.class)).isEqualTo(Integer.valueOf(55));
}

View File

@ -26,49 +26,49 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Phillip Webb
*/
public class PackagesAnnotationFilterTests {
class PackagesAnnotationFilterTests {
@Test
public void createWhenPackagesIsNullThrowsException() {
void createWhenPackagesIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PackagesAnnotationFilter((String[]) null))
.withMessage("Packages array must not be null");
}
@Test
public void createWhenPackagesContainsNullThrowsException() {
void createWhenPackagesContainsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PackagesAnnotationFilter((String) null))
.withMessage("Packages array must not have empty elements");
}
@Test
public void createWhenPackagesContainsEmptyTextThrowsException() {
void createWhenPackagesContainsEmptyTextThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PackagesAnnotationFilter(""))
.withMessage("Packages array must not have empty elements");
}
@Test
public void matchesWhenInPackageReturnsTrue() {
void matchesWhenInPackageReturnsTrue() {
PackagesAnnotationFilter filter = new PackagesAnnotationFilter("com.example");
assertThat(filter.matches("com.example.Component")).isTrue();
}
@Test
public void matchesWhenNotInPackageReturnsFalse() {
void matchesWhenNotInPackageReturnsFalse() {
PackagesAnnotationFilter filter = new PackagesAnnotationFilter("com.example");
assertThat(filter.matches("org.springframework.sterotype.Component")).isFalse();
}
@Test
public void matchesWhenInSimilarPackageReturnsFalse() {
void matchesWhenInSimilarPackageReturnsFalse() {
PackagesAnnotationFilter filter = new PackagesAnnotationFilter("com.example");
assertThat(filter.matches("com.examples.Component")).isFalse();
}
@Test
public void equalsAndHashCode() {
void equalsAndHashCode() {
PackagesAnnotationFilter filter1 = new PackagesAnnotationFilter("com.example",
"org.springframework");
PackagesAnnotationFilter filter2 = new PackagesAnnotationFilter(

View File

@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
*
* @author Phillip Webb
*/
public class RepeatableContainersTests {
class RepeatableContainersTests {
@Test
public void standardRepeatablesWhenNonRepeatableReturnsNull() {
void standardRepeatablesWhenNonRepeatableReturnsNull() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.standardRepeatables(), WithNonRepeatable.class,
NonRepeatable.class);
@ -43,7 +43,7 @@ public class RepeatableContainersTests {
}
@Test
public void standardRepeatablesWhenSingleReturnsNull() {
void standardRepeatablesWhenSingleReturnsNull() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.standardRepeatables(),
WithSingleStandardRepeatable.class, StandardRepeatable.class);
@ -51,7 +51,7 @@ public class RepeatableContainersTests {
}
@Test
public void standardRepeatablesWhenContainerReturnsRepeats() {
void standardRepeatablesWhenContainerReturnsRepeats() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.standardRepeatables(), WithStandardRepeatables.class,
StandardContainer.class);
@ -59,7 +59,7 @@ public class RepeatableContainersTests {
}
@Test
public void standardRepeatablesWhenContainerButNotRepeatableReturnsNull() {
void standardRepeatablesWhenContainerButNotRepeatableReturnsNull() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.standardRepeatables(), WithExplicitRepeatables.class,
ExplicitContainer.class);
@ -67,7 +67,7 @@ public class RepeatableContainersTests {
}
@Test
public void ofExplicitWhenNonRepeatableReturnsNull() {
void ofExplicitWhenNonRepeatableReturnsNull() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.of(ExplicitRepeatable.class,
ExplicitContainer.class),
@ -76,7 +76,7 @@ public class RepeatableContainersTests {
}
@Test
public void ofExplicitWhenStandardRepeatableContainerReturnsNull() {
void ofExplicitWhenStandardRepeatableContainerReturnsNull() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.of(ExplicitRepeatable.class,
ExplicitContainer.class),
@ -85,7 +85,7 @@ public class RepeatableContainersTests {
}
@Test
public void ofExplicitWhenContainerReturnsRepeats() {
void ofExplicitWhenContainerReturnsRepeats() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.of(ExplicitRepeatable.class,
ExplicitContainer.class),
@ -94,7 +94,7 @@ public class RepeatableContainersTests {
}
@Test
public void ofExplicitWhenHasNoValueThrowsException() {
void ofExplicitWhenHasNoValueThrowsException() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
RepeatableContainers.of(ExplicitRepeatable.class, InvalidNoValue.class))
.withMessageContaining("Invalid declaration of container type ["
@ -104,7 +104,7 @@ public class RepeatableContainersTests {
}
@Test
public void ofExplicitWhenValueIsNotArrayThrowsException() {
void ofExplicitWhenValueIsNotArrayThrowsException() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
RepeatableContainers.of(ExplicitRepeatable.class, InvalidNotArray.class))
.withMessage("Container type ["
@ -114,7 +114,7 @@ public class RepeatableContainersTests {
}
@Test
public void ofExplicitWhenValueIsArrayOfWrongTypeThrowsException() {
void ofExplicitWhenValueIsArrayOfWrongTypeThrowsException() {
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
RepeatableContainers.of(ExplicitRepeatable.class, InvalidWrongArrayType.class))
.withMessage("Container type ["
@ -124,14 +124,14 @@ public class RepeatableContainersTests {
}
@Test
public void ofExplicitWhenAnnotationIsNullThrowsException() {
void ofExplicitWhenAnnotationIsNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
RepeatableContainers.of(null, null))
.withMessage("Repeatable must not be null");
}
@Test
public void ofExplicitWhenContainerIsNullDeducesContainer() {
void ofExplicitWhenContainerIsNullDeducesContainer() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.of(StandardRepeatable.class, null),
WithStandardRepeatables.class, StandardContainer.class);
@ -139,7 +139,7 @@ public class RepeatableContainersTests {
}
@Test
public void ofExplicitWhenContainerIsNullAndNotRepeatableThrowsException() {
void ofExplicitWhenContainerIsNullAndNotRepeatableThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
RepeatableContainers.of(ExplicitRepeatable.class, null))
.withMessage("Annotation type must be a repeatable annotation: " +
@ -148,7 +148,7 @@ public class RepeatableContainersTests {
}
@Test
public void standardAndExplicitReturnsRepeats() {
void standardAndExplicitReturnsRepeats() {
RepeatableContainers repeatableContainers = RepeatableContainers.standardRepeatables().and(
ExplicitContainer.class, ExplicitRepeatable.class);
assertThat(findRepeatedAnnotationValues(repeatableContainers,
@ -160,7 +160,7 @@ public class RepeatableContainersTests {
}
@Test
public void noneAlwaysReturnsNull() {
void noneAlwaysReturnsNull() {
Object[] values = findRepeatedAnnotationValues(
RepeatableContainers.none(), WithStandardRepeatables.class,
StandardContainer.class);
@ -168,7 +168,7 @@ public class RepeatableContainersTests {
}
@Test
public void equalsAndHashcode() {
void equalsAndHashcode() {
RepeatableContainers c1 = RepeatableContainers.of(ExplicitRepeatable.class,
ExplicitContainer.class);
RepeatableContainers c2 = RepeatableContainers.of(ExplicitRepeatable.class,

View File

@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Juergen Hoeller
* @since 5.0
*/
public class SynthesizingMethodParameterTests {
class SynthesizingMethodParameterTests {
private Method method;
@ -42,7 +42,7 @@ public class SynthesizingMethodParameterTests {
@BeforeEach
public void setUp() throws NoSuchMethodException {
void setUp() throws NoSuchMethodException {
method = getClass().getMethod("method", String.class, Long.TYPE);
stringParameter = new SynthesizingMethodParameter(method, 0);
longParameter = new SynthesizingMethodParameter(method, 1);
@ -51,7 +51,7 @@ public class SynthesizingMethodParameterTests {
@Test
public void testEquals() throws NoSuchMethodException {
void equals() throws NoSuchMethodException {
assertThat(stringParameter).isEqualTo(stringParameter);
assertThat(longParameter).isEqualTo(longParameter);
assertThat(intReturnType).isEqualTo(intReturnType);
@ -78,7 +78,7 @@ public class SynthesizingMethodParameterTests {
}
@Test
public void testHashCode() throws NoSuchMethodException {
void testHashCode() throws NoSuchMethodException {
assertThat(stringParameter.hashCode()).isEqualTo(stringParameter.hashCode());
assertThat(longParameter.hashCode()).isEqualTo(longParameter.hashCode());
assertThat(intReturnType.hashCode()).isEqualTo(intReturnType.hashCode());
@ -90,7 +90,7 @@ public class SynthesizingMethodParameterTests {
}
@Test
public void testFactoryMethods() {
void factoryMethods() {
assertThat(SynthesizingMethodParameter.forExecutable(method, 0)).isEqualTo(stringParameter);
assertThat(SynthesizingMethodParameter.forExecutable(method, 1)).isEqualTo(longParameter);
@ -99,7 +99,7 @@ public class SynthesizingMethodParameterTests {
}
@Test
public void testIndexValidation() {
void indexValidation() {
assertThatIllegalArgumentException().isThrownBy(() ->
new SynthesizingMethodParameter(method, 2));
}

View File

@ -34,10 +34,10 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
public class TypeMappedAnnotationTests {
class TypeMappedAnnotationTests {
@Test
public void mappingWhenMirroredReturnsMirroredValues() {
void mappingWhenMirroredReturnsMirroredValues() {
testExplicitMirror(WithExplicitMirrorA.class);
testExplicitMirror(WithExplicitMirrorB.class);
}
@ -50,7 +50,7 @@ public class TypeMappedAnnotationTests {
}
@Test
public void mappingExplicitAliasToMetaAnnotationReturnsMappedValues() {
void mappingExplicitAliasToMetaAnnotationReturnsMappedValues() {
TypeMappedAnnotation<?> annotation = getTypeMappedAnnotation(
WithExplicitAliasToMetaAnnotation.class,
ExplicitAliasToMetaAnnotation.class,
@ -60,7 +60,7 @@ public class TypeMappedAnnotationTests {
}
@Test
public void mappingConventionAliasToMetaAnnotationReturnsMappedValues() {
void mappingConventionAliasToMetaAnnotationReturnsMappedValues() {
TypeMappedAnnotation<?> annotation = getTypeMappedAnnotation(
WithConventionAliasToMetaAnnotation.class,
ConventionAliasToMetaAnnotation.class,
@ -70,7 +70,7 @@ public class TypeMappedAnnotationTests {
}
@Test
public void adaptFromEmptyArrayToAnyComponentType() {
void adaptFromEmptyArrayToAnyComponentType() {
AttributeMethods methods = AttributeMethods.forAnnotationType(ArrayTypes.class);
Map<String, Object> attributes = new HashMap<>();
for (int i = 0; i < methods.size(); i++) {
@ -93,7 +93,7 @@ public class TypeMappedAnnotationTests {
}
@Test
public void adaptFromNestedMergedAnnotation() {
void adaptFromNestedMergedAnnotation() {
MergedAnnotation<Nested> nested = MergedAnnotation.of(Nested.class);
MergedAnnotation<?> annotation = TypeMappedAnnotation.of(null, null,
NestedContainer.class, Collections.singletonMap("value", nested));
@ -101,7 +101,7 @@ public class TypeMappedAnnotationTests {
}
@Test
public void adaptFromStringToClass() {
void adaptFromStringToClass() {
MergedAnnotation<?> annotation = TypeMappedAnnotation.of(null, null,
ClassAttributes.class,
Collections.singletonMap("classValue", InputStream.class.getName()));
@ -110,7 +110,7 @@ public class TypeMappedAnnotationTests {
}
@Test
public void adaptFromStringArrayToClassArray() {
void adaptFromStringArrayToClassArray() {
MergedAnnotation<?> annotation = TypeMappedAnnotation.of(null, null, ClassAttributes.class,
Collections.singletonMap("classArrayValue", new String[] { InputStream.class.getName() }));
assertThat(annotation.getStringArray("classArrayValue")).containsExactly(InputStream.class.getName());

View File

@ -44,8 +44,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @since 5.1.3
*/
@SuppressWarnings("ProtectedField")
public abstract class AbstractDecoderTestCase<D extends Decoder<?>>
extends AbstractLeakCheckingTestCase {
public abstract class AbstractDecoderTestCase<D extends Decoder<?>> extends AbstractLeakCheckingTestCase {
/**
* The decoder to test.

View File

@ -45,8 +45,7 @@ import static org.springframework.core.io.buffer.DataBufferUtils.release;
* @since 5.1.3
*/
@SuppressWarnings("ProtectedField")
public abstract class AbstractEncoderTestCase<E extends Encoder<?>>
extends AbstractLeakCheckingTestCase {
public abstract class AbstractEncoderTestCase<E extends Encoder<?>> extends AbstractLeakCheckingTestCase {
/**
* The encoder to test.
@ -273,5 +272,4 @@ public abstract class AbstractEncoderTestCase<E extends Encoder<?>>
}
}

View File

@ -31,14 +31,14 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Arjen Poutsma
*/
public class ByteArrayDecoderTests extends AbstractDecoderTestCase<ByteArrayDecoder> {
class ByteArrayDecoderTests extends AbstractDecoderTestCase<ByteArrayDecoder> {
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8);
public ByteArrayDecoderTests() {
ByteArrayDecoderTests() {
super(new ByteArrayDecoder());
}

View File

@ -29,13 +29,13 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Arjen Poutsma
*/
public class ByteArrayEncoderTests extends AbstractEncoderTestCase<ByteArrayEncoder> {
class ByteArrayEncoderTests extends AbstractEncoderTestCase<ByteArrayEncoder> {
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8);
public ByteArrayEncoderTests() {
ByteArrayEncoderTests() {
super(new ByteArrayEncoder());
}

View File

@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Sebastien Deleuze
*/
public class ByteBufferDecoderTests extends AbstractDecoderTestCase<ByteBufferDecoder> {
class ByteBufferDecoderTests extends AbstractDecoderTestCase<ByteBufferDecoder> {
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8);
public ByteBufferDecoderTests() {
ByteBufferDecoderTests() {
super(new ByteBufferDecoder());
}

View File

@ -30,13 +30,13 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Sebastien Deleuze
*/
public class ByteBufferEncoderTests extends AbstractEncoderTestCase<ByteBufferEncoder> {
class ByteBufferEncoderTests extends AbstractEncoderTestCase<ByteBufferEncoder> {
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8);
public ByteBufferEncoderTests() {
ByteBufferEncoderTests() {
super(new ByteBufferEncoder());
}
@ -64,7 +64,6 @@ public class ByteBufferEncoderTests extends AbstractEncoderTestCase<ByteBufferEn
.consumeNextWith(expectBytes(this.fooBytes))
.consumeNextWith(expectBytes(this.barBytes))
.verifyComplete());
}
}

View File

@ -34,14 +34,13 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Sebastien Deleuze
*/
public class CharSequenceEncoderTests
extends AbstractEncoderTestCase<CharSequenceEncoder> {
class CharSequenceEncoderTests extends AbstractEncoderTestCase<CharSequenceEncoder> {
private final String foo = "foo";
private final String bar = "bar";
public CharSequenceEncoderTests() {
CharSequenceEncoderTests() {
super(CharSequenceEncoder.textPlainOnly());
}
@ -74,7 +73,7 @@ public class CharSequenceEncoderTests
}
@Test
public void calculateCapacity() {
void calculateCapacity() {
String sequence = "Hello World!";
Stream.of(UTF_8, UTF_16, ISO_8859_1, US_ASCII, Charset.forName("BIG5"))
.forEach(charset -> {
@ -82,7 +81,6 @@ public class CharSequenceEncoderTests
int length = sequence.length();
assertThat(capacity >= length).as(String.format("%s has capacity %d; length %d", charset, capacity, length)).isTrue();
});
}
}

View File

@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Sebastien Deleuze
*/
public class DataBufferDecoderTests extends AbstractDecoderTestCase<DataBufferDecoder> {
class DataBufferDecoderTests extends AbstractDecoderTestCase<DataBufferDecoder> {
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8);
public DataBufferDecoderTests() {
DataBufferDecoderTests() {
super(new DataBufferDecoder());
}
@ -90,4 +90,5 @@ public class DataBufferDecoderTests extends AbstractDecoderTestCase<DataBufferDe
DataBufferUtils.release(actual);
};
}
}

View File

@ -31,13 +31,13 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Sebastien Deleuze
*/
public class DataBufferEncoderTests extends AbstractEncoderTestCase<DataBufferEncoder> {
class DataBufferEncoderTests extends AbstractEncoderTestCase<DataBufferEncoder> {
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8);
public DataBufferEncoderTests() {
DataBufferEncoderTests() {
super(new DataBufferEncoder());
}
@ -72,5 +72,4 @@ public class DataBufferEncoderTests extends AbstractEncoderTestCase<DataBufferEn
}
}

View File

@ -37,14 +37,14 @@ import static org.springframework.core.ResolvableType.forClass;
/**
* @author Arjen Poutsma
*/
public class ResourceDecoderTests extends AbstractDecoderTestCase<ResourceDecoder> {
class ResourceDecoderTests extends AbstractDecoderTestCase<ResourceDecoder> {
private final byte[] fooBytes = "foo".getBytes(StandardCharsets.UTF_8);
private final byte[] barBytes = "bar".getBytes(StandardCharsets.UTF_8);
public ResourceDecoderTests() {
ResourceDecoderTests() {
super(new ResourceDecoder());
}

View File

@ -38,12 +38,12 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Arjen Poutsma
*/
public class ResourceEncoderTests extends AbstractEncoderTestCase<ResourceEncoder> {
class ResourceEncoderTests extends AbstractEncoderTestCase<ResourceEncoder> {
private final byte[] bytes = "foo".getBytes(UTF_8);
public ResourceEncoderTests() {
ResourceEncoderTests() {
super(new ResourceEncoder());
}

View File

@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* Test cases for {@link ResourceRegionEncoder} class.
* @author Brian Clozel
*/
public class ResourceRegionEncoderTests {
class ResourceRegionEncoderTests {
private ResourceRegionEncoder encoder = new ResourceRegionEncoder();
@ -53,12 +53,12 @@ public class ResourceRegionEncoderTests {
@AfterEach
public void tearDown() throws Exception {
void tearDown() throws Exception {
this.bufferFactory.checkForLeaks();
}
@Test
public void canEncode() {
void canEncode() {
ResolvableType resourceRegion = ResolvableType.forClass(ResourceRegion.class);
MimeType allMimeType = MimeType.valueOf("*/*");
@ -73,7 +73,7 @@ public class ResourceRegionEncoderTests {
}
@Test
public void shouldEncodeResourceRegionFileResource() throws Exception {
void shouldEncodeResourceRegionFileResource() throws Exception {
ResourceRegion region = new ResourceRegion(
new ClassPathResource("ResourceRegionEncoderTests.txt", getClass()), 0, 6);
Flux<DataBuffer> result = this.encoder.encode(Mono.just(region), this.bufferFactory,
@ -88,7 +88,7 @@ public class ResourceRegionEncoderTests {
}
@Test
public void shouldEncodeMultipleResourceRegionsFileResource() {
void shouldEncodeMultipleResourceRegionsFileResource() {
Resource resource = new ClassPathResource("ResourceRegionEncoderTests.txt", getClass());
Flux<ResourceRegion> regions = Flux.just(
new ResourceRegion(resource, 0, 6),
@ -127,7 +127,7 @@ public class ResourceRegionEncoderTests {
}
@Test // gh-22107
public void cancelWithoutDemandForMultipleResourceRegions() {
void cancelWithoutDemandForMultipleResourceRegions() {
Resource resource = new ClassPathResource("ResourceRegionEncoderTests.txt", getClass());
Flux<ResourceRegion> regions = Flux.just(
new ResourceRegion(resource, 0, 6),
@ -149,7 +149,7 @@ public class ResourceRegionEncoderTests {
}
@Test // gh-22107
public void cancelWithoutDemandForSingleResourceRegion() {
void cancelWithoutDemandForSingleResourceRegion() {
Resource resource = new ClassPathResource("ResourceRegionEncoderTests.txt", getClass());
Mono<ResourceRegion> regions = Mono.just(new ResourceRegion(resource, 0, 6));
String boundary = MimeTypeUtils.generateMultipartBoundaryString();
@ -166,7 +166,7 @@ public class ResourceRegionEncoderTests {
}
@Test
public void nonExisting() {
void nonExisting() {
Resource resource = new ClassPathResource("ResourceRegionEncoderTests.txt", getClass());
Resource nonExisting = new ClassPathResource("does not exist", getClass());
Flux<ResourceRegion> regions = Flux.just(

View File

@ -43,12 +43,12 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Brian Clozel
* @author Mark Paluch
*/
public class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
private static final ResolvableType TYPE = ResolvableType.forClass(String.class);
public StringDecoderTests() {
StringDecoderTests() {
super(StringDecoder.allMimeTypes());
}
@ -77,7 +77,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
}
@Test
public void decodeMultibyteCharacterUtf16() {
void decodeMultibyteCharacterUtf16() {
String u = "ü";
String e = "é";
String o = "ø";
@ -103,7 +103,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
}
@Test
public void decodeNewLine() {
void decodeNewLine() {
Flux<DataBuffer> input = Flux.just(
stringBuffer("\r\nabc\n"),
stringBuffer("def"),
@ -128,7 +128,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
}
@Test
public void decodeNewLineIncludeDelimiters() {
void decodeNewLineIncludeDelimiters() {
this.decoder = StringDecoder.allMimeTypes(StringDecoder.DEFAULT_DELIMITERS, false);
Flux<DataBuffer> input = Flux.just(
@ -155,7 +155,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
}
@Test
public void decodeEmptyFlux() {
void decodeEmptyFlux() {
Flux<DataBuffer> input = Flux.empty();
testDecode(input, String.class, step -> step
@ -164,7 +164,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
}
@Test
public void decodeEmptyDataBuffer() {
void decodeEmptyDataBuffer() {
Flux<DataBuffer> input = Flux.just(stringBuffer(""));
Flux<String> output = this.decoder.decode(input,
TYPE, null, Collections.emptyMap());
@ -190,7 +190,7 @@ public class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
}
@Test
public void decodeToMonoWithEmptyFlux() {
void decodeToMonoWithEmptyFlux() {
Flux<DataBuffer> input = Flux.empty();
testDecodeToMono(input, String.class, step -> step
@ -205,5 +205,4 @@ public class StringDecoderTests extends AbstractDecoderTestCase<StringDecoder> {
return buffer;
}
}

View File

@ -55,10 +55,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Nathan Piper
*/
@SuppressWarnings("rawtypes")
public class TypeDescriptorTests {
class TypeDescriptorTests {
@Test
public void parameterPrimitive() throws Exception {
void parameterPrimitive() throws Exception {
TypeDescriptor desc = new TypeDescriptor(new MethodParameter(getClass().getMethod("testParameterPrimitive", int.class), 0));
assertThat(desc.getType()).isEqualTo(int.class);
assertThat(desc.getObjectType()).isEqualTo(Integer.class);
@ -71,7 +71,7 @@ public class TypeDescriptorTests {
}
@Test
public void parameterScalar() throws Exception {
void parameterScalar() throws Exception {
TypeDescriptor desc = new TypeDescriptor(new MethodParameter(getClass().getMethod("testParameterScalar", String.class), 0));
assertThat(desc.getType()).isEqualTo(String.class);
assertThat(desc.getObjectType()).isEqualTo(String.class);
@ -85,7 +85,7 @@ public class TypeDescriptorTests {
}
@Test
public void parameterList() throws Exception {
void parameterList() throws Exception {
MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterList", List.class), 0);
TypeDescriptor desc = new TypeDescriptor(methodParameter);
assertThat(desc.getType()).isEqualTo(List.class);
@ -106,7 +106,7 @@ public class TypeDescriptorTests {
}
@Test
public void parameterListNoParamTypes() throws Exception {
void parameterListNoParamTypes() throws Exception {
MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterListNoParamTypes", List.class), 0);
TypeDescriptor desc = new TypeDescriptor(methodParameter);
assertThat(desc.getType()).isEqualTo(List.class);
@ -122,7 +122,7 @@ public class TypeDescriptorTests {
}
@Test
public void parameterArray() throws Exception {
void parameterArray() throws Exception {
MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterArray", Integer[].class), 0);
TypeDescriptor desc = new TypeDescriptor(methodParameter);
assertThat(desc.getType()).isEqualTo(Integer[].class);
@ -139,7 +139,7 @@ public class TypeDescriptorTests {
}
@Test
public void parameterMap() throws Exception {
void parameterMap() throws Exception {
MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterMap", Map.class), 0);
TypeDescriptor desc = new TypeDescriptor(methodParameter);
assertThat(desc.getType()).isEqualTo(Map.class);
@ -159,7 +159,7 @@ public class TypeDescriptorTests {
}
@Test
public void parameterAnnotated() throws Exception {
void parameterAnnotated() throws Exception {
TypeDescriptor t1 = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0));
assertThat(t1.getType()).isEqualTo(String.class);
assertThat(t1.getAnnotations().length).isEqualTo(1);
@ -169,14 +169,14 @@ public class TypeDescriptorTests {
}
@Test
public void getAnnotationsReturnsClonedArray() throws Exception {
void getAnnotationsReturnsClonedArray() throws Exception {
TypeDescriptor t = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0));
t.getAnnotations()[0] = null;
assertThat(t.getAnnotations()[0]).isNotNull();
}
@Test
public void propertyComplex() throws Exception {
void propertyComplex() throws Exception {
Property property = new Property(getClass(), getClass().getMethod("getComplexProperty"),
getClass().getMethod("setComplexProperty", Map.class));
TypeDescriptor desc = new TypeDescriptor(property);
@ -185,7 +185,7 @@ public class TypeDescriptorTests {
}
@Test
public void propertyGenericType() throws Exception {
void propertyGenericType() throws Exception {
GenericType<Integer> genericBean = new IntegerType();
Property property = new Property(getClass(), genericBean.getClass().getMethod("getProperty"),
genericBean.getClass().getMethod("setProperty", Integer.class));
@ -194,7 +194,7 @@ public class TypeDescriptorTests {
}
@Test
public void propertyTypeCovariance() throws Exception {
void propertyTypeCovariance() throws Exception {
GenericType<Number> genericBean = new NumberType();
Property property = new Property(getClass(), genericBean.getClass().getMethod("getProperty"),
genericBean.getClass().getMethod("setProperty", Number.class));
@ -203,7 +203,7 @@ public class TypeDescriptorTests {
}
@Test
public void propertyGenericTypeList() throws Exception {
void propertyGenericTypeList() throws Exception {
GenericType<Integer> genericBean = new IntegerType();
Property property = new Property(getClass(), genericBean.getClass().getMethod("getListProperty"),
genericBean.getClass().getMethod("setListProperty", List.class));
@ -213,7 +213,7 @@ public class TypeDescriptorTests {
}
@Test
public void propertyGenericClassList() throws Exception {
void propertyGenericClassList() throws Exception {
IntegerClass genericBean = new IntegerClass();
Property property = new Property(genericBean.getClass(), genericBean.getClass().getMethod("getListProperty"),
genericBean.getClass().getMethod("setListProperty", List.class));
@ -225,7 +225,7 @@ public class TypeDescriptorTests {
}
@Test
public void property() throws Exception {
void property() throws Exception {
Property property = new Property(
getClass(), getClass().getMethod("getProperty"), getClass().getMethod("setProperty", Map.class));
TypeDescriptor desc = new TypeDescriptor(property);
@ -238,17 +238,17 @@ public class TypeDescriptorTests {
}
@Test
public void getAnnotationOnMethodThatIsLocallyAnnotated() throws Exception {
void getAnnotationOnMethodThatIsLocallyAnnotated() throws Exception {
assertAnnotationFoundOnMethod(MethodAnnotation1.class, "methodWithLocalAnnotation");
}
@Test
public void getAnnotationOnMethodThatIsMetaAnnotated() throws Exception {
void getAnnotationOnMethodThatIsMetaAnnotated() throws Exception {
assertAnnotationFoundOnMethod(MethodAnnotation1.class, "methodWithComposedAnnotation");
}
@Test
public void getAnnotationOnMethodThatIsMetaMetaAnnotated() throws Exception {
void getAnnotationOnMethodThatIsMetaMetaAnnotated() throws Exception {
assertAnnotationFoundOnMethod(MethodAnnotation1.class, "methodWithComposedComposedAnnotation");
}
@ -258,7 +258,7 @@ public class TypeDescriptorTests {
}
@Test
public void fieldScalar() throws Exception {
void fieldScalar() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(getClass().getField("fieldScalar"));
assertThat(typeDescriptor.isPrimitive()).isFalse();
assertThat(typeDescriptor.isArray()).isFalse();
@ -269,7 +269,7 @@ public class TypeDescriptorTests {
}
@Test
public void fieldList() throws Exception {
void fieldList() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("listOfString"));
assertThat(typeDescriptor.isArray()).isFalse();
assertThat(typeDescriptor.getType()).isEqualTo(List.class);
@ -278,7 +278,7 @@ public class TypeDescriptorTests {
}
@Test
public void fieldListOfListOfString() throws Exception {
void fieldListOfListOfString() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("listOfListOfString"));
assertThat(typeDescriptor.isArray()).isFalse();
assertThat(typeDescriptor.getType()).isEqualTo(List.class);
@ -288,7 +288,7 @@ public class TypeDescriptorTests {
}
@Test
public void fieldListOfListUnknown() throws Exception {
void fieldListOfListUnknown() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("listOfListOfUnknown"));
assertThat(typeDescriptor.isArray()).isFalse();
assertThat(typeDescriptor.getType()).isEqualTo(List.class);
@ -298,7 +298,7 @@ public class TypeDescriptorTests {
}
@Test
public void fieldArray() throws Exception {
void fieldArray() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("intArray"));
assertThat(typeDescriptor.isArray()).isTrue();
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(Integer.TYPE);
@ -306,7 +306,7 @@ public class TypeDescriptorTests {
}
@Test
public void fieldComplexTypeDescriptor() throws Exception {
void fieldComplexTypeDescriptor() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("arrayOfListOfString"));
assertThat(typeDescriptor.isArray()).isTrue();
assertThat(typeDescriptor.getElementTypeDescriptor().getType()).isEqualTo(List.class);
@ -315,7 +315,7 @@ public class TypeDescriptorTests {
}
@Test
public void fieldComplexTypeDescriptor2() throws Exception {
void fieldComplexTypeDescriptor2() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(TypeDescriptorTests.class.getDeclaredField("nestedMapField"));
assertThat(typeDescriptor.isMap()).isTrue();
assertThat(typeDescriptor.getMapKeyTypeDescriptor().getType()).isEqualTo(String.class);
@ -325,7 +325,7 @@ public class TypeDescriptorTests {
}
@Test
public void fieldMap() throws Exception {
void fieldMap() throws Exception {
TypeDescriptor desc = new TypeDescriptor(TypeDescriptorTests.class.getField("fieldMap"));
assertThat(desc.isMap()).isTrue();
assertThat(desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class);
@ -333,14 +333,14 @@ public class TypeDescriptorTests {
}
@Test
public void fieldAnnotated() throws Exception {
void fieldAnnotated() throws Exception {
TypeDescriptor typeDescriptor = new TypeDescriptor(getClass().getField("fieldAnnotated"));
assertThat(typeDescriptor.getAnnotations().length).isEqualTo(1);
assertThat(typeDescriptor.getAnnotation(FieldAnnotation.class)).isNotNull();
}
@Test
public void valueOfScalar() {
void valueOfScalar() {
TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(Integer.class);
assertThat(typeDescriptor.isPrimitive()).isFalse();
assertThat(typeDescriptor.isArray()).isFalse();
@ -351,7 +351,7 @@ public class TypeDescriptorTests {
}
@Test
public void valueOfPrimitive() {
void valueOfPrimitive() {
TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(int.class);
assertThat(typeDescriptor.isPrimitive()).isTrue();
assertThat(typeDescriptor.isArray()).isFalse();
@ -362,7 +362,7 @@ public class TypeDescriptorTests {
}
@Test
public void valueOfArray() throws Exception {
void valueOfArray() throws Exception {
TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(int[].class);
assertThat(typeDescriptor.isArray()).isTrue();
assertThat(typeDescriptor.isCollection()).isFalse();
@ -371,7 +371,7 @@ public class TypeDescriptorTests {
}
@Test
public void valueOfCollection() throws Exception {
void valueOfCollection() throws Exception {
TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(Collection.class);
assertThat(typeDescriptor.isCollection()).isTrue();
assertThat(typeDescriptor.isArray()).isFalse();
@ -380,61 +380,61 @@ public class TypeDescriptorTests {
}
@Test
public void forObject() {
void forObject() {
TypeDescriptor desc = TypeDescriptor.forObject("3");
assertThat(desc.getType()).isEqualTo(String.class);
}
@Test
public void forObjectNullTypeDescriptor() {
void forObjectNullTypeDescriptor() {
TypeDescriptor desc = TypeDescriptor.forObject(null);
assertThat((Object) desc).isNull();
}
@Test
public void nestedMethodParameterType2Levels() throws Exception {
void nestedMethodParameterType2Levels() throws Exception {
TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test2", List.class), 0), 2);
assertThat(t1.getType()).isEqualTo(String.class);
}
@Test
public void nestedMethodParameterTypeMap() throws Exception {
void nestedMethodParameterTypeMap() throws Exception {
TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test3", Map.class), 0), 1);
assertThat(t1.getType()).isEqualTo(String.class);
}
@Test
public void nestedMethodParameterTypeMapTwoLevels() throws Exception {
void nestedMethodParameterTypeMapTwoLevels() throws Exception {
TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test4", List.class), 0), 2);
assertThat(t1.getType()).isEqualTo(String.class);
}
@Test
public void nestedMethodParameterNot1NestedLevel() throws Exception {
void nestedMethodParameterNot1NestedLevel() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test4", List.class), 0, 2), 2));
}
@Test
public void nestedTooManyLevels() throws Exception {
void nestedTooManyLevels() throws Exception {
TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test4", List.class), 0), 3);
assertThat((Object) t1).isNull();
}
@Test
public void nestedMethodParameterTypeNotNestable() throws Exception {
void nestedMethodParameterTypeNotNestable() throws Exception {
TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test5", String.class), 0), 2);
assertThat((Object) t1).isNull();
}
@Test
public void nestedMethodParameterTypeInvalidNestingLevel() throws Exception {
void nestedMethodParameterTypeInvalidNestingLevel() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test5", String.class), 0, 2), 2));
}
@Test
public void nestedNotParameterized() throws Exception {
void nestedNotParameterized() throws Exception {
TypeDescriptor t1 = TypeDescriptor.nested(new MethodParameter(getClass().getMethod("test6", List.class), 0), 1);
assertThat(t1.getType()).isEqualTo(List.class);
assertThat(t1.toString()).isEqualTo("java.util.List<?>");
@ -443,20 +443,20 @@ public class TypeDescriptorTests {
}
@Test
public void nestedFieldTypeMapTwoLevels() throws Exception {
void nestedFieldTypeMapTwoLevels() throws Exception {
TypeDescriptor t1 = TypeDescriptor.nested(getClass().getField("test4"), 2);
assertThat(t1.getType()).isEqualTo(String.class);
}
@Test
public void nestedPropertyTypeMapTwoLevels() throws Exception {
void nestedPropertyTypeMapTwoLevels() throws Exception {
Property property = new Property(getClass(), getClass().getMethod("getTest4"), getClass().getMethod("setTest4", List.class));
TypeDescriptor t1 = TypeDescriptor.nested(property, 2);
assertThat(t1.getType()).isEqualTo(String.class);
}
@Test
public void collection() {
void collection() {
TypeDescriptor desc = TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Integer.class));
assertThat(desc.getType()).isEqualTo(List.class);
assertThat(desc.getObjectType()).isEqualTo(List.class);
@ -472,7 +472,7 @@ public class TypeDescriptorTests {
}
@Test
public void collectionNested() {
void collectionNested() {
TypeDescriptor desc = TypeDescriptor.collection(List.class, TypeDescriptor.collection(List.class, TypeDescriptor.valueOf(Integer.class)));
assertThat(desc.getType()).isEqualTo(List.class);
assertThat(desc.getObjectType()).isEqualTo(List.class);
@ -488,7 +488,7 @@ public class TypeDescriptorTests {
}
@Test
public void map() {
void map() {
TypeDescriptor desc = TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class));
assertThat(desc.getType()).isEqualTo(Map.class);
assertThat(desc.getObjectType()).isEqualTo(Map.class);
@ -504,7 +504,7 @@ public class TypeDescriptorTests {
}
@Test
public void mapNested() {
void mapNested() {
TypeDescriptor desc = TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class),
TypeDescriptor.map(Map.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class)));
assertThat(desc.getType()).isEqualTo(Map.class);
@ -522,7 +522,7 @@ public class TypeDescriptorTests {
}
@Test
public void narrow() {
void narrow() {
TypeDescriptor desc = TypeDescriptor.valueOf(Number.class);
Integer value = Integer.valueOf(3);
desc = desc.narrow(value);
@ -530,7 +530,7 @@ public class TypeDescriptorTests {
}
@Test
public void elementType() {
void elementType() {
TypeDescriptor desc = TypeDescriptor.valueOf(List.class);
Integer value = Integer.valueOf(3);
desc = desc.elementTypeDescriptor(value);
@ -538,7 +538,7 @@ public class TypeDescriptorTests {
}
@Test
public void elementTypePreserveContext() throws Exception {
void elementTypePreserveContext() throws Exception {
TypeDescriptor desc = new TypeDescriptor(getClass().getField("listPreserveContext"));
assertThat(desc.getElementTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class);
List<Integer> value = new ArrayList<>(3);
@ -548,7 +548,7 @@ public class TypeDescriptorTests {
}
@Test
public void mapKeyType() {
void mapKeyType() {
TypeDescriptor desc = TypeDescriptor.valueOf(Map.class);
Integer value = Integer.valueOf(3);
desc = desc.getMapKeyTypeDescriptor(value);
@ -556,7 +556,7 @@ public class TypeDescriptorTests {
}
@Test
public void mapKeyTypePreserveContext() throws Exception {
void mapKeyTypePreserveContext() throws Exception {
TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
assertThat(desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class);
List<Integer> value = new ArrayList<>(3);
@ -566,7 +566,7 @@ public class TypeDescriptorTests {
}
@Test
public void mapValueType() {
void mapValueType() {
TypeDescriptor desc = TypeDescriptor.valueOf(Map.class);
Integer value = Integer.valueOf(3);
desc = desc.getMapValueTypeDescriptor(value);
@ -574,7 +574,7 @@ public class TypeDescriptorTests {
}
@Test
public void mapValueTypePreserveContext() throws Exception {
void mapValueTypePreserveContext() throws Exception {
TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
assertThat(desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Integer.class);
List<Integer> value = new ArrayList<>(3);
@ -584,7 +584,7 @@ public class TypeDescriptorTests {
}
@Test
public void equality() throws Exception {
void equality() throws Exception {
TypeDescriptor t1 = TypeDescriptor.valueOf(String.class);
TypeDescriptor t2 = TypeDescriptor.valueOf(String.class);
TypeDescriptor t3 = TypeDescriptor.valueOf(Date.class);
@ -621,14 +621,14 @@ public class TypeDescriptorTests {
}
@Test
public void isAssignableTypes() {
void isAssignableTypes() {
assertThat(TypeDescriptor.valueOf(Integer.class).isAssignableTo(TypeDescriptor.valueOf(Number.class))).isTrue();
assertThat(TypeDescriptor.valueOf(Number.class).isAssignableTo(TypeDescriptor.valueOf(Integer.class))).isFalse();
assertThat(TypeDescriptor.valueOf(String.class).isAssignableTo(TypeDescriptor.valueOf(String[].class))).isFalse();
}
@Test
public void isAssignableElementTypes() throws Exception {
void isAssignableElementTypes() throws Exception {
assertThat(new TypeDescriptor(getClass().getField("listField")).isAssignableTo(new TypeDescriptor(getClass().getField("listField")))).isTrue();
assertThat(new TypeDescriptor(getClass().getField("notGenericList")).isAssignableTo(new TypeDescriptor(getClass().getField("listField")))).isTrue();
assertThat(new TypeDescriptor(getClass().getField("listField")).isAssignableTo(new TypeDescriptor(getClass().getField("notGenericList")))).isTrue();
@ -637,7 +637,7 @@ public class TypeDescriptorTests {
}
@Test
public void isAssignableMapKeyValueTypes() throws Exception {
void isAssignableMapKeyValueTypes() throws Exception {
assertThat(new TypeDescriptor(getClass().getField("mapField")).isAssignableTo(new TypeDescriptor(getClass().getField("mapField")))).isTrue();
assertThat(new TypeDescriptor(getClass().getField("notGenericMap")).isAssignableTo(new TypeDescriptor(getClass().getField("mapField")))).isTrue();
assertThat(new TypeDescriptor(getClass().getField("mapField")).isAssignableTo(new TypeDescriptor(getClass().getField("notGenericMap")))).isTrue();
@ -646,7 +646,7 @@ public class TypeDescriptorTests {
}
@Test
public void multiValueMap() throws Exception {
void multiValueMap() throws Exception {
TypeDescriptor td = new TypeDescriptor(getClass().getField("multiValueMap"));
assertThat(td.isMap()).isTrue();
assertThat(td.getMapKeyTypeDescriptor().getType()).isEqualTo(String.class);
@ -655,7 +655,7 @@ public class TypeDescriptorTests {
}
@Test
public void passDownGeneric() throws Exception {
void passDownGeneric() throws Exception {
TypeDescriptor td = new TypeDescriptor(getClass().getField("passDownGeneric"));
assertThat(td.getElementTypeDescriptor().getType()).isEqualTo(List.class);
assertThat(td.getElementTypeDescriptor().getElementTypeDescriptor().getType()).isEqualTo(Set.class);
@ -663,7 +663,7 @@ public class TypeDescriptorTests {
}
@Test
public void testUpCast() throws Exception {
void upCast() throws Exception {
Property property = new Property(getClass(), getClass().getMethod("getProperty"),
getClass().getMethod("setProperty", Map.class));
TypeDescriptor typeDescriptor = new TypeDescriptor(property);
@ -672,7 +672,7 @@ public class TypeDescriptorTests {
}
@Test
public void testUpCastNotSuper() throws Exception {
void upCastNotSuper() throws Exception {
Property property = new Property(getClass(), getClass().getMethod("getProperty"),
getClass().getMethod("setProperty", Map.class));
TypeDescriptor typeDescriptor = new TypeDescriptor(property);
@ -682,7 +682,7 @@ public class TypeDescriptorTests {
}
@Test
public void elementTypeForCollectionSubclass() throws Exception {
void elementTypeForCollectionSubclass() throws Exception {
@SuppressWarnings("serial")
class CustomSet extends HashSet<String> {
}
@ -692,7 +692,7 @@ public class TypeDescriptorTests {
}
@Test
public void elementTypeForMapSubclass() throws Exception {
void elementTypeForMapSubclass() throws Exception {
@SuppressWarnings("serial")
class CustomMap extends HashMap<String, Integer> {
}
@ -704,7 +704,7 @@ public class TypeDescriptorTests {
}
@Test
public void createMapArray() throws Exception {
void createMapArray() throws Exception {
TypeDescriptor mapType = TypeDescriptor.map(
LinkedHashMap.class, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(Integer.class));
TypeDescriptor arrayType = TypeDescriptor.array(mapType);
@ -713,18 +713,18 @@ public class TypeDescriptorTests {
}
@Test
public void createStringArray() throws Exception {
void createStringArray() throws Exception {
TypeDescriptor arrayType = TypeDescriptor.array(TypeDescriptor.valueOf(String.class));
assertThat(TypeDescriptor.valueOf(String[].class)).isEqualTo(arrayType);
}
@Test
public void createNullArray() throws Exception {
void createNullArray() throws Exception {
assertThat((Object) TypeDescriptor.array(null)).isNull();
}
@Test
public void serializable() throws Exception {
void serializable() throws Exception {
TypeDescriptor typeDescriptor = TypeDescriptor.forObject("");
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream outputStream = new ObjectOutputStream(out);
@ -736,20 +736,20 @@ public class TypeDescriptorTests {
}
@Test
public void createCollectionWithNullElement() throws Exception {
void createCollectionWithNullElement() throws Exception {
TypeDescriptor typeDescriptor = TypeDescriptor.collection(List.class, null);
assertThat(typeDescriptor.getElementTypeDescriptor()).isNull();
}
@Test
public void createMapWithNullElements() throws Exception {
void createMapWithNullElements() throws Exception {
TypeDescriptor typeDescriptor = TypeDescriptor.map(LinkedHashMap.class, null, null);
assertThat(typeDescriptor.getMapKeyTypeDescriptor()).isNull();
assertThat(typeDescriptor.getMapValueTypeDescriptor()).isNull();
}
@Test
public void getSource() throws Exception {
void getSource() throws Exception {
Field field = getClass().getField("fieldScalar");
MethodParameter methodParameter = new MethodParameter(getClass().getMethod("testParameterPrimitive", int.class), 0);
assertThat(new TypeDescriptor(field).getSource()).isEqualTo(field);

View File

@ -32,13 +32,12 @@ import org.springframework.util.comparator.ComparableComparator;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
/**
* Tests for {@link ConvertingComparator}.
*
* @author Phillip Webb
*/
public class ConvertingComparatorTests {
class ConvertingComparatorTests {
private final StringToInteger converter = new StringToInteger();
@ -47,45 +46,45 @@ public class ConvertingComparatorTests {
private final TestComparator comparator = new TestComparator();
@Test
public void shouldThrowOnNullComparator() throws Exception {
void shouldThrowOnNullComparator() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
new ConvertingComparator<>(null, this.converter));
}
@Test
public void shouldThrowOnNullConverter() throws Exception {
void shouldThrowOnNullConverter() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
new ConvertingComparator<String, Integer>(this.comparator, null));
}
@Test
public void shouldThrowOnNullConversionService() throws Exception {
void shouldThrowOnNullConversionService() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
new ConvertingComparator<String, Integer>(this.comparator, null, Integer.class));
}
@Test
public void shouldThrowOnNullType() throws Exception {
void shouldThrowOnNullType() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
new ConvertingComparator<String, Integer>(this.comparator, this.conversionService, null));
}
@Test
public void shouldUseConverterOnCompare() throws Exception {
void shouldUseConverterOnCompare() throws Exception {
ConvertingComparator<String, Integer> convertingComparator = new ConvertingComparator<>(
this.comparator, this.converter);
testConversion(convertingComparator);
}
@Test
public void shouldUseConversionServiceOnCompare() throws Exception {
void shouldUseConversionServiceOnCompare() throws Exception {
ConvertingComparator<String, Integer> convertingComparator = new ConvertingComparator<>(
comparator, conversionService, Integer.class);
testConversion(convertingComparator);
}
@Test
public void shouldGetForConverter() throws Exception {
void shouldGetForConverter() throws Exception {
testConversion(new ConvertingComparator<>(comparator, converter));
}
@ -97,7 +96,7 @@ public class ConvertingComparatorTests {
}
@Test
public void shouldGetMapEntryKeys() throws Exception {
void shouldGetMapEntryKeys() throws Exception {
ArrayList<Entry<String, Integer>> list = createReverseOrderMapEntryList();
Comparator<Map.Entry<String, Integer>> comparator = ConvertingComparator.mapEntryKeys(new ComparableComparator<String>());
Collections.sort(list, comparator);
@ -105,7 +104,7 @@ public class ConvertingComparatorTests {
}
@Test
public void shouldGetMapEntryValues() throws Exception {
void shouldGetMapEntryValues() throws Exception {
ArrayList<Entry<String, Integer>> list = createReverseOrderMapEntryList();
Comparator<Map.Entry<String, Integer>> comparator = ConvertingComparator.mapEntryValues(new ComparableComparator<Integer>());
Collections.sort(list, comparator);

View File

@ -71,34 +71,34 @@ import static org.springframework.tests.TestGroup.PERFORMANCE;
* @author Stephane Nicoll
* @author Sam Brannen
*/
public class DefaultConversionServiceTests {
class DefaultConversionServiceTests {
private final DefaultConversionService conversionService = new DefaultConversionService();
@Test
public void testStringToCharacter() {
void stringToCharacter() {
assertThat(conversionService.convert("1", Character.class)).isEqualTo(Character.valueOf('1'));
}
@Test
public void testStringToCharacterEmptyString() {
void stringToCharacterEmptyString() {
assertThat(conversionService.convert("", Character.class)).isEqualTo(null);
}
@Test
public void testStringToCharacterInvalidString() {
void stringToCharacterInvalidString() {
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
conversionService.convert("invalid", Character.class));
}
@Test
public void testCharacterToString() {
void characterToString() {
assertThat(conversionService.convert('3', String.class)).isEqualTo("3");
}
@Test
public void testStringToBooleanTrue() {
void stringToBooleanTrue() {
assertThat(conversionService.convert("true", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("on", Boolean.class)).isEqualTo(true);
assertThat(conversionService.convert("yes", Boolean.class)).isEqualTo(true);
@ -109,7 +109,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void testStringToBooleanFalse() {
void stringToBooleanFalse() {
assertThat(conversionService.convert("false", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("off", Boolean.class)).isEqualTo(false);
assertThat(conversionService.convert("no", Boolean.class)).isEqualTo(false);
@ -120,201 +120,201 @@ public class DefaultConversionServiceTests {
}
@Test
public void testStringToBooleanEmptyString() {
void stringToBooleanEmptyString() {
assertThat(conversionService.convert("", Boolean.class)).isEqualTo(null);
}
@Test
public void testStringToBooleanInvalidString() {
void stringToBooleanInvalidString() {
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
conversionService.convert("invalid", Boolean.class));
}
@Test
public void testBooleanToString() {
void booleanToString() {
assertThat(conversionService.convert(true, String.class)).isEqualTo("true");
}
@Test
public void testStringToByte() {
void stringToByte() {
assertThat(conversionService.convert("1", Byte.class)).isEqualTo((byte) 1);
}
@Test
public void testByteToString() {
void byteToString() {
assertThat(conversionService.convert("A".getBytes()[0], String.class)).isEqualTo("65");
}
@Test
public void testStringToShort() {
void stringToShort() {
assertThat(conversionService.convert("1", Short.class)).isEqualTo((short) 1);
}
@Test
public void testShortToString() {
void shortToString() {
short three = 3;
assertThat(conversionService.convert(three, String.class)).isEqualTo("3");
}
@Test
public void testStringToInteger() {
void stringToInteger() {
assertThat(conversionService.convert("1", Integer.class)).isEqualTo((int) Integer.valueOf(1));
}
@Test
public void testIntegerToString() {
void integerToString() {
assertThat(conversionService.convert(3, String.class)).isEqualTo("3");
}
@Test
public void testStringToLong() {
void stringToLong() {
assertThat(conversionService.convert("1", Long.class)).isEqualTo(Long.valueOf(1));
}
@Test
public void testLongToString() {
void longToString() {
assertThat(conversionService.convert(3L, String.class)).isEqualTo("3");
}
@Test
public void testStringToFloat() {
void stringToFloat() {
assertThat(conversionService.convert("1.0", Float.class)).isEqualTo(Float.valueOf("1.0"));
}
@Test
public void testFloatToString() {
void floatToString() {
assertThat(conversionService.convert(Float.valueOf("1.0"), String.class)).isEqualTo("1.0");
}
@Test
public void testStringToDouble() {
void stringToDouble() {
assertThat(conversionService.convert("1.0", Double.class)).isEqualTo(Double.valueOf("1.0"));
}
@Test
public void testDoubleToString() {
void doubleToString() {
assertThat(conversionService.convert(Double.valueOf("1.0"), String.class)).isEqualTo("1.0");
}
@Test
public void testStringToBigInteger() {
void stringToBigInteger() {
assertThat(conversionService.convert("1", BigInteger.class)).isEqualTo(new BigInteger("1"));
}
@Test
public void testBigIntegerToString() {
void bigIntegerToString() {
assertThat(conversionService.convert(new BigInteger("100"), String.class)).isEqualTo("100");
}
@Test
public void testStringToBigDecimal() {
void stringToBigDecimal() {
assertThat(conversionService.convert("1.0", BigDecimal.class)).isEqualTo(new BigDecimal("1.0"));
}
@Test
public void testBigDecimalToString() {
void bigDecimalToString() {
assertThat(conversionService.convert(new BigDecimal("100.00"), String.class)).isEqualTo("100.00");
}
@Test
public void testStringToNumber() {
void stringToNumber() {
assertThat(conversionService.convert("1.0", Number.class)).isEqualTo(new BigDecimal("1.0"));
}
@Test
public void testStringToNumberEmptyString() {
void stringToNumberEmptyString() {
assertThat(conversionService.convert("", Number.class)).isEqualTo(null);
}
@Test
public void testStringToEnum() {
void stringToEnum() {
assertThat(conversionService.convert("BAR", Foo.class)).isEqualTo(Foo.BAR);
}
@Test
public void testStringToEnumWithSubclass() {
void stringToEnumWithSubclass() {
assertThat(conversionService.convert("BAZ", SubFoo.BAR.getClass())).isEqualTo(SubFoo.BAZ);
}
@Test
public void testStringToEnumEmptyString() {
void stringToEnumEmptyString() {
assertThat(conversionService.convert("", Foo.class)).isEqualTo(null);
}
@Test
public void testEnumToString() {
void enumToString() {
assertThat(conversionService.convert(Foo.BAR, String.class)).isEqualTo("BAR");
}
@Test
public void testIntegerToEnum() {
void integerToEnum() {
assertThat(conversionService.convert(0, Foo.class)).isEqualTo(Foo.BAR);
}
@Test
public void testIntegerToEnumWithSubclass() {
void integerToEnumWithSubclass() {
assertThat(conversionService.convert(1, SubFoo.BAR.getClass())).isEqualTo(SubFoo.BAZ);
}
@Test
public void testIntegerToEnumNull() {
void integerToEnumNull() {
assertThat(conversionService.convert(null, Foo.class)).isEqualTo(null);
}
@Test
public void testEnumToInteger() {
void enumToInteger() {
assertThat(conversionService.convert(Foo.BAR, Integer.class)).isEqualTo((int) Integer.valueOf(0));
}
@Test
public void testStringToEnumSet() throws Exception {
void stringToEnumSet() throws Exception {
assertThat(conversionService.convert("BAR", TypeDescriptor.valueOf(String.class),
new TypeDescriptor(getClass().getField("enumSet")))).isEqualTo(EnumSet.of(Foo.BAR));
}
@Test
public void testStringToLocale() {
void stringToLocale() {
assertThat(conversionService.convert("en", Locale.class)).isEqualTo(Locale.ENGLISH);
}
@Test
public void testStringToLocaleWithCountry() {
void stringToLocaleWithCountry() {
assertThat(conversionService.convert("en_US", Locale.class)).isEqualTo(Locale.US);
}
@Test
public void testStringToLocaleWithLanguageTag() {
void stringToLocaleWithLanguageTag() {
assertThat(conversionService.convert("en-US", Locale.class)).isEqualTo(Locale.US);
}
@Test
public void testStringToCharset() {
void stringToCharset() {
assertThat(conversionService.convert("UTF-8", Charset.class)).isEqualTo(StandardCharsets.UTF_8);
}
@Test
public void testCharsetToString() {
void charsetToString() {
assertThat(conversionService.convert(StandardCharsets.UTF_8, String.class)).isEqualTo("UTF-8");
}
@Test
public void testStringToCurrency() {
void stringToCurrency() {
assertThat(conversionService.convert("EUR", Currency.class)).isEqualTo(Currency.getInstance("EUR"));
}
@Test
public void testCurrencyToString() {
void currencyToString() {
assertThat(conversionService.convert(Currency.getInstance("USD"), String.class)).isEqualTo("USD");
}
@Test
public void testStringToString() {
void stringToString() {
String str = "test";
assertThat(conversionService.convert(str, String.class)).isSameAs(str);
}
@Test
public void testUuidToStringAndStringToUuid() {
void uuidToStringAndStringToUuid() {
UUID uuid = UUID.randomUUID();
String convertToString = conversionService.convert(uuid, String.class);
UUID convertToUUID = conversionService.convert(convertToString, UUID.class);
@ -322,30 +322,30 @@ public class DefaultConversionServiceTests {
}
@Test
public void testNumberToNumber() {
void numberToNumber() {
assertThat(conversionService.convert(1, Long.class)).isEqualTo(Long.valueOf(1));
}
@Test
public void testNumberToNumberNotSupportedNumber() {
void numberToNumberNotSupportedNumber() {
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
conversionService.convert(1, CustomNumber.class));
}
@Test
public void testNumberToCharacter() {
void numberToCharacter() {
assertThat(conversionService.convert(65, Character.class)).isEqualTo(Character.valueOf('A'));
}
@Test
public void testCharacterToNumber() {
void characterToNumber() {
assertThat(conversionService.convert('A', Integer.class)).isEqualTo(65);
}
// collection conversion
@Test
public void convertArrayToCollectionInterface() {
void convertArrayToCollectionInterface() {
List<?> result = conversionService.convert(new String[] {"1", "2", "3"}, List.class);
assertThat(result.get(0)).isEqualTo("1");
assertThat(result.get(1)).isEqualTo("2");
@ -353,7 +353,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertArrayToCollectionGenericTypeConversion() throws Exception {
void convertArrayToCollectionGenericTypeConversion() throws Exception {
@SuppressWarnings("unchecked")
List<Integer> result = (List<Integer>) conversionService.convert(new String[] {"1", "2", "3"}, TypeDescriptor
.valueOf(String[].class), new TypeDescriptor(getClass().getDeclaredField("genericList")));
@ -363,7 +363,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertArrayToStream() throws Exception {
void convertArrayToStream() throws Exception {
String[] source = {"1", "3", "4"};
@SuppressWarnings("unchecked")
Stream<Integer> result = (Stream<Integer>) this.conversionService.convert(source,
@ -373,7 +373,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void testSpr7766() throws Exception {
void spr7766() throws Exception {
ConverterRegistry registry = (conversionService);
registry.addConverter(new ColorConverter());
@SuppressWarnings("unchecked")
@ -386,7 +386,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertArrayToCollectionImpl() {
void convertArrayToCollectionImpl() {
LinkedList<?> result = conversionService.convert(new String[] {"1", "2", "3"}, LinkedList.class);
assertThat(result.get(0)).isEqualTo("1");
assertThat(result.get(1)).isEqualTo("2");
@ -394,31 +394,31 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertArrayToAbstractCollection() {
void convertArrayToAbstractCollection() {
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
conversionService.convert(new String[]{"1", "2", "3"}, AbstractList.class));
}
@Test
public void convertArrayToString() {
void convertArrayToString() {
String result = conversionService.convert(new String[] {"1", "2", "3"}, String.class);
assertThat(result).isEqualTo("1,2,3");
}
@Test
public void convertArrayToStringWithElementConversion() {
void convertArrayToStringWithElementConversion() {
String result = conversionService.convert(new Integer[] {1, 2, 3}, String.class);
assertThat(result).isEqualTo("1,2,3");
}
@Test
public void convertEmptyArrayToString() {
void convertEmptyArrayToString() {
String result = conversionService.convert(new String[0], String.class);
assertThat(result).isEqualTo("");
}
@Test
public void convertStringToArray() {
void convertStringToArray() {
String[] result = conversionService.convert("1,2,3", String[].class);
assertThat(result.length).isEqualTo(3);
assertThat(result[0]).isEqualTo("1");
@ -427,7 +427,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringToArrayWithElementConversion() {
void convertStringToArrayWithElementConversion() {
Integer[] result = conversionService.convert("1,2,3", Integer[].class);
assertThat(result.length).isEqualTo(3);
assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(1));
@ -436,7 +436,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringToPrimitiveArrayWithElementConversion() {
void convertStringToPrimitiveArrayWithElementConversion() {
int[] result = conversionService.convert("1,2,3", int[].class);
assertThat(result.length).isEqualTo(3);
assertThat(result[0]).isEqualTo(1);
@ -445,48 +445,48 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertEmptyStringToArray() {
void convertEmptyStringToArray() {
String[] result = conversionService.convert("", String[].class);
assertThat(result.length).isEqualTo(0);
}
@Test
public void convertArrayToObject() {
void convertArrayToObject() {
Object[] array = new Object[] {3L};
Object result = conversionService.convert(array, Long.class);
assertThat(result).isEqualTo(3L);
}
@Test
public void convertArrayToObjectWithElementConversion() {
void convertArrayToObjectWithElementConversion() {
String[] array = new String[] {"3"};
Integer result = conversionService.convert(array, Integer.class);
assertThat((int) result).isEqualTo((int) Integer.valueOf(3));
}
@Test
public void convertArrayToObjectAssignableTargetType() {
void convertArrayToObjectAssignableTargetType() {
Long[] array = new Long[] {3L};
Long[] result = (Long[]) conversionService.convert(array, Object.class);
assertThat(result).isEqualTo(array);
}
@Test
public void convertObjectToArray() {
void convertObjectToArray() {
Object[] result = conversionService.convert(3L, Object[].class);
assertThat(result.length).isEqualTo(1);
assertThat(result[0]).isEqualTo(3L);
}
@Test
public void convertObjectToArrayWithElementConversion() {
void convertObjectToArrayWithElementConversion() {
Integer[] result = conversionService.convert(3L, Integer[].class);
assertThat(result.length).isEqualTo(1);
assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(3));
}
@Test
public void convertCollectionToArray() {
void convertCollectionToArray() {
List<String> list = new ArrayList<>();
list.add("1");
list.add("2");
@ -498,7 +498,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertCollectionToArrayWithElementConversion() {
void convertCollectionToArrayWithElementConversion() {
List<String> list = new ArrayList<>();
list.add("1");
list.add("2");
@ -510,14 +510,14 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertCollectionToString() {
void convertCollectionToString() {
List<String> list = Arrays.asList("foo", "bar");
String result = conversionService.convert(list, String.class);
assertThat(result).isEqualTo("foo,bar");
}
@Test
public void convertCollectionToStringWithElementConversion() throws Exception {
void convertCollectionToStringWithElementConversion() throws Exception {
List<Integer> list = Arrays.asList(3, 5);
String result = (String) conversionService.convert(list,
new TypeDescriptor(getClass().getField("genericList")), TypeDescriptor.valueOf(String.class));
@ -525,7 +525,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringToCollection() {
void convertStringToCollection() {
List<?> result = conversionService.convert("1,2,3", List.class);
assertThat(result.size()).isEqualTo(3);
assertThat(result.get(0)).isEqualTo("1");
@ -534,7 +534,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringToCollectionWithElementConversion() throws Exception {
void convertStringToCollectionWithElementConversion() throws Exception {
List<?> result = (List<?>) conversionService.convert("1,2,3", TypeDescriptor.valueOf(String.class),
new TypeDescriptor(getClass().getField("genericList")));
assertThat(result.size()).isEqualTo(3);
@ -544,27 +544,27 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertEmptyStringToCollection() {
void convertEmptyStringToCollection() {
Collection<?> result = conversionService.convert("", Collection.class);
assertThat(result.size()).isEqualTo(0);
}
@Test
public void convertCollectionToObject() {
void convertCollectionToObject() {
List<Long> list = Collections.singletonList(3L);
Long result = conversionService.convert(list, Long.class);
assertThat(result).isEqualTo(Long.valueOf(3));
}
@Test
public void convertCollectionToObjectWithElementConversion() {
void convertCollectionToObjectWithElementConversion() {
List<String> list = Collections.singletonList("3");
Integer result = conversionService.convert(list, Integer.class);
assertThat((int) result).isEqualTo((int) Integer.valueOf(3));
}
@Test
public void convertCollectionToObjectAssignableTarget() throws Exception {
void convertCollectionToObjectAssignableTarget() throws Exception {
Collection<String> source = new ArrayList<>();
source.add("foo");
Object result = conversionService.convert(source, new TypeDescriptor(getClass().getField("assignableTarget")));
@ -572,7 +572,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertCollectionToObjectWithCustomConverter() {
void convertCollectionToObjectWithCustomConverter() {
List<String> source = new ArrayList<>();
source.add("A");
source.add("B");
@ -582,14 +582,14 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertObjectToCollection() {
void convertObjectToCollection() {
List<?> result = conversionService.convert(3L, List.class);
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0)).isEqualTo(3L);
}
@Test
public void convertObjectToCollectionWithElementConversion() throws Exception {
void convertObjectToCollectionWithElementConversion() throws Exception {
@SuppressWarnings("unchecked")
List<Integer> result = (List<Integer>) conversionService.convert(3L, TypeDescriptor.valueOf(Long.class),
new TypeDescriptor(getClass().getField("genericList")));
@ -598,7 +598,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringArrayToIntegerArray() {
void convertStringArrayToIntegerArray() {
Integer[] result = conversionService.convert(new String[] {"1", "2", "3"}, Integer[].class);
assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(1));
assertThat((int) result[1]).isEqualTo((int) Integer.valueOf(2));
@ -606,7 +606,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringArrayToIntArray() {
void convertStringArrayToIntArray() {
int[] result = conversionService.convert(new String[] {"1", "2", "3"}, int[].class);
assertThat(result[0]).isEqualTo(1);
assertThat(result[1]).isEqualTo(2);
@ -614,7 +614,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertIntegerArrayToIntegerArray() {
void convertIntegerArrayToIntegerArray() {
Integer[] result = conversionService.convert(new Integer[] {1, 2, 3}, Integer[].class);
assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(1));
assertThat((int) result[1]).isEqualTo((int) Integer.valueOf(2));
@ -622,7 +622,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertIntegerArrayToIntArray() {
void convertIntegerArrayToIntArray() {
int[] result = conversionService.convert(new Integer[] {1, 2, 3}, int[].class);
assertThat(result[0]).isEqualTo(1);
assertThat(result[1]).isEqualTo(2);
@ -630,7 +630,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertObjectArrayToIntegerArray() {
void convertObjectArrayToIntegerArray() {
Integer[] result = conversionService.convert(new Object[] {1, 2, 3}, Integer[].class);
assertThat((int) result[0]).isEqualTo((int) Integer.valueOf(1));
assertThat((int) result[1]).isEqualTo((int) Integer.valueOf(2));
@ -638,7 +638,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertObjectArrayToIntArray() {
void convertObjectArrayToIntArray() {
int[] result = conversionService.convert(new Object[] {1, 2, 3}, int[].class);
assertThat(result[0]).isEqualTo(1);
assertThat(result[1]).isEqualTo(2);
@ -646,14 +646,14 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertByteArrayToWrapperArray() {
void convertByteArrayToWrapperArray() {
byte[] byteArray = new byte[] {1, 2, 3};
Byte[] converted = conversionService.convert(byteArray, Byte[].class);
assertThat(converted).isEqualTo(new Byte[]{1, 2, 3});
}
@Test
public void convertArrayToArrayAssignable() {
void convertArrayToArrayAssignable() {
int[] result = conversionService.convert(new int[] {1, 2, 3}, int[].class);
assertThat(result[0]).isEqualTo(1);
assertThat(result[1]).isEqualTo(2);
@ -661,7 +661,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertListOfNonStringifiable() {
void convertListOfNonStringifiable() {
List<Object> list = Arrays.asList(new TestEntity(1L), new TestEntity(2L));
assertThat(conversionService.canConvert(list.getClass(), String.class)).isTrue();
try {
@ -675,7 +675,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertListOfStringToString() {
void convertListOfStringToString() {
List<String> list = Arrays.asList("Foo", "Bar");
assertThat(conversionService.canConvert(list.getClass(), String.class)).isTrue();
String result = conversionService.convert(list, String.class);
@ -683,7 +683,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertListOfListToString() {
void convertListOfListToString() {
List<String> list1 = Arrays.asList("Foo", "Bar");
List<String> list2 = Arrays.asList("Baz", "Boop");
List<List<String>> list = Arrays.asList(list1, list2);
@ -693,7 +693,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertCollectionToCollection() throws Exception {
void convertCollectionToCollection() throws Exception {
Set<String> foo = new LinkedHashSet<>();
foo.add("1");
foo.add("2");
@ -707,7 +707,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertCollectionToCollectionNull() throws Exception {
void convertCollectionToCollectionNull() throws Exception {
@SuppressWarnings("unchecked")
List<Integer> bar = (List<Integer>) conversionService.convert(null,
TypeDescriptor.valueOf(LinkedHashSet.class), new TypeDescriptor(getClass().getField("genericList")));
@ -716,7 +716,7 @@ public class DefaultConversionServiceTests {
@Test
@SuppressWarnings("rawtypes")
public void convertCollectionToCollectionNotGeneric() {
void convertCollectionToCollectionNotGeneric() {
Set<String> foo = new LinkedHashSet<>();
foo.add("1");
foo.add("2");
@ -730,7 +730,7 @@ public class DefaultConversionServiceTests {
@Test
@SuppressWarnings({"unchecked", "rawtypes"})
public void convertCollectionToCollectionSpecialCaseSourceImpl() throws Exception {
void convertCollectionToCollectionSpecialCaseSourceImpl() throws Exception {
Map map = new LinkedHashMap();
map.put("1", "1");
map.put("2", "2");
@ -745,7 +745,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void collection() {
void collection() {
List<String> strings = new ArrayList<>();
strings.add("3");
strings.add("9");
@ -757,7 +757,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertMapToMap() throws Exception {
void convertMapToMap() throws Exception {
Map<String, String> foo = new HashMap<>();
foo.put("1", "BAR");
foo.put("2", "BAZ");
@ -769,7 +769,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertHashMapValuesToList() {
void convertHashMapValuesToList() {
Map<String, Integer> hashMap = new LinkedHashMap<>();
hashMap.put("1", 1);
hashMap.put("2", 2);
@ -778,7 +778,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void map() {
void map() {
Map<String, String> strings = new HashMap<>();
strings.put("3", "9");
strings.put("6", "31");
@ -790,7 +790,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertPropertiesToString() {
void convertPropertiesToString() {
Properties foo = new Properties();
foo.setProperty("1", "BAR");
foo.setProperty("2", "BAZ");
@ -800,7 +800,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringToProperties() {
void convertStringToProperties() {
Properties result = conversionService.convert("a=b\nc=2\nd=", Properties.class);
assertThat(result.size()).isEqualTo(3);
assertThat(result.getProperty("a")).isEqualTo("b");
@ -809,7 +809,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringToPropertiesWithSpaces() {
void convertStringToPropertiesWithSpaces() {
Properties result = conversionService.convert(" foo=bar\n bar=baz\n baz=boop", Properties.class);
assertThat(result.get("foo")).isEqualTo("bar");
assertThat(result.get("bar")).isEqualTo("baz");
@ -819,7 +819,7 @@ public class DefaultConversionServiceTests {
// generic object conversion
@Test
public void convertObjectToStringWithValueOfMethodPresentUsingToString() {
void convertObjectToStringWithValueOfMethodPresentUsingToString() {
ISBN.reset();
assertThat(conversionService.convert(new ISBN("123456789"), String.class)).isEqualTo("123456789");
@ -829,7 +829,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertObjectToObjectUsingValueOfMethod() {
void convertObjectToObjectUsingValueOfMethod() {
ISBN.reset();
assertThat(conversionService.convert("123456789", ISBN.class)).isEqualTo(new ISBN("123456789"));
@ -840,7 +840,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertObjectToStringUsingToString() {
void convertObjectToStringUsingToString() {
SSN.reset();
assertThat(conversionService.convert(new SSN("123456789"), String.class)).isEqualTo("123456789");
@ -849,7 +849,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertObjectToObjectUsingObjectConstructor() {
void convertObjectToObjectUsingObjectConstructor() {
SSN.reset();
assertThat(conversionService.convert("123456789", SSN.class)).isEqualTo(new SSN("123456789"));
@ -858,64 +858,64 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertStringToTimezone() {
void convertStringToTimezone() {
assertThat(conversionService.convert("GMT+2", TimeZone.class).getID()).isEqualTo("GMT+02:00");
}
@Test
public void convertObjectToStringWithJavaTimeOfMethodPresent() {
void convertObjectToStringWithJavaTimeOfMethodPresent() {
assertThat(conversionService.convert(ZoneId.of("GMT+1"), String.class).startsWith("GMT+")).isTrue();
}
@Test
public void convertObjectToStringNotSupported() {
void convertObjectToStringNotSupported() {
assertThat(conversionService.canConvert(TestEntity.class, String.class)).isFalse();
}
@Test
public void convertObjectToObjectWithJavaTimeOfMethod() {
void convertObjectToObjectWithJavaTimeOfMethod() {
assertThat(conversionService.convert("GMT+1", ZoneId.class)).isEqualTo(ZoneId.of("GMT+1"));
}
@Test
public void convertObjectToObjectNoValueOfMethodOrConstructor() {
void convertObjectToObjectNoValueOfMethodOrConstructor() {
assertThatExceptionOfType(ConverterNotFoundException.class).isThrownBy(() ->
conversionService.convert(Long.valueOf(3), SSN.class));
}
@Test
public void convertObjectToObjectFinderMethod() {
void convertObjectToObjectFinderMethod() {
TestEntity e = conversionService.convert(1L, TestEntity.class);
assertThat(e.getId()).isEqualTo(Long.valueOf(1));
}
@Test
public void convertObjectToObjectFinderMethodWithNull() {
void convertObjectToObjectFinderMethodWithNull() {
TestEntity entity = (TestEntity) conversionService.convert(null,
TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(TestEntity.class));
assertThat((Object) entity).isNull();
}
@Test
public void convertObjectToObjectFinderMethodWithIdConversion() {
void convertObjectToObjectFinderMethodWithIdConversion() {
TestEntity entity = conversionService.convert("1", TestEntity.class);
assertThat(entity.getId()).isEqualTo(Long.valueOf(1));
}
@Test
public void convertCharArrayToString() {
void convertCharArrayToString() {
String converted = conversionService.convert(new char[] {'a', 'b', 'c'}, String.class);
assertThat(converted).isEqualTo("a,b,c");
}
@Test
public void convertStringToCharArray() {
void convertStringToCharArray() {
char[] converted = conversionService.convert("a,b,c", char[].class);
assertThat(converted).isEqualTo(new char[]{'a', 'b', 'c'});
}
@Test
public void convertStringToCustomCharArray() {
void convertStringToCustomCharArray() {
conversionService.addConverter(String.class, char[].class, String::toCharArray);
char[] converted = conversionService.convert("abc", char[].class);
assertThat(converted).isEqualTo(new char[] {'a', 'b', 'c'});
@ -923,7 +923,7 @@ public class DefaultConversionServiceTests {
@Test
@SuppressWarnings("unchecked")
public void multidimensionalArrayToListConversionShouldConvertEntriesCorrectly() {
void multidimensionalArrayToListConversionShouldConvertEntriesCorrectly() {
String[][] grid = new String[][] {new String[] {"1", "2", "3", "4"}, new String[] {"5", "6", "7", "8"},
new String[] {"9", "10", "11", "12"}};
List<String[]> converted = conversionService.convert(grid, List.class);
@ -932,7 +932,7 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertCannotOptimizeArray() {
void convertCannotOptimizeArray() {
conversionService.addConverter(Byte.class, Byte.class, source -> (byte) (source + 1));
byte[] byteArray = new byte[] {1, 2, 3};
byte[] converted = conversionService.convert(byteArray, byte[].class);
@ -942,7 +942,7 @@ public class DefaultConversionServiceTests {
@Test
@SuppressWarnings("unchecked")
public void convertObjectToOptional() {
void convertObjectToOptional() {
Method method = ClassUtils.getMethod(TestEntity.class, "handleOptionalValue", Optional.class);
MethodParameter parameter = new MethodParameter(method, 0);
TypeDescriptor descriptor = new TypeDescriptor(parameter);
@ -952,14 +952,14 @@ public class DefaultConversionServiceTests {
}
@Test
public void convertObjectToOptionalNull() {
void convertObjectToOptionalNull() {
assertThat(conversionService.convert(null, TypeDescriptor.valueOf(Object.class),
TypeDescriptor.valueOf(Optional.class))).isSameAs(Optional.empty());
assertThat((Object) conversionService.convert(null, Optional.class)).isSameAs(Optional.empty());
}
@Test
public void convertExistingOptional() {
void convertExistingOptional() {
assertThat(conversionService.convert(Optional.empty(), TypeDescriptor.valueOf(Object.class),
TypeDescriptor.valueOf(Optional.class))).isSameAs(Optional.empty());
assertThat((Object) conversionService.convert(Optional.empty(), Optional.class)).isSameAs(Optional.empty());
@ -967,7 +967,7 @@ public class DefaultConversionServiceTests {
@Test
@EnabledForTestGroups(PERFORMANCE)
public void testPerformance1() {
void testPerformance1() {
StopWatch watch = new StopWatch("integer->string conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
for (int i = 0; i < 4000000; i++) {

View File

@ -25,23 +25,19 @@ import org.springframework.core.convert.converter.Converter;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link ByteBufferConverter}.
*
* @author Phillip Webb
* @author Juergen Hoeller
*/
public class ByteBufferConverterTests {
class ByteBufferConverterTests {
private GenericConversionService conversionService;
@BeforeEach
public void setup() {
void setup() {
this.conversionService = new DefaultConversionService();
this.conversionService.addConverter(new ByteArrayToOtherTypeConverter());
this.conversionService.addConverter(new OtherTypeToByteArrayConverter());
@ -49,7 +45,7 @@ public class ByteBufferConverterTests {
@Test
public void byteArrayToByteBuffer() throws Exception {
void byteArrayToByteBuffer() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
ByteBuffer convert = this.conversionService.convert(bytes, ByteBuffer.class);
assertThat(convert.array()).isNotSameAs(bytes);
@ -57,7 +53,7 @@ public class ByteBufferConverterTests {
}
@Test
public void byteBufferToByteArray() throws Exception {
void byteBufferToByteArray() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
byte[] convert = this.conversionService.convert(byteBuffer, byte[].class);
@ -66,7 +62,7 @@ public class ByteBufferConverterTests {
}
@Test
public void byteBufferToOtherType() throws Exception {
void byteBufferToOtherType() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
OtherType convert = this.conversionService.convert(byteBuffer, OtherType.class);
@ -75,7 +71,7 @@ public class ByteBufferConverterTests {
}
@Test
public void otherTypeToByteBuffer() throws Exception {
void otherTypeToByteBuffer() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
OtherType otherType = new OtherType(bytes);
ByteBuffer convert = this.conversionService.convert(otherType, ByteBuffer.class);
@ -84,7 +80,7 @@ public class ByteBufferConverterTests {
}
@Test
public void byteBufferToByteBuffer() throws Exception {
void byteBufferToByteBuffer() throws Exception {
byte[] bytes = new byte[] { 1, 2, 3 };
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
ByteBuffer convert = this.conversionService.convert(byteBuffer, ByteBuffer.class);
@ -105,7 +101,6 @@ public class ByteBufferConverterTests {
}
private static class ByteArrayToOtherTypeConverter implements Converter<byte[], OtherType> {
@Override

View File

@ -48,19 +48,19 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Juergen Hoeller
* @author Stephane Nicoll
*/
public class CollectionToCollectionConverterTests {
class CollectionToCollectionConverterTests {
private GenericConversionService conversionService = new GenericConversionService();
@BeforeEach
public void setUp() {
void setUp() {
conversionService.addConverter(new CollectionToCollectionConverter(conversionService));
}
@Test
public void scalarList() throws Exception {
void scalarList() throws Exception {
List<String> list = new ArrayList<>();
list.add("9");
list.add("37");
@ -84,7 +84,7 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void emptyListToList() throws Exception {
void emptyListToList() throws Exception {
conversionService.addConverter(new CollectionToCollectionConverter(conversionService));
conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> list = new ArrayList<>();
@ -95,7 +95,7 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void emptyListToListDifferentTargetType() throws Exception {
void emptyListToListDifferentTargetType() throws Exception {
conversionService.addConverter(new CollectionToCollectionConverter(conversionService));
conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> list = new ArrayList<>();
@ -109,7 +109,7 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void collectionToObjectInteraction() throws Exception {
void collectionToObjectInteraction() throws Exception {
List<List<String>> list = new ArrayList<>();
list.add(Arrays.asList("9", "12"));
list.add(Arrays.asList("37", "23"));
@ -120,7 +120,7 @@ public class CollectionToCollectionConverterTests {
@Test
@SuppressWarnings("unchecked")
public void arrayCollectionToObjectInteraction() throws Exception {
void arrayCollectionToObjectInteraction() throws Exception {
List<String>[] array = new List[2];
array[0] = Arrays.asList("9", "12");
array[1] = Arrays.asList("37", "23");
@ -132,7 +132,7 @@ public class CollectionToCollectionConverterTests {
@Test
@SuppressWarnings("unchecked")
public void objectToCollection() throws Exception {
void objectToCollection() throws Exception {
List<List<String>> list = new ArrayList<>();
list.add(Arrays.asList("9", "12"));
list.add(Arrays.asList("37", "23"));
@ -151,7 +151,7 @@ public class CollectionToCollectionConverterTests {
@Test
@SuppressWarnings("unchecked")
public void stringToCollection() throws Exception {
void stringToCollection() throws Exception {
List<List<String>> list = new ArrayList<>();
list.add(Arrays.asList("9,12"));
list.add(Arrays.asList("37,23"));
@ -170,21 +170,21 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void convertEmptyVector_shouldReturnEmptyArrayList() {
void convertEmptyVector_shouldReturnEmptyArrayList() {
Vector<String> vector = new Vector<>();
vector.add("Element");
testCollectionConversionToArrayList(vector);
}
@Test
public void convertNonEmptyVector_shouldReturnNonEmptyArrayList() {
void convertNonEmptyVector_shouldReturnNonEmptyArrayList() {
Vector<String> vector = new Vector<>();
vector.add("Element");
testCollectionConversionToArrayList(vector);
}
@Test
public void testCollectionsEmptyList() throws Exception {
void collectionsEmptyList() throws Exception {
CollectionToCollectionConverter converter = new CollectionToCollectionConverter(new GenericConversionService());
TypeDescriptor type = new TypeDescriptor(getClass().getField("list"));
converter.convert(list, type, TypeDescriptor.valueOf(Class.forName("java.util.Collections$EmptyList")));
@ -200,14 +200,14 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void listToCollectionNoCopyRequired() throws NoSuchFieldException {
void listToCollectionNoCopyRequired() throws NoSuchFieldException {
List<?> input = new ArrayList<>(Arrays.asList("foo", "bar"));
assertThat(conversionService.convert(input, TypeDescriptor.forObject(input),
new TypeDescriptor(getClass().getField("wildcardCollection")))).isSameAs(input);
}
@Test
public void differentImpls() throws Exception {
void differentImpls() throws Exception {
List<Resource> resources = new ArrayList<>();
resources.add(new ClassPathResource("test"));
resources.add(new FileSystemResource("test"));
@ -217,7 +217,7 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void mixedInNulls() throws Exception {
void mixedInNulls() throws Exception {
List<Resource> resources = new ArrayList<>();
resources.add(new ClassPathResource("test"));
resources.add(null);
@ -228,7 +228,7 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void allNulls() throws Exception {
void allNulls() throws Exception {
List<Resource> resources = new ArrayList<>();
resources.add(null);
resources.add(null);
@ -237,7 +237,7 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void elementTypesNotConvertible() throws Exception {
void elementTypesNotConvertible() throws Exception {
List<String> resources = new ArrayList<>();
resources.add(null);
resources.add(null);
@ -247,7 +247,7 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void nothingInCommon() throws Exception {
void nothingInCommon() throws Exception {
List<Object> resources = new ArrayList<>();
resources.add(new ClassPathResource("test"));
resources.add(3);
@ -257,7 +257,7 @@ public class CollectionToCollectionConverterTests {
}
@Test
public void testStringToEnumSet() throws Exception {
void stringToEnumSet() throws Exception {
conversionService.addConverterFactory(new StringToEnumConverterFactory());
List<String> list = new ArrayList<>();
list.add("A");

View File

@ -67,20 +67,20 @@ import static org.springframework.tests.TestGroup.PERFORMANCE;
* @author David Haraburda
* @author Sam Brannen
*/
public class GenericConversionServiceTests {
class GenericConversionServiceTests {
private final GenericConversionService conversionService = new GenericConversionService();
@Test
public void canConvert() {
void canConvert() {
assertThat(conversionService.canConvert(String.class, Integer.class)).isFalse();
conversionService.addConverterFactory(new StringToNumberConverterFactory());
assertThat(conversionService.canConvert(String.class, Integer.class)).isTrue();
}
@Test
public void canConvertAssignable() {
void canConvertAssignable() {
assertThat(conversionService.canConvert(String.class, String.class)).isTrue();
assertThat(conversionService.canConvert(Integer.class, Number.class)).isTrue();
assertThat(conversionService.canConvert(boolean.class, boolean.class)).isTrue();
@ -88,112 +88,112 @@ public class GenericConversionServiceTests {
}
@Test
public void canConvertFromClassSourceTypeToNullTargetType() {
void canConvertFromClassSourceTypeToNullTargetType() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.canConvert(String.class, null));
}
@Test
public void canConvertFromTypeDescriptorSourceTypeToNullTargetType() {
void canConvertFromTypeDescriptorSourceTypeToNullTargetType() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.canConvert(TypeDescriptor.valueOf(String.class), null));
}
@Test
public void canConvertNullSourceType() {
void canConvertNullSourceType() {
assertThat(conversionService.canConvert(null, Integer.class)).isTrue();
assertThat(conversionService.canConvert(null, TypeDescriptor.valueOf(Integer.class))).isTrue();
}
@Test
public void convert() {
void convert() {
conversionService.addConverterFactory(new StringToNumberConverterFactory());
assertThat(conversionService.convert("3", Integer.class)).isEqualTo((int) Integer.valueOf(3));
}
@Test
public void convertNullSource() {
void convertNullSource() {
assertThat(conversionService.convert(null, Integer.class)).isEqualTo(null);
}
@Test
public void convertNullSourcePrimitiveTarget() {
void convertNullSourcePrimitiveTarget() {
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
conversionService.convert(null, int.class));
}
@Test
public void convertNullSourcePrimitiveTargetTypeDescriptor() {
void convertNullSourcePrimitiveTargetTypeDescriptor() {
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
conversionService.convert(null, TypeDescriptor.valueOf(String.class), TypeDescriptor.valueOf(int.class)));
}
@Test
public void convertNotNullSourceNullSourceTypeDescriptor() {
void convertNotNullSourceNullSourceTypeDescriptor() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.convert("3", null, TypeDescriptor.valueOf(int.class)));
}
@Test
public void convertAssignableSource() {
void convertAssignableSource() {
assertThat(conversionService.convert(false, boolean.class)).isEqualTo(Boolean.FALSE);
assertThat(conversionService.convert(false, Boolean.class)).isEqualTo(Boolean.FALSE);
}
@Test
public void converterNotFound() {
void converterNotFound() {
assertThatExceptionOfType(ConverterNotFoundException.class).isThrownBy(() ->
conversionService.convert("3", Integer.class));
}
@Test
public void addConverterNoSourceTargetClassInfoAvailable() {
void addConverterNoSourceTargetClassInfoAvailable() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.addConverter(new UntypedConverter()));
}
@Test
public void sourceTypeIsVoid() {
void sourceTypeIsVoid() {
assertThat(conversionService.canConvert(void.class, String.class)).isFalse();
}
@Test
public void targetTypeIsVoid() {
void targetTypeIsVoid() {
assertThat(conversionService.canConvert(String.class, void.class)).isFalse();
}
@Test
public void convertNull() {
void convertNull() {
assertThat(conversionService.convert(null, Integer.class)).isNull();
}
@Test
public void convertToNullTargetClass() {
void convertToNullTargetClass() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.convert("3", (Class<?>) null));
}
@Test
public void convertToNullTargetTypeDescriptor() {
void convertToNullTargetTypeDescriptor() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.convert("3", TypeDescriptor.valueOf(String.class), null));
}
@Test
public void convertWrongSourceTypeDescriptor() {
void convertWrongSourceTypeDescriptor() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.convert("3", TypeDescriptor.valueOf(Integer.class), TypeDescriptor.valueOf(Long.class)));
}
@Test
public void convertWrongTypeArgument() {
void convertWrongTypeArgument() {
conversionService.addConverterFactory(new StringToNumberConverterFactory());
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
conversionService.convert("BOGUS", Integer.class));
}
@Test
public void convertSuperSourceType() {
void convertSuperSourceType() {
conversionService.addConverter(new Converter<CharSequence, Integer>() {
@Override
public Integer convert(CharSequence source) {
@ -206,14 +206,14 @@ public class GenericConversionServiceTests {
// SPR-8718
@Test
public void convertSuperTarget() {
void convertSuperTarget() {
conversionService.addConverter(new ColorConverter());
assertThatExceptionOfType(ConverterNotFoundException.class).isThrownBy(() ->
conversionService.convert("#000000", SystemColor.class));
}
@Test
public void convertObjectToPrimitive() {
void convertObjectToPrimitive() {
assertThat(conversionService.canConvert(String.class, boolean.class)).isFalse();
conversionService.addConverter(new StringToBooleanConverter());
assertThat(conversionService.canConvert(String.class, boolean.class)).isTrue();
@ -225,7 +225,7 @@ public class GenericConversionServiceTests {
}
@Test
public void convertObjectToPrimitiveViaConverterFactory() {
void convertObjectToPrimitiveViaConverterFactory() {
assertThat(conversionService.canConvert(String.class, int.class)).isFalse();
conversionService.addConverterFactory(new StringToNumberConverterFactory());
assertThat(conversionService.canConvert(String.class, int.class)).isTrue();
@ -234,7 +234,7 @@ public class GenericConversionServiceTests {
}
@Test
public void genericConverterDelegatingBackToConversionServiceConverterNotFound() {
void genericConverterDelegatingBackToConversionServiceConverterNotFound() {
conversionService.addConverter(new ObjectToArrayConverter(conversionService));
assertThat(conversionService.canConvert(String.class, Integer[].class)).isFalse();
assertThatExceptionOfType(ConverterNotFoundException.class).isThrownBy(() ->
@ -242,7 +242,7 @@ public class GenericConversionServiceTests {
}
@Test
public void testListToIterableConversion() {
void listToIterableConversion() {
List<Object> raw = new ArrayList<>();
raw.add("one");
raw.add("two");
@ -251,7 +251,7 @@ public class GenericConversionServiceTests {
}
@Test
public void testListToObjectConversion() {
void listToObjectConversion() {
List<Object> raw = new ArrayList<>();
raw.add("one");
raw.add("two");
@ -260,7 +260,7 @@ public class GenericConversionServiceTests {
}
@Test
public void testMapToObjectConversion() {
void mapToObjectConversion() {
Map<Object, Object> raw = new HashMap<>();
raw.put("key", "value");
Object converted = conversionService.convert(raw, Object.class);
@ -268,7 +268,7 @@ public class GenericConversionServiceTests {
}
@Test
public void testInterfaceToString() {
void interfaceToString() {
conversionService.addConverter(new MyBaseInterfaceToStringConverter());
conversionService.addConverter(new ObjectToStringConverter());
Object converted = conversionService.convert(new MyInterfaceImplementer(), String.class);
@ -276,7 +276,7 @@ public class GenericConversionServiceTests {
}
@Test
public void testInterfaceArrayToStringArray() {
void interfaceArrayToStringArray() {
conversionService.addConverter(new MyBaseInterfaceToStringConverter());
conversionService.addConverter(new ArrayToArrayConverter(conversionService));
String[] converted = conversionService.convert(new MyInterface[] {new MyInterfaceImplementer()}, String[].class);
@ -284,7 +284,7 @@ public class GenericConversionServiceTests {
}
@Test
public void testObjectArrayToStringArray() {
void objectArrayToStringArray() {
conversionService.addConverter(new MyBaseInterfaceToStringConverter());
conversionService.addConverter(new ArrayToArrayConverter(conversionService));
String[] converted = conversionService.convert(new MyInterfaceImplementer[] {new MyInterfaceImplementer()}, String[].class);
@ -292,7 +292,7 @@ public class GenericConversionServiceTests {
}
@Test
public void testStringArrayToResourceArray() {
void stringArrayToResourceArray() {
conversionService.addConverter(new MyStringArrayToResourceArrayConverter());
Resource[] converted = conversionService.convert(new String[] { "x1", "z3" }, Resource[].class);
List<String> descriptions = Arrays.stream(converted).map(Resource::getDescription).sorted(naturalOrder()).collect(toList());
@ -300,21 +300,21 @@ public class GenericConversionServiceTests {
}
@Test
public void testStringArrayToIntegerArray() {
void stringArrayToIntegerArray() {
conversionService.addConverter(new MyStringArrayToIntegerArrayConverter());
Integer[] converted = conversionService.convert(new String[] {"x1", "z3"}, Integer[].class);
assertThat(converted).isEqualTo(new Integer[] { 1, 3 });
}
@Test
public void testStringToIntegerArray() {
void stringToIntegerArray() {
conversionService.addConverter(new MyStringToIntegerArrayConverter());
Integer[] converted = conversionService.convert("x1,z3", Integer[].class);
assertThat(converted).isEqualTo(new Integer[] { 1, 3 });
}
@Test
public void testWildcardMap() throws Exception {
void wildcardMap() throws Exception {
Map<String, String> input = new LinkedHashMap<>();
input.put("key", "value");
Object converted = conversionService.convert(input, TypeDescriptor.forObject(input), new TypeDescriptor(getClass().getField("wildcardMap")));
@ -322,21 +322,21 @@ public class GenericConversionServiceTests {
}
@Test
public void testStringToString() {
void stringToString() {
String value = "myValue";
String result = conversionService.convert(value, String.class);
assertThat(result).isSameAs(value);
}
@Test
public void testStringToObject() {
void stringToObject() {
String value = "myValue";
Object result = conversionService.convert(value, Object.class);
assertThat(result).isSameAs(value);
}
@Test
public void testIgnoreCopyConstructor() {
void ignoreCopyConstructor() {
WithCopyConstructor value = new WithCopyConstructor();
Object result = conversionService.convert(value, WithCopyConstructor.class);
assertThat(result).isSameAs(value);
@ -344,7 +344,7 @@ public class GenericConversionServiceTests {
@Test
@EnabledForTestGroups(PERFORMANCE)
public void testPerformance2() throws Exception {
void testPerformance2() throws Exception {
StopWatch watch = new StopWatch("list<string> -> list<integer> conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
List<String> source = new LinkedList<>();
@ -369,7 +369,7 @@ public class GenericConversionServiceTests {
@Test
@EnabledForTestGroups(PERFORMANCE)
public void testPerformance3() throws Exception {
void testPerformance3() throws Exception {
StopWatch watch = new StopWatch("map<string, string> -> map<string, integer> conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
Map<String, String> source = new HashMap<>();
@ -391,7 +391,7 @@ public class GenericConversionServiceTests {
}
@Test
public void emptyListToArray() {
void emptyListToArray() {
conversionService.addConverter(new CollectionToArrayConverter(conversionService));
conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> list = new ArrayList<>();
@ -402,7 +402,7 @@ public class GenericConversionServiceTests {
}
@Test
public void emptyListToObject() {
void emptyListToObject() {
conversionService.addConverter(new CollectionToObjectConverter(conversionService));
conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> list = new ArrayList<>();
@ -413,7 +413,7 @@ public class GenericConversionServiceTests {
}
@Test
public void stringToArrayCanConvert() {
void stringToArrayCanConvert() {
conversionService.addConverter(new StringToArrayConverter(conversionService));
assertThat(conversionService.canConvert(String.class, Integer[].class)).isFalse();
conversionService.addConverterFactory(new StringToNumberConverterFactory());
@ -421,7 +421,7 @@ public class GenericConversionServiceTests {
}
@Test
public void stringToCollectionCanConvert() throws Exception {
void stringToCollectionCanConvert() throws Exception {
conversionService.addConverter(new StringToCollectionConverter(conversionService));
assertThat(conversionService.canConvert(String.class, Collection.class)).isTrue();
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("integerCollection"));
@ -431,14 +431,14 @@ public class GenericConversionServiceTests {
}
@Test
public void testConvertiblePairsInSet() {
void convertiblePairsInSet() {
Set<GenericConverter.ConvertiblePair> set = new HashSet<>();
set.add(new GenericConverter.ConvertiblePair(Number.class, String.class));
assert set.contains(new GenericConverter.ConvertiblePair(Number.class, String.class));
}
@Test
public void testConvertiblePairEqualsAndHash() {
void convertiblePairEqualsAndHash() {
GenericConverter.ConvertiblePair pair = new GenericConverter.ConvertiblePair(Number.class, String.class);
GenericConverter.ConvertiblePair pairEqual = new GenericConverter.ConvertiblePair(Number.class, String.class);
assertThat(pairEqual).isEqualTo(pair);
@ -446,7 +446,7 @@ public class GenericConversionServiceTests {
}
@Test
public void testConvertiblePairDifferentEqualsAndHash() {
void convertiblePairDifferentEqualsAndHash() {
GenericConverter.ConvertiblePair pair = new GenericConverter.ConvertiblePair(Number.class, String.class);
GenericConverter.ConvertiblePair pairOpposite = new GenericConverter.ConvertiblePair(String.class, Number.class);
assertThat(pair.equals(pairOpposite)).isFalse();
@ -454,19 +454,19 @@ public class GenericConversionServiceTests {
}
@Test
public void canConvertIllegalArgumentNullTargetTypeFromClass() {
void canConvertIllegalArgumentNullTargetTypeFromClass() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.canConvert(String.class, null));
}
@Test
public void canConvertIllegalArgumentNullTargetTypeFromTypeDescriptor() {
void canConvertIllegalArgumentNullTargetTypeFromTypeDescriptor() {
assertThatIllegalArgumentException().isThrownBy(() ->
conversionService.canConvert(TypeDescriptor.valueOf(String.class), null));
}
@Test
public void removeConvertible() {
void removeConvertible() {
conversionService.addConverter(new ColorConverter());
assertThat(conversionService.canConvert(String.class, Color.class)).isTrue();
conversionService.removeConvertible(String.class, Color.class);
@ -474,7 +474,7 @@ public class GenericConversionServiceTests {
}
@Test
public void conditionalConverter() {
void conditionalConverter() {
MyConditionalConverter converter = new MyConditionalConverter();
conversionService.addConverter(new ColorConverter());
conversionService.addConverter(converter);
@ -483,7 +483,7 @@ public class GenericConversionServiceTests {
}
@Test
public void conditionalConverterFactory() {
void conditionalConverterFactory() {
MyConditionalConverterFactory converter = new MyConditionalConverterFactory();
conversionService.addConverter(new ColorConverter());
conversionService.addConverterFactory(converter);
@ -493,7 +493,7 @@ public class GenericConversionServiceTests {
}
@Test
public void conditionalConverterCachingForDifferentAnnotationAttributes() throws Exception {
void conditionalConverterCachingForDifferentAnnotationAttributes() throws Exception {
conversionService.addConverter(new ColorConverter());
conversionService.addConverter(new MyConditionalColorConverter());
@ -508,7 +508,7 @@ public class GenericConversionServiceTests {
}
@Test
public void shouldNotSupportNullConvertibleTypesFromNonConditionalGenericConverter() {
void shouldNotSupportNullConvertibleTypesFromNonConditionalGenericConverter() {
GenericConverter converter = new NonConditionalGenericConverter();
assertThatIllegalStateException().isThrownBy(() ->
conversionService.addConverter(converter))
@ -516,7 +516,7 @@ public class GenericConversionServiceTests {
}
@Test
public void conditionalConversionForAllTypes() {
void conditionalConversionForAllTypes() {
MyConditionalGenericConverter converter = new MyConditionalGenericConverter();
conversionService.addConverter(converter);
assertThat(conversionService.convert(3, Integer.class)).isEqualTo(3);
@ -525,7 +525,7 @@ public class GenericConversionServiceTests {
}
@Test
public void convertOptimizeArray() {
void convertOptimizeArray() {
// SPR-9566
byte[] byteArray = new byte[] { 1, 2, 3 };
byte[] converted = conversionService.convert(byteArray, byte[].class);
@ -533,19 +533,19 @@ public class GenericConversionServiceTests {
}
@Test
public void testEnumToStringConversion() {
void enumToStringConversion() {
conversionService.addConverter(new EnumToStringConverter(conversionService));
assertThat(conversionService.convert(MyEnum.A, String.class)).isEqualTo("A");
}
@Test
public void testSubclassOfEnumToString() throws Exception {
void subclassOfEnumToString() throws Exception {
conversionService.addConverter(new EnumToStringConverter(conversionService));
assertThat(conversionService.convert(EnumWithSubclass.FIRST, String.class)).isEqualTo("FIRST");
}
@Test
public void testEnumWithInterfaceToStringConversion() {
void enumWithInterfaceToStringConversion() {
// SPR-9692
conversionService.addConverter(new EnumToStringConverter(conversionService));
conversionService.addConverter(new MyEnumInterfaceToStringConverter<MyEnum>());
@ -553,21 +553,21 @@ public class GenericConversionServiceTests {
}
@Test
public void testStringToEnumWithInterfaceConversion() {
void stringToEnumWithInterfaceConversion() {
conversionService.addConverterFactory(new StringToEnumConverterFactory());
conversionService.addConverterFactory(new StringToMyEnumInterfaceConverterFactory());
assertThat(conversionService.convert("1", MyEnum.class)).isEqualTo(MyEnum.A);
}
@Test
public void testStringToEnumWithBaseInterfaceConversion() {
void stringToEnumWithBaseInterfaceConversion() {
conversionService.addConverterFactory(new StringToEnumConverterFactory());
conversionService.addConverterFactory(new StringToMyEnumBaseInterfaceConverterFactory());
assertThat(conversionService.convert("base1", MyEnum.class)).isEqualTo(MyEnum.A);
}
@Test
public void convertNullAnnotatedStringToString() throws Exception {
void convertNullAnnotatedStringToString() throws Exception {
String source = null;
TypeDescriptor sourceType = new TypeDescriptor(getClass().getField("annotatedString"));
TypeDescriptor targetType = TypeDescriptor.valueOf(String.class);
@ -575,7 +575,7 @@ public class GenericConversionServiceTests {
}
@Test
public void multipleCollectionTypesFromSameSourceType() throws Exception {
void multipleCollectionTypesFromSameSourceType() throws Exception {
conversionService.addConverter(new MyStringToRawCollectionConverter());
conversionService.addConverter(new MyStringToGenericCollectionConverter());
conversionService.addConverter(new MyStringToStringCollectionConverter());
@ -590,7 +590,7 @@ public class GenericConversionServiceTests {
}
@Test
public void adaptedCollectionTypesFromSameSourceType() throws Exception {
void adaptedCollectionTypesFromSameSourceType() throws Exception {
conversionService.addConverter(new MyStringToStringCollectionConverter());
assertThat(conversionService.convert("test", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("stringCollection")))).isEqualTo(Collections.singleton("testX"));
@ -605,7 +605,7 @@ public class GenericConversionServiceTests {
}
@Test
public void genericCollectionAsSource() throws Exception {
void genericCollectionAsSource() throws Exception {
conversionService.addConverter(new MyStringToGenericCollectionConverter());
assertThat(conversionService.convert("test", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("stringCollection")))).isEqualTo(Collections.singleton("testX"));
@ -617,7 +617,7 @@ public class GenericConversionServiceTests {
}
@Test
public void rawCollectionAsSource() throws Exception {
void rawCollectionAsSource() throws Exception {
conversionService.addConverter(new MyStringToRawCollectionConverter());
assertThat(conversionService.convert("test", TypeDescriptor.valueOf(String.class), new TypeDescriptor(getClass().getField("stringCollection")))).isEqualTo(Collections.singleton("testX"));

View File

@ -41,19 +41,19 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Phil Webb
* @author Juergen Hoeller
*/
public class MapToMapConverterTests {
class MapToMapConverterTests {
private final GenericConversionService conversionService = new GenericConversionService();
@BeforeEach
public void setUp() {
void setUp() {
conversionService.addConverter(new MapToMapConverter(conversionService));
}
@Test
public void scalarMap() throws Exception {
void scalarMap() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("1", "9");
map.put("2", "37");
@ -78,7 +78,7 @@ public class MapToMapConverterTests {
}
@Test
public void scalarMapNotGenericTarget() throws Exception {
void scalarMapNotGenericTarget() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("1", "9");
map.put("2", "37");
@ -88,7 +88,7 @@ public class MapToMapConverterTests {
}
@Test
public void scalarMapNotGenericSourceField() throws Exception {
void scalarMapNotGenericSourceField() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("1", "9");
map.put("2", "37");
@ -113,7 +113,7 @@ public class MapToMapConverterTests {
}
@Test
public void collectionMap() throws Exception {
void collectionMap() throws Exception {
Map<String, List<String>> map = new HashMap<>();
map.put("1", Arrays.asList("9", "12"));
map.put("2", Arrays.asList("37", "23"));
@ -139,7 +139,7 @@ public class MapToMapConverterTests {
}
@Test
public void collectionMapSourceTarget() throws Exception {
void collectionMapSourceTarget() throws Exception {
Map<String, List<String>> map = new HashMap<>();
map.put("1", Arrays.asList("9", "12"));
map.put("2", Arrays.asList("37", "23"));
@ -161,7 +161,7 @@ public class MapToMapConverterTests {
}
@Test
public void collectionMapNotGenericTarget() throws Exception {
void collectionMapNotGenericTarget() throws Exception {
Map<String, List<String>> map = new HashMap<>();
map.put("1", Arrays.asList("9", "12"));
map.put("2", Arrays.asList("37", "23"));
@ -171,7 +171,7 @@ public class MapToMapConverterTests {
}
@Test
public void collectionMapNotGenericTargetCollectionToObjectInteraction() throws Exception {
void collectionMapNotGenericTargetCollectionToObjectInteraction() throws Exception {
Map<String, List<String>> map = new HashMap<>();
map.put("1", Arrays.asList("9", "12"));
map.put("2", Arrays.asList("37", "23"));
@ -183,7 +183,7 @@ public class MapToMapConverterTests {
}
@Test
public void emptyMap() throws Exception {
void emptyMap() throws Exception {
Map<String, String> map = new HashMap<>();
TypeDescriptor sourceType = TypeDescriptor.forObject(map);
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapTarget"));
@ -193,7 +193,7 @@ public class MapToMapConverterTests {
}
@Test
public void emptyMapNoTargetGenericInfo() throws Exception {
void emptyMapNoTargetGenericInfo() throws Exception {
Map<String, String> map = new HashMap<>();
assertThat(conversionService.canConvert(Map.class, Map.class)).isTrue();
@ -201,7 +201,7 @@ public class MapToMapConverterTests {
}
@Test
public void emptyMapDifferentTargetImplType() throws Exception {
void emptyMapDifferentTargetImplType() throws Exception {
Map<String, String> map = new HashMap<>();
TypeDescriptor sourceType = TypeDescriptor.forObject(map);
TypeDescriptor targetType = new TypeDescriptor(getClass().getField("emptyMapDifferentTarget"));
@ -214,7 +214,7 @@ public class MapToMapConverterTests {
}
@Test
public void noDefaultConstructorCopyNotRequired() throws Exception {
void noDefaultConstructorCopyNotRequired() throws Exception {
// SPR-9284
NoDefaultConstructorMap<String, Integer> map = new NoDefaultConstructorMap<>(
Collections.<String, Integer>singletonMap("1", 1));
@ -232,7 +232,7 @@ public class MapToMapConverterTests {
@Test
@SuppressWarnings("unchecked")
public void multiValueMapToMultiValueMap() throws Exception {
void multiValueMapToMultiValueMap() throws Exception {
DefaultConversionService.addDefaultConverters(conversionService);
MultiValueMap<String, Integer> source = new LinkedMultiValueMap<>();
source.put("a", Arrays.asList(1, 2, 3));
@ -247,7 +247,7 @@ public class MapToMapConverterTests {
@Test
@SuppressWarnings("unchecked")
public void mapToMultiValueMap() throws Exception {
void mapToMultiValueMap() throws Exception {
DefaultConversionService.addDefaultConverters(conversionService);
Map<String, Integer> source = new HashMap<>();
source.put("a", 1);
@ -261,7 +261,7 @@ public class MapToMapConverterTests {
}
@Test
public void testStringToEnumMap() throws Exception {
void stringToEnumMap() throws Exception {
conversionService.addConverterFactory(new StringToEnumConverterFactory());
Map<String, Integer> source = new HashMap<>();
source.put("A", 1);

View File

@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Stephane Nicoll
* @since 4.2
*/
public class StreamConverterTests {
class StreamConverterTests {
private final GenericConversionService conversionService = new GenericConversionService();
@ -46,7 +46,7 @@ public class StreamConverterTests {
@BeforeEach
public void setup() {
void setup() {
this.conversionService.addConverter(new CollectionToCollectionConverter(this.conversionService));
this.conversionService.addConverter(new ArrayToCollectionConverter(this.conversionService));
this.conversionService.addConverter(new CollectionToArrayConverter(this.conversionService));
@ -55,7 +55,7 @@ public class StreamConverterTests {
@Test
public void convertFromStreamToList() throws NoSuchFieldException {
void convertFromStreamToList() throws NoSuchFieldException {
this.conversionService.addConverter(Number.class, String.class, new ObjectToStringConverter());
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("listOfStrings"));
@ -73,7 +73,7 @@ public class StreamConverterTests {
}
@Test
public void convertFromStreamToArray() throws NoSuchFieldException {
void convertFromStreamToArray() throws NoSuchFieldException {
this.conversionService.addConverterFactory(new NumberToNumberConverterFactory());
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
@ -89,7 +89,7 @@ public class StreamConverterTests {
}
@Test
public void convertFromStreamToRawList() throws NoSuchFieldException {
void convertFromStreamToRawList() throws NoSuchFieldException {
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
TypeDescriptor listOfStrings = new TypeDescriptor(Types.class.getField("rawList"));
Object result = this.conversionService.convert(stream, listOfStrings);
@ -106,7 +106,7 @@ public class StreamConverterTests {
}
@Test
public void convertFromStreamToArrayNoConverter() throws NoSuchFieldException {
void convertFromStreamToArrayNoConverter() throws NoSuchFieldException {
Stream<Integer> stream = Arrays.asList(1, 2, 3).stream();
TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
@ -116,7 +116,7 @@ public class StreamConverterTests {
@Test
@SuppressWarnings("resource")
public void convertFromListToStream() throws NoSuchFieldException {
void convertFromListToStream() throws NoSuchFieldException {
this.conversionService.addConverterFactory(new StringToNumberConverterFactory());
List<String> stream = Arrays.asList("1", "2", "3");
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("streamOfIntegers"));
@ -132,7 +132,7 @@ public class StreamConverterTests {
@Test
@SuppressWarnings("resource")
public void convertFromArrayToStream() throws NoSuchFieldException {
void convertFromArrayToStream() throws NoSuchFieldException {
Integer[] stream = new Integer[] {1, 0, 1};
this.conversionService.addConverter(new Converter<Integer, Boolean>() {
@Override
@ -153,7 +153,7 @@ public class StreamConverterTests {
@Test
@SuppressWarnings("resource")
public void convertFromListToRawStream() throws NoSuchFieldException {
void convertFromListToRawStream() throws NoSuchFieldException {
List<String> stream = Arrays.asList("1", "2", "3");
TypeDescriptor streamOfInteger = new TypeDescriptor(Types.class.getField("rawStream"));
Object result = this.conversionService.convert(stream, streamOfInteger);
@ -169,14 +169,14 @@ public class StreamConverterTests {
}
@Test
public void doesNotMatchIfNoStream() throws NoSuchFieldException {
void doesNotMatchIfNoStream() throws NoSuchFieldException {
assertThat(this.streamConverter.matches(
new TypeDescriptor(Types.class.getField("listOfStrings")),
new TypeDescriptor(Types.class.getField("arrayOfLongs")))).as("Should not match non stream type").isFalse();
}
@Test
public void shouldFailToConvertIfNoStream() throws NoSuchFieldException {
void shouldFailToConvertIfNoStream() throws NoSuchFieldException {
TypeDescriptor sourceType = new TypeDescriptor(Types.class.getField("listOfStrings"));
TypeDescriptor targetType = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
assertThatIllegalStateException().isThrownBy(() ->

View File

@ -27,10 +27,10 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Phillip Webb
*/
public class CompositePropertySourceTests {
class CompositePropertySourceTests {
@Test
public void addFirst() {
void addFirst() {
PropertySource<?> p1 = new MapPropertySource("p1", Collections.emptyMap());
PropertySource<?> p2 = new MapPropertySource("p2", Collections.emptyMap());
PropertySource<?> p3 = new MapPropertySource("p3", Collections.emptyMap());

View File

@ -24,25 +24,24 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests covering the extensibility of {@link AbstractEnvironment}.
*
* @author Chris Beams
* @since 3.1
*/
public class CustomEnvironmentTests {
class CustomEnvironmentTests {
// -- tests relating to customizing reserved default profiles ----------------------
@Test
public void control() {
void control() {
Environment env = new AbstractEnvironment() { };
assertThat(env.acceptsProfiles(defaultProfile())).isTrue();
}
@Test
public void withNoReservedDefaultProfile() {
void withNoReservedDefaultProfile() {
class CustomEnvironment extends AbstractEnvironment {
@Override
protected Set<String> getReservedDefaultProfiles() {
@ -55,7 +54,7 @@ public class CustomEnvironmentTests {
}
@Test
public void withSingleCustomReservedDefaultProfile() {
void withSingleCustomReservedDefaultProfile() {
class CustomEnvironment extends AbstractEnvironment {
@Override
protected Set<String> getReservedDefaultProfiles() {
@ -69,7 +68,7 @@ public class CustomEnvironmentTests {
}
@Test
public void withMultiCustomReservedDefaultProfile() {
void withMultiCustomReservedDefaultProfile() {
class CustomEnvironment extends AbstractEnvironment {
@Override
@SuppressWarnings("serial")

View File

@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Chris Beams
* @since 3.1
*/
public class JOptCommandLinePropertySourceTests {
class JOptCommandLinePropertySourceTests {
@Test
public void withRequiredArg_andArgIsPresent() {
void withRequiredArg_andArgIsPresent() {
OptionParser parser = new OptionParser();
parser.accepts("foo").withRequiredArg();
OptionSet options = parser.parse("--foo=bar");
@ -43,7 +43,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withOptionalArg_andArgIsMissing() {
void withOptionalArg_andArgIsMissing() {
OptionParser parser = new OptionParser();
parser.accepts("foo").withOptionalArg();
OptionSet options = parser.parse("--foo");
@ -54,7 +54,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withNoArg() {
void withNoArg() {
OptionParser parser = new OptionParser();
parser.accepts("o1");
parser.accepts("o2");
@ -68,7 +68,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withRequiredArg_andMultipleArgsPresent_usingDelimiter() {
void withRequiredArg_andMultipleArgsPresent_usingDelimiter() {
OptionParser parser = new OptionParser();
parser.accepts("foo").withRequiredArg().withValuesSeparatedBy(',');
OptionSet options = parser.parse("--foo=bar,baz,biz");
@ -79,7 +79,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withRequiredArg_andMultipleArgsPresent_usingRepeatedOption() {
void withRequiredArg_andMultipleArgsPresent_usingRepeatedOption() {
OptionParser parser = new OptionParser();
parser.accepts("foo").withRequiredArg().withValuesSeparatedBy(',');
OptionSet options = parser.parse("--foo=bar", "--foo=baz", "--foo=biz");
@ -90,7 +90,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withMissingOption() {
void withMissingOption() {
OptionParser parser = new OptionParser();
parser.accepts("foo").withRequiredArg().withValuesSeparatedBy(',');
OptionSet options = parser.parse(); // <-- no options whatsoever
@ -100,7 +100,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withDottedOptionName() {
void withDottedOptionName() {
OptionParser parser = new OptionParser();
parser.accepts("spring.profiles.active").withRequiredArg();
OptionSet options = parser.parse("--spring.profiles.active=p1");
@ -110,7 +110,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() {
void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() {
OptionParser parser = new OptionParser();
parser.acceptsAll(Arrays.asList("o1","option1")).withRequiredArg();
parser.accepts("o2");
@ -127,7 +127,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() {
void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() {
OptionParser parser = new OptionParser();
parser.accepts("o1").withRequiredArg();
parser.accepts("o2");
@ -143,7 +143,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() {
void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() {
OptionParser parser = new OptionParser();
parser.accepts("o1").withRequiredArg();
parser.accepts("o2");
@ -160,7 +160,7 @@ public class JOptCommandLinePropertySourceTests {
}
@Test
public void withRequiredArg_ofTypeEnum() {
void withRequiredArg_ofTypeEnum() {
OptionParser parser = new OptionParser();
parser.accepts("o1").withRequiredArg().ofType(OptionEnum.class);
OptionSet options = parser.parse("--o1=VAL_1");

View File

@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Chris Beams
* @author Juergen Hoeller
*/
public class MutablePropertySourcesTests {
class MutablePropertySourcesTests {
@Test
public void test() {
void test() {
MutablePropertySources sources = new MutablePropertySources();
sources.addLast(new MockPropertySource("b").withProperty("p1", "bValue"));
sources.addLast(new MockPropertySource("d").withProperty("p1", "dValue"));
@ -135,13 +135,13 @@ public class MutablePropertySourcesTests {
}
@Test
public void getNonExistentPropertySourceReturnsNull() {
void getNonExistentPropertySourceReturnsNull() {
MutablePropertySources sources = new MutablePropertySources();
assertThat(sources.get("bogus")).isNull();
}
@Test
public void iteratorContainsPropertySource() {
void iteratorContainsPropertySource() {
MutablePropertySources sources = new MutablePropertySources();
sources.addLast(new MockPropertySource("test"));
@ -155,14 +155,14 @@ public class MutablePropertySourcesTests {
}
@Test
public void iteratorIsEmptyForEmptySources() {
void iteratorIsEmptyForEmptySources() {
MutablePropertySources sources = new MutablePropertySources();
Iterator<PropertySource<?>> it = sources.iterator();
assertThat(it.hasNext()).isFalse();
}
@Test
public void streamContainsPropertySource() {
void streamContainsPropertySource() {
MutablePropertySources sources = new MutablePropertySources();
sources.addLast(new MockPropertySource("test"));
@ -173,7 +173,7 @@ public class MutablePropertySourcesTests {
}
@Test
public void streamIsEmptyForEmptySources() {
void streamIsEmptyForEmptySources() {
MutablePropertySources sources = new MutablePropertySources();
assertThat(sources.stream()).isNotNull();
assertThat(sources.stream().count()).isEqualTo(0L);

View File

@ -36,52 +36,52 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Sam Brannen
* @since 5.1
*/
public class ProfilesTests {
class ProfilesTests {
@Test
public void ofWhenNullThrowsException() {
void ofWhenNullThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
Profiles.of((String[]) null))
.withMessageContaining("Must specify at least one profile");
}
@Test
public void ofWhenEmptyThrowsException() {
void ofWhenEmptyThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
Profiles.of())
.withMessageContaining("Must specify at least one profile");
}
@Test
public void ofNullElement() {
void ofNullElement() {
assertThatIllegalArgumentException().isThrownBy(() ->
Profiles.of((String) null))
.withMessageContaining("must contain text");
}
@Test
public void ofEmptyElement() {
void ofEmptyElement() {
assertThatIllegalArgumentException().isThrownBy(() ->
Profiles.of(" "))
.withMessageContaining("must contain text");
}
@Test
public void ofSingleElement() {
void ofSingleElement() {
Profiles profiles = Profiles.of("spring");
assertThat(profiles.matches(activeProfiles("spring"))).isTrue();
assertThat(profiles.matches(activeProfiles("framework"))).isFalse();
}
@Test
public void ofSingleInvertedElement() {
void ofSingleInvertedElement() {
Profiles profiles = Profiles.of("!spring");
assertThat(profiles.matches(activeProfiles("spring"))).isFalse();
assertThat(profiles.matches(activeProfiles("framework"))).isTrue();
}
@Test
public void ofMultipleElements() {
void ofMultipleElements() {
Profiles profiles = Profiles.of("spring", "framework");
assertThat(profiles.matches(activeProfiles("spring"))).isTrue();
assertThat(profiles.matches(activeProfiles("framework"))).isTrue();
@ -89,7 +89,7 @@ public class ProfilesTests {
}
@Test
public void ofMultipleElementsWithInverted() {
void ofMultipleElementsWithInverted() {
Profiles profiles = Profiles.of("!spring", "framework");
assertThat(profiles.matches(activeProfiles("spring"))).isFalse();
assertThat(profiles.matches(activeProfiles("spring", "framework"))).isTrue();
@ -98,7 +98,7 @@ public class ProfilesTests {
}
@Test
public void ofMultipleElementsAllInverted() {
void ofMultipleElementsAllInverted() {
Profiles profiles = Profiles.of("!spring", "!framework");
assertThat(profiles.matches(activeProfiles("spring"))).isTrue();
assertThat(profiles.matches(activeProfiles("framework"))).isTrue();
@ -108,34 +108,34 @@ public class ProfilesTests {
}
@Test
public void ofSingleExpression() {
void ofSingleExpression() {
Profiles profiles = Profiles.of("(spring)");
assertThat(profiles.matches(activeProfiles("spring"))).isTrue();
assertThat(profiles.matches(activeProfiles("framework"))).isFalse();
}
@Test
public void ofSingleExpressionInverted() {
void ofSingleExpressionInverted() {
Profiles profiles = Profiles.of("!(spring)");
assertThat(profiles.matches(activeProfiles("spring"))).isFalse();
assertThat(profiles.matches(activeProfiles("framework"))).isTrue();
}
@Test
public void ofSingleInvertedExpression() {
void ofSingleInvertedExpression() {
Profiles profiles = Profiles.of("(!spring)");
assertThat(profiles.matches(activeProfiles("spring"))).isFalse();
assertThat(profiles.matches(activeProfiles("framework"))).isTrue();
}
@Test
public void ofOrExpression() {
void ofOrExpression() {
Profiles profiles = Profiles.of("(spring | framework)");
assertOrExpression(profiles);
}
@Test
public void ofOrExpressionWithoutSpaces() {
void ofOrExpressionWithoutSpaces() {
Profiles profiles = Profiles.of("(spring|framework)");
assertOrExpression(profiles);
}
@ -148,19 +148,19 @@ public class ProfilesTests {
}
@Test
public void ofAndExpression() {
void ofAndExpression() {
Profiles profiles = Profiles.of("(spring & framework)");
assertAndExpression(profiles);
}
@Test
public void ofAndExpressionWithoutSpaces() {
void ofAndExpressionWithoutSpaces() {
Profiles profiles = Profiles.of("spring&framework)");
assertAndExpression(profiles);
}
@Test
public void ofAndExpressionWithoutParentheses() {
void ofAndExpressionWithoutParentheses() {
Profiles profiles = Profiles.of("spring & framework");
assertAndExpression(profiles);
}
@ -173,13 +173,13 @@ public class ProfilesTests {
}
@Test
public void ofNotAndExpression() {
void ofNotAndExpression() {
Profiles profiles = Profiles.of("!(spring & framework)");
assertOfNotAndExpression(profiles);
}
@Test
public void ofNotAndExpressionWithoutSpaces() {
void ofNotAndExpressionWithoutSpaces() {
Profiles profiles = Profiles.of("!(spring&framework)");
assertOfNotAndExpression(profiles);
}
@ -192,31 +192,31 @@ public class ProfilesTests {
}
@Test
public void ofAndExpressionWithInvertedSingleElement() {
void ofAndExpressionWithInvertedSingleElement() {
Profiles profiles = Profiles.of("!spring & framework");
assertOfAndExpressionWithInvertedSingleElement(profiles);
}
@Test
public void ofAndExpressionWithInBracketsInvertedSingleElement() {
void ofAndExpressionWithInBracketsInvertedSingleElement() {
Profiles profiles = Profiles.of("(!spring) & framework");
assertOfAndExpressionWithInvertedSingleElement(profiles);
}
@Test
public void ofAndExpressionWithInvertedSingleElementInBrackets() {
void ofAndExpressionWithInvertedSingleElementInBrackets() {
Profiles profiles = Profiles.of("! (spring) & framework");
assertOfAndExpressionWithInvertedSingleElement(profiles);
}
@Test
public void ofAndExpressionWithInvertedSingleElementInBracketsWithoutSpaces() {
void ofAndExpressionWithInvertedSingleElementInBracketsWithoutSpaces() {
Profiles profiles = Profiles.of("!(spring)&framework");
assertOfAndExpressionWithInvertedSingleElement(profiles);
}
@Test
public void ofAndExpressionWithInvertedSingleElementWithoutSpaces() {
void ofAndExpressionWithInvertedSingleElementWithoutSpaces() {
Profiles profiles = Profiles.of("!spring&framework");
assertOfAndExpressionWithInvertedSingleElement(profiles);
}
@ -229,7 +229,7 @@ public class ProfilesTests {
}
@Test
public void ofOrExpressionWithInvertedSingleElementWithoutSpaces() {
void ofOrExpressionWithInvertedSingleElementWithoutSpaces() {
Profiles profiles = Profiles.of("!spring|framework");
assertOfOrExpressionWithInvertedSingleElement(profiles);
}
@ -242,13 +242,13 @@ public class ProfilesTests {
}
@Test
public void ofNotOrExpression() {
void ofNotOrExpression() {
Profiles profiles = Profiles.of("!(spring | framework)");
assertOfNotOrExpression(profiles);
}
@Test
public void ofNotOrExpressionWithoutSpaces() {
void ofNotOrExpressionWithoutSpaces() {
Profiles profiles = Profiles.of("!(spring|framework)");
assertOfNotOrExpression(profiles);
}
@ -261,13 +261,13 @@ public class ProfilesTests {
}
@Test
public void ofComplexExpression() {
void ofComplexExpression() {
Profiles profiles = Profiles.of("(spring & framework) | (spring & java)");
assertComplexExpression(profiles);
}
@Test
public void ofComplexExpressionWithoutSpaces() {
void ofComplexExpressionWithoutSpaces() {
Profiles profiles = Profiles.of("(spring&framework)|(spring&java)");
assertComplexExpression(profiles);
}
@ -280,14 +280,14 @@ public class ProfilesTests {
}
@Test
public void malformedExpressions() {
void malformedExpressions() {
assertMalformed(() -> Profiles.of("("));
assertMalformed(() -> Profiles.of(")"));
assertMalformed(() -> Profiles.of("a & b | c"));
}
@Test
public void sensibleToString() {
void sensibleToString() {
assertThat(Profiles.of("spring & framework", "java | kotlin").toString()).isEqualTo("spring & framework or java | kotlin");
}

View File

@ -26,18 +26,17 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link PropertySource} implementations.
*
* @author Chris Beams
* @since 3.1
*/
public class PropertySourceTests {
class PropertySourceTests {
@Test
@SuppressWarnings("serial")
public void equals() {
void equals() {
Map<String, Object> map1 = new HashMap<String, Object>() {{
put("a", "b");
}};
@ -69,7 +68,7 @@ public class PropertySourceTests {
@Test
@SuppressWarnings("serial")
public void collectionsOperations() {
void collectionsOperations() {
Map<String, Object> map1 = new HashMap<String, Object>() {{
put("a", "b");
}};

View File

@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Chris Beams
* @since 3.1
*/
public class PropertySourcesPropertyResolverTests {
class PropertySourcesPropertyResolverTests {
private Properties testProperties;
@ -45,7 +45,7 @@ public class PropertySourcesPropertyResolverTests {
@BeforeEach
public void setUp() {
void setUp() {
propertySources = new MutablePropertySources();
propertyResolver = new PropertySourcesPropertyResolver(propertySources);
testProperties = new Properties();
@ -54,28 +54,28 @@ public class PropertySourcesPropertyResolverTests {
@Test
public void containsProperty() {
void containsProperty() {
assertThat(propertyResolver.containsProperty("foo")).isFalse();
testProperties.put("foo", "bar");
assertThat(propertyResolver.containsProperty("foo")).isTrue();
}
@Test
public void getProperty() {
void getProperty() {
assertThat(propertyResolver.getProperty("foo")).isNull();
testProperties.put("foo", "bar");
assertThat(propertyResolver.getProperty("foo")).isEqualTo("bar");
}
@Test
public void getProperty_withDefaultValue() {
void getProperty_withDefaultValue() {
assertThat(propertyResolver.getProperty("foo", "myDefault")).isEqualTo("myDefault");
testProperties.put("foo", "bar");
assertThat(propertyResolver.getProperty("foo")).isEqualTo("bar");
}
@Test
public void getProperty_propertySourceSearchOrderIsFIFO() {
void getProperty_propertySourceSearchOrderIsFIFO() {
MutablePropertySources sources = new MutablePropertySources();
PropertyResolver resolver = new PropertySourcesPropertyResolver(sources);
sources.addFirst(new MockPropertySource("ps1").withProperty("pName", "ps1Value"));
@ -87,7 +87,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void getProperty_withExplicitNullValue() {
void getProperty_withExplicitNullValue() {
// java.util.Properties does not allow null values (because Hashtable does not)
Map<String, Object> nullableProperties = new HashMap<>();
propertySources.addLast(new MapPropertySource("nullableProperties", nullableProperties));
@ -96,20 +96,20 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void getProperty_withTargetType_andDefaultValue() {
void getProperty_withTargetType_andDefaultValue() {
assertThat(propertyResolver.getProperty("foo", Integer.class, 42)).isEqualTo(42);
testProperties.put("foo", 13);
assertThat(propertyResolver.getProperty("foo", Integer.class, 42)).isEqualTo(13);
}
@Test
public void getProperty_withStringArrayConversion() {
void getProperty_withStringArrayConversion() {
testProperties.put("foo", "bar,baz");
assertThat(propertyResolver.getProperty("foo", String[].class)).isEqualTo(new String[] { "bar", "baz" });
}
@Test
public void getProperty_withNonConvertibleTargetType() {
void getProperty_withNonConvertibleTargetType() {
testProperties.put("foo", "bar");
class TestType { }
@ -119,7 +119,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void getProperty_doesNotCache_replaceExistingKeyPostConstruction() {
void getProperty_doesNotCache_replaceExistingKeyPostConstruction() {
String key = "foo";
String value1 = "bar";
String value2 = "biz";
@ -135,7 +135,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void getProperty_doesNotCache_addNewKeyPostConstruction() {
void getProperty_doesNotCache_addNewKeyPostConstruction() {
HashMap<String, Object> map = new HashMap<>();
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MapPropertySource("testProperties", map));
@ -146,7 +146,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void getPropertySources_replacePropertySource() {
void getPropertySources_replacePropertySource() {
propertySources = new MutablePropertySources();
propertyResolver = new PropertySourcesPropertyResolver(propertySources);
propertySources.addLast(new MockPropertySource("local").withProperty("foo", "localValue"));
@ -165,7 +165,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void getRequiredProperty() {
void getRequiredProperty() {
testProperties.put("exists", "xyz");
assertThat(propertyResolver.getRequiredProperty("exists")).isEqualTo("xyz");
@ -174,7 +174,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void getRequiredProperty_withStringArrayConversion() {
void getRequiredProperty_withStringArrayConversion() {
testProperties.put("exists", "abc,123");
assertThat(propertyResolver.getRequiredProperty("exists", String[].class)).isEqualTo(new String[] { "abc", "123" });
@ -183,7 +183,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void resolvePlaceholders() {
void resolvePlaceholders() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("key", "value"));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
@ -191,7 +191,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void resolvePlaceholders_withUnresolvable() {
void resolvePlaceholders_withUnresolvable() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("key", "value"));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
@ -200,7 +200,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void resolvePlaceholders_withDefaultValue() {
void resolvePlaceholders_withDefaultValue() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("key", "value"));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
@ -209,13 +209,13 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void resolvePlaceholders_withNullInput() {
void resolvePlaceholders_withNullInput() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PropertySourcesPropertyResolver(new MutablePropertySources()).resolvePlaceholders(null));
}
@Test
public void resolveRequiredPlaceholders() {
void resolveRequiredPlaceholders() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("key", "value"));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
@ -223,7 +223,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void resolveRequiredPlaceholders_withUnresolvable() {
void resolveRequiredPlaceholders_withUnresolvable() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("key", "value"));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
@ -232,7 +232,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void resolveRequiredPlaceholders_withDefaultValue() {
void resolveRequiredPlaceholders_withDefaultValue() {
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addFirst(new MockPropertySource().withProperty("key", "value"));
PropertyResolver resolver = new PropertySourcesPropertyResolver(propertySources);
@ -241,13 +241,13 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void resolveRequiredPlaceholders_withNullInput() {
void resolveRequiredPlaceholders_withNullInput() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PropertySourcesPropertyResolver(new MutablePropertySources()).resolveRequiredPlaceholders(null));
}
@Test
public void setRequiredProperties_andValidateRequiredProperties() {
void setRequiredProperties_andValidateRequiredProperties() {
// no properties have been marked as required -> validation should pass
propertyResolver.validateRequiredProperties();
@ -273,7 +273,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void resolveNestedPropertyPlaceholders() {
void resolveNestedPropertyPlaceholders() {
MutablePropertySources ps = new MutablePropertySources();
ps.addFirst(new MockPropertySource()
.withProperty("p1", "v1")
@ -300,7 +300,7 @@ public class PropertySourcesPropertyResolverTests {
}
@Test
public void ignoreUnresolvableNestedPlaceholdersIsConfigurable() {
void ignoreUnresolvableNestedPlaceholdersIsConfigurable() {
MutablePropertySources ps = new MutablePropertySources();
ps.addFirst(new MockPropertySource()
.withProperty("p1", "v1")

View File

@ -25,17 +25,16 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
public class SimpleCommandLineParserTests {
class SimpleCommandLineParserTests {
@Test
public void withNoOptions() {
void withNoOptions() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
assertThat(parser.parse().getOptionValues("foo")).isNull();
}
@Test
public void withSingleOptionAndNoValue() {
void withSingleOptionAndNoValue() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
CommandLineArgs args = parser.parse("--o1");
assertThat(args.containsOption("o1")).isTrue();
@ -43,7 +42,7 @@ public class SimpleCommandLineParserTests {
}
@Test
public void withSingleOptionAndValue() {
void withSingleOptionAndValue() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
CommandLineArgs args = parser.parse("--o1=v1");
assertThat(args.containsOption("o1")).isTrue();
@ -51,7 +50,7 @@ public class SimpleCommandLineParserTests {
}
@Test
public void withMixOfOptionsHavingValueAndOptionsHavingNoValue() {
void withMixOfOptionsHavingValueAndOptionsHavingNoValue() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
CommandLineArgs args = parser.parse("--o1=v1", "--o2");
assertThat(args.containsOption("o1")).isTrue();
@ -63,35 +62,35 @@ public class SimpleCommandLineParserTests {
}
@Test
public void withEmptyOptionText() {
void withEmptyOptionText() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
assertThatIllegalArgumentException().isThrownBy(() ->
parser.parse("--"));
}
@Test
public void withEmptyOptionName() {
void withEmptyOptionName() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
assertThatIllegalArgumentException().isThrownBy(() ->
parser.parse("--=v1"));
}
@Test
public void withEmptyOptionValue() {
void withEmptyOptionValue() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
assertThatIllegalArgumentException().isThrownBy(() ->
parser.parse("--o1="));
}
@Test
public void withEmptyOptionNameAndEmptyOptionValue() {
void withEmptyOptionNameAndEmptyOptionValue() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
assertThatIllegalArgumentException().isThrownBy(() ->
parser.parse("--="));
}
@Test
public void withNonOptionArguments() {
void withNonOptionArguments() {
SimpleCommandLineArgsParser parser = new SimpleCommandLineArgsParser();
CommandLineArgs args = parser.parse("--o1=v1", "noa1", "--o2=v2", "noa2");
assertThat(args.getOptionValues("o1").get(0)).isEqualTo("v1");
@ -104,14 +103,14 @@ public class SimpleCommandLineParserTests {
}
@Test
public void assertOptionNamesIsUnmodifiable() {
void assertOptionNamesIsUnmodifiable() {
CommandLineArgs args = new SimpleCommandLineArgsParser().parse();
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
args.getOptionNames().add("bogus"));
}
@Test
public void assertNonOptionArgsIsUnmodifiable() {
void assertNonOptionArgsIsUnmodifiable() {
CommandLineArgs args = new SimpleCommandLineArgsParser().parse();
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
args.getNonOptionArgs().add("foo"));

View File

@ -22,37 +22,36 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link SimpleCommandLinePropertySource}.
*
* @author Chris Beams
* @since 3.1
*/
public class SimpleCommandLinePropertySourceTests {
class SimpleCommandLinePropertySourceTests {
@Test
public void withDefaultName() {
void withDefaultName() {
PropertySource<?> ps = new SimpleCommandLinePropertySource();
assertThat(ps.getName())
.isEqualTo(CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME);
}
@Test
public void withCustomName() {
void withCustomName() {
PropertySource<?> ps = new SimpleCommandLinePropertySource("ps1", new String[0]);
assertThat(ps.getName()).isEqualTo("ps1");
}
@Test
public void withNoArgs() {
void withNoArgs() {
PropertySource<?> ps = new SimpleCommandLinePropertySource();
assertThat(ps.containsProperty("foo")).isFalse();
assertThat(ps.getProperty("foo")).isNull();
}
@Test
public void withOptionArgsOnly() {
void withOptionArgsOnly() {
CommandLinePropertySource<?> ps =
new SimpleCommandLinePropertySource("--o1=v1", "--o2");
assertThat(ps.containsProperty("o1")).isTrue();
@ -64,7 +63,7 @@ public class SimpleCommandLinePropertySourceTests {
}
@Test
public void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() {
void withDefaultNonOptionArgsNameAndNoNonOptionArgsPresent() {
EnumerablePropertySource<?> ps = new SimpleCommandLinePropertySource("--o1=v1", "--o2");
assertThat(ps.containsProperty("nonOptionArgs")).isFalse();
@ -77,7 +76,7 @@ public class SimpleCommandLinePropertySourceTests {
}
@Test
public void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() {
void withDefaultNonOptionArgsNameAndNonOptionArgsPresent() {
CommandLinePropertySource<?> ps =
new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2");
@ -90,7 +89,7 @@ public class SimpleCommandLinePropertySourceTests {
}
@Test
public void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() {
void withCustomNonOptionArgsNameAndNoNonOptionArgsPresent() {
CommandLinePropertySource<?> ps =
new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2");
ps.setNonOptionArgsPropertyName("NOA");
@ -104,7 +103,7 @@ public class SimpleCommandLinePropertySourceTests {
}
@Test
public void covertNonOptionArgsToStringArrayAndList() {
void covertNonOptionArgsToStringArrayAndList() {
CommandLinePropertySource<?> ps =
new SimpleCommandLinePropertySource("--o1=v1", "noa1", "--o2", "noa2");
StandardEnvironment env = new StandardEnvironment();

View File

@ -58,7 +58,7 @@ public class StandardEnvironmentTests {
@Test
public void merge() {
void merge() {
ConfigurableEnvironment child = new StandardEnvironment();
child.setActiveProfiles("c1", "c2");
child.getPropertySources().addLast(
@ -99,7 +99,7 @@ public class StandardEnvironmentTests {
}
@Test
public void propertySourceOrder() {
void propertySourceOrder() {
ConfigurableEnvironment env = new StandardEnvironment();
MutablePropertySources sources = env.getPropertySources();
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))).isEqualTo(0);
@ -108,25 +108,25 @@ public class StandardEnvironmentTests {
}
@Test
public void propertySourceTypes() {
void propertySourceTypes() {
ConfigurableEnvironment env = new StandardEnvironment();
MutablePropertySources sources = env.getPropertySources();
assertThat(sources.get(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)).isInstanceOf(SystemEnvironmentPropertySource.class);
}
@Test
public void activeProfilesIsEmptyByDefault() {
void activeProfilesIsEmptyByDefault() {
assertThat(environment.getActiveProfiles().length).isEqualTo(0);
}
@Test
public void defaultProfilesContainsDefaultProfileByDefault() {
void defaultProfilesContainsDefaultProfileByDefault() {
assertThat(environment.getDefaultProfiles().length).isEqualTo(1);
assertThat(environment.getDefaultProfiles()[0]).isEqualTo("default");
}
@Test
public void setActiveProfiles() {
void setActiveProfiles() {
environment.setActiveProfiles("local", "embedded");
String[] activeProfiles = environment.getActiveProfiles();
assertThat(activeProfiles).contains("local", "embedded");
@ -134,55 +134,55 @@ public class StandardEnvironmentTests {
}
@Test
public void setActiveProfiles_withNullProfileArray() {
void setActiveProfiles_withNullProfileArray() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.setActiveProfiles((String[]) null));
}
@Test
public void setActiveProfiles_withNullProfile() {
void setActiveProfiles_withNullProfile() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.setActiveProfiles((String) null));
}
@Test
public void setActiveProfiles_withEmptyProfile() {
void setActiveProfiles_withEmptyProfile() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.setActiveProfiles(""));
}
@Test
public void setActiveProfiles_withNotOperator() {
void setActiveProfiles_withNotOperator() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.setActiveProfiles("p1", "!p2"));
}
@Test
public void setDefaultProfiles_withNullProfileArray() {
void setDefaultProfiles_withNullProfileArray() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.setDefaultProfiles((String[]) null));
}
@Test
public void setDefaultProfiles_withNullProfile() {
void setDefaultProfiles_withNullProfile() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.setDefaultProfiles((String) null));
}
@Test
public void setDefaultProfiles_withEmptyProfile() {
void setDefaultProfiles_withEmptyProfile() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.setDefaultProfiles(""));
}
@Test
public void setDefaultProfiles_withNotOperator() {
void setDefaultProfiles_withNotOperator() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.setDefaultProfiles("d1", "!d2"));
}
@Test
public void addActiveProfile() {
void addActiveProfile() {
assertThat(environment.getActiveProfiles().length).isEqualTo(0);
environment.setActiveProfiles("local", "embedded");
assertThat(environment.getActiveProfiles()).contains("local", "embedded");
@ -197,7 +197,7 @@ public class StandardEnvironmentTests {
}
@Test
public void addActiveProfile_whenActiveProfilesPropertyIsAlreadySet() {
void addActiveProfile_whenActiveProfilesPropertyIsAlreadySet() {
ConfigurableEnvironment env = new StandardEnvironment();
assertThat(env.getProperty(ACTIVE_PROFILES_PROPERTY_NAME)).isNull();
env.getPropertySources().addFirst(new MockPropertySource().withProperty(ACTIVE_PROFILES_PROPERTY_NAME, "p1"));
@ -207,7 +207,7 @@ public class StandardEnvironmentTests {
}
@Test
public void reservedDefaultProfile() {
void reservedDefaultProfile() {
assertThat(environment.getDefaultProfiles()).isEqualTo(new String[]{RESERVED_DEFAULT_PROFILE_NAME});
System.setProperty(DEFAULT_PROFILES_PROPERTY_NAME, "d0");
assertThat(environment.getDefaultProfiles()).isEqualTo(new String[]{"d0"});
@ -217,7 +217,7 @@ public class StandardEnvironmentTests {
}
@Test
public void defaultProfileWithCircularPlaceholder() {
void defaultProfileWithCircularPlaceholder() {
System.setProperty(DEFAULT_PROFILES_PROPERTY_NAME, "${spring.profiles.default}");
try {
assertThatIllegalArgumentException().isThrownBy(() ->
@ -229,7 +229,7 @@ public class StandardEnvironmentTests {
}
@Test
public void getActiveProfiles_systemPropertiesEmpty() {
void getActiveProfiles_systemPropertiesEmpty() {
assertThat(environment.getActiveProfiles().length).isEqualTo(0);
System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "");
assertThat(environment.getActiveProfiles().length).isEqualTo(0);
@ -237,28 +237,28 @@ public class StandardEnvironmentTests {
}
@Test
public void getActiveProfiles_fromSystemProperties() {
void getActiveProfiles_fromSystemProperties() {
System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "foo");
assertThat(Arrays.asList(environment.getActiveProfiles())).contains("foo");
System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME);
}
@Test
public void getActiveProfiles_fromSystemProperties_withMultipleProfiles() {
void getActiveProfiles_fromSystemProperties_withMultipleProfiles() {
System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, "foo,bar");
assertThat(environment.getActiveProfiles()).contains("foo", "bar");
System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME);
}
@Test
public void getActiveProfiles_fromSystemProperties_withMulitpleProfiles_withWhitespace() {
void getActiveProfiles_fromSystemProperties_withMulitpleProfiles_withWhitespace() {
System.setProperty(ACTIVE_PROFILES_PROPERTY_NAME, " bar , baz "); // notice whitespace
assertThat(environment.getActiveProfiles()).contains("bar", "baz");
System.getProperties().remove(ACTIVE_PROFILES_PROPERTY_NAME);
}
@Test
public void getDefaultProfiles() {
void getDefaultProfiles() {
assertThat(environment.getDefaultProfiles()).isEqualTo(new String[] {RESERVED_DEFAULT_PROFILE_NAME});
environment.getPropertySources().addFirst(new MockPropertySource().withProperty(DEFAULT_PROFILES_PROPERTY_NAME, "pd1"));
assertThat(environment.getDefaultProfiles().length).isEqualTo(1);
@ -266,7 +266,7 @@ public class StandardEnvironmentTests {
}
@Test
public void setDefaultProfiles() {
void setDefaultProfiles() {
environment.setDefaultProfiles();
assertThat(environment.getDefaultProfiles().length).isEqualTo(0);
environment.setDefaultProfiles("pd1");
@ -277,31 +277,31 @@ public class StandardEnvironmentTests {
}
@Test
public void acceptsProfiles_withEmptyArgumentList() {
void acceptsProfiles_withEmptyArgumentList() {
assertThatIllegalArgumentException().isThrownBy(
environment::acceptsProfiles);
}
@Test
public void acceptsProfiles_withNullArgumentList() {
void acceptsProfiles_withNullArgumentList() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.acceptsProfiles((String[]) null));
}
@Test
public void acceptsProfiles_withNullArgument() {
void acceptsProfiles_withNullArgument() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.acceptsProfiles((String) null));
}
@Test
public void acceptsProfiles_withEmptyArgument() {
void acceptsProfiles_withEmptyArgument() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.acceptsProfiles(""));
}
@Test
public void acceptsProfiles_activeProfileSetProgrammatically() {
void acceptsProfiles_activeProfileSetProgrammatically() {
assertThat(environment.acceptsProfiles("p1", "p2")).isFalse();
environment.setActiveProfiles("p1");
assertThat(environment.acceptsProfiles("p1", "p2")).isTrue();
@ -312,14 +312,14 @@ public class StandardEnvironmentTests {
}
@Test
public void acceptsProfiles_activeProfileSetViaProperty() {
void acceptsProfiles_activeProfileSetViaProperty() {
assertThat(environment.acceptsProfiles("p1")).isFalse();
environment.getPropertySources().addFirst(new MockPropertySource().withProperty(ACTIVE_PROFILES_PROPERTY_NAME, "p1"));
assertThat(environment.acceptsProfiles("p1")).isTrue();
}
@Test
public void acceptsProfiles_defaultProfile() {
void acceptsProfiles_defaultProfile() {
assertThat(environment.acceptsProfiles("pd")).isFalse();
environment.setDefaultProfiles("pd");
assertThat(environment.acceptsProfiles("pd")).isTrue();
@ -329,7 +329,7 @@ public class StandardEnvironmentTests {
}
@Test
public void acceptsProfiles_withNotOperator() {
void acceptsProfiles_withNotOperator() {
assertThat(environment.acceptsProfiles("p1")).isFalse();
assertThat(environment.acceptsProfiles("!p1")).isTrue();
environment.addActiveProfile("p1");
@ -338,13 +338,13 @@ public class StandardEnvironmentTests {
}
@Test
public void acceptsProfiles_withInvalidNotOperator() {
void acceptsProfiles_withInvalidNotOperator() {
assertThatIllegalArgumentException().isThrownBy(() ->
environment.acceptsProfiles("p1", "!"));
}
@Test
public void acceptsProfiles_withProfileExpression() {
void acceptsProfiles_withProfileExpression() {
assertThat(environment.acceptsProfiles(Profiles.of("p1 & p2"))).isFalse();
environment.addActiveProfile("p1");
assertThat(environment.acceptsProfiles(Profiles.of("p1 & p2"))).isFalse();
@ -353,7 +353,7 @@ public class StandardEnvironmentTests {
}
@Test
public void environmentSubclass_withCustomProfileValidation() {
void environmentSubclass_withCustomProfileValidation() {
ConfigurableEnvironment env = new AbstractEnvironment() {
@Override
protected void validateProfile(String profile) {
@ -373,28 +373,28 @@ public class StandardEnvironmentTests {
}
@Test
public void suppressGetenvAccessThroughSystemProperty() {
void suppressGetenvAccessThroughSystemProperty() {
System.setProperty("spring.getenv.ignore", "true");
assertThat(environment.getSystemEnvironment().isEmpty()).isTrue();
System.clearProperty("spring.getenv.ignore");
}
@Test
public void suppressGetenvAccessThroughSpringProperty() {
void suppressGetenvAccessThroughSpringProperty() {
SpringProperties.setProperty("spring.getenv.ignore", "true");
assertThat(environment.getSystemEnvironment().isEmpty()).isTrue();
SpringProperties.setProperty("spring.getenv.ignore", null);
}
@Test
public void suppressGetenvAccessThroughSpringFlag() {
void suppressGetenvAccessThroughSpringFlag() {
SpringProperties.setFlag("spring.getenv.ignore");
assertThat(environment.getSystemEnvironment().isEmpty()).isTrue();
SpringProperties.setProperty("spring.getenv.ignore", null);
}
@Test
public void getSystemProperties_withAndWithoutSecurityManager() {
void getSystemProperties_withAndWithoutSecurityManager() {
System.setProperty(ALLOWED_PROPERTY_NAME, ALLOWED_PROPERTY_VALUE);
System.setProperty(DISALLOWED_PROPERTY_NAME, DISALLOWED_PROPERTY_VALUE);
System.getProperties().put(STRING_PROPERTY_NAME, NON_STRING_PROPERTY_VALUE);
@ -464,7 +464,7 @@ public class StandardEnvironmentTests {
}
@Test
public void getSystemEnvironment_withAndWithoutSecurityManager() {
void getSystemEnvironment_withAndWithoutSecurityManager() {
getModifiableSystemEnvironment().put(ALLOWED_PROPERTY_NAME, ALLOWED_PROPERTY_VALUE);
getModifiableSystemEnvironment().put(DISALLOWED_PROPERTY_NAME, DISALLOWED_PROPERTY_VALUE);

View File

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @since 3.1
*/
public class SystemEnvironmentPropertySourceTests {
class SystemEnvironmentPropertySourceTests {
private Map<String, Object> envMap;
@ -42,20 +42,20 @@ public class SystemEnvironmentPropertySourceTests {
@BeforeEach
public void setUp() {
void setUp() {
envMap = new HashMap<>();
ps = new SystemEnvironmentPropertySource("sysEnv", envMap);
}
@Test
public void none() {
void none() {
assertThat(ps.containsProperty("a.key")).isEqualTo(false);
assertThat(ps.getProperty("a.key")).isNull();
}
@Test
public void normalWithoutPeriod() {
void normalWithoutPeriod() {
envMap.put("akey", "avalue");
assertThat(ps.containsProperty("akey")).isEqualTo(true);
@ -63,7 +63,7 @@ public class SystemEnvironmentPropertySourceTests {
}
@Test
public void normalWithPeriod() {
void normalWithPeriod() {
envMap.put("a.key", "a.value");
assertThat(ps.containsProperty("a.key")).isEqualTo(true);
@ -71,7 +71,7 @@ public class SystemEnvironmentPropertySourceTests {
}
@Test
public void withUnderscore() {
void withUnderscore() {
envMap.put("a_key", "a_value");
assertThat(ps.containsProperty("a_key")).isEqualTo(true);
@ -82,7 +82,7 @@ public class SystemEnvironmentPropertySourceTests {
}
@Test
public void withBothPeriodAndUnderscore() {
void withBothPeriodAndUnderscore() {
envMap.put("a_key", "a_value");
envMap.put("a.key", "a.value");
@ -91,7 +91,7 @@ public class SystemEnvironmentPropertySourceTests {
}
@Test
public void withUppercase() {
void withUppercase() {
envMap.put("A_KEY", "a_value");
envMap.put("A_LONG_KEY", "a_long_value");
envMap.put("A_DOT.KEY", "a_dot_value");
@ -150,7 +150,7 @@ public class SystemEnvironmentPropertySourceTests {
@Test
@SuppressWarnings("serial")
public void withSecurityConstraints() throws Exception {
void withSecurityConstraints() throws Exception {
envMap = new HashMap<String, Object>() {
@Override
public boolean containsKey(Object key) {

View File

@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Chris Beams
* @author Sam Brannen
*/
public class ClassPathResourceTests {
class ClassPathResourceTests {
private static final String PACKAGE_PATH = "org/springframework/core/io";
private static final String NONEXISTENT_RESOURCE_NAME = "nonexistent.xml";
@ -47,69 +47,69 @@ public class ClassPathResourceTests {
@Test
public void stringConstructorRaisesExceptionWithFullyQualifiedPath() {
void stringConstructorRaisesExceptionWithFullyQualifiedPath() {
assertExceptionContainsFullyQualifiedPath(new ClassPathResource(FQ_RESOURCE_PATH));
}
@Test
public void classLiteralConstructorRaisesExceptionWithFullyQualifiedPath() {
void classLiteralConstructorRaisesExceptionWithFullyQualifiedPath() {
assertExceptionContainsFullyQualifiedPath(new ClassPathResource(NONEXISTENT_RESOURCE_NAME, getClass()));
}
@Test
public void classLoaderConstructorRaisesExceptionWithFullyQualifiedPath() {
void classLoaderConstructorRaisesExceptionWithFullyQualifiedPath() {
assertExceptionContainsFullyQualifiedPath(new ClassPathResource(FQ_RESOURCE_PATH, getClass().getClassLoader()));
}
@Test
public void getDescriptionWithStringConstructor() {
void getDescriptionWithStringConstructor() {
assertDescriptionContainsExpectedPath(new ClassPathResource(FQ_RESOURCE_PATH), FQ_RESOURCE_PATH);
}
@Test
public void getDescriptionWithStringConstructorAndLeadingSlash() {
void getDescriptionWithStringConstructorAndLeadingSlash() {
assertDescriptionContainsExpectedPath(new ClassPathResource(FQ_RESOURCE_PATH_WITH_LEADING_SLASH),
FQ_RESOURCE_PATH);
}
@Test
public void getDescriptionWithClassLiteralConstructor() {
void getDescriptionWithClassLiteralConstructor() {
assertDescriptionContainsExpectedPath(new ClassPathResource(NONEXISTENT_RESOURCE_NAME, getClass()),
FQ_RESOURCE_PATH);
}
@Test
public void getDescriptionWithClassLiteralConstructorAndLeadingSlash() {
void getDescriptionWithClassLiteralConstructorAndLeadingSlash() {
assertDescriptionContainsExpectedPath(
new ClassPathResource(FQ_RESOURCE_PATH_WITH_LEADING_SLASH, getClass()), FQ_RESOURCE_PATH);
}
@Test
public void getDescriptionWithClassLoaderConstructor() {
void getDescriptionWithClassLoaderConstructor() {
assertDescriptionContainsExpectedPath(
new ClassPathResource(FQ_RESOURCE_PATH, getClass().getClassLoader()), FQ_RESOURCE_PATH);
}
@Test
public void getDescriptionWithClassLoaderConstructorAndLeadingSlash() {
void getDescriptionWithClassLoaderConstructorAndLeadingSlash() {
assertDescriptionContainsExpectedPath(
new ClassPathResource(FQ_RESOURCE_PATH_WITH_LEADING_SLASH, getClass().getClassLoader()), FQ_RESOURCE_PATH);
}
@Test
public void dropLeadingSlashForClassLoaderAccess() {
void dropLeadingSlashForClassLoaderAccess() {
assertThat(new ClassPathResource("/test.html").getPath()).isEqualTo("test.html");
assertThat(((ClassPathResource) new ClassPathResource("").createRelative("/test.html")).getPath()).isEqualTo("test.html");
}
@Test
public void preserveLeadingSlashForClassRelativeAccess() {
void preserveLeadingSlashForClassRelativeAccess() {
assertThat(new ClassPathResource("/test.html", getClass()).getPath()).isEqualTo("/test.html");
assertThat(((ClassPathResource) new ClassPathResource("", getClass()).createRelative("/test.html")).getPath()).isEqualTo("/test.html");
}
@Test
public void directoryNotReadable() {
void directoryNotReadable() {
Resource fileDir = new ClassPathResource("org/springframework/core");
assertThat(fileDir.exists()).isTrue();
assertThat(fileDir.isReadable()).isFalse();

View File

@ -51,7 +51,7 @@ import static org.mockito.Mockito.mock;
* @author Arjen Poutsma
*/
@Deprecated
public class PathResourceTests {
class PathResourceTests {
private static final String TEST_DIR =
platformPath("src/test/resources/org/springframework/core/io");
@ -69,136 +69,136 @@ public class PathResourceTests {
@Test
public void nullPath() {
void nullPath() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PathResource((Path) null))
.withMessageContaining("Path must not be null");
}
@Test
public void nullPathString() {
void nullPathString() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PathResource((String) null))
.withMessageContaining("Path must not be null");
}
@Test
public void nullUri() {
void nullUri() {
assertThatIllegalArgumentException().isThrownBy(() ->
new PathResource((URI) null))
.withMessageContaining("URI must not be null");
}
@Test
public void createFromPath() {
void createFromPath() {
Path path = Paths.get(TEST_FILE);
PathResource resource = new PathResource(path);
assertThat(resource.getPath()).isEqualTo(TEST_FILE);
}
@Test
public void createFromString() {
void createFromString() {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.getPath()).isEqualTo(TEST_FILE);
}
@Test
public void createFromUri() {
void createFromUri() {
File file = new File(TEST_FILE);
PathResource resource = new PathResource(file.toURI());
assertThat(resource.getPath()).isEqualTo(file.getAbsoluteFile().toString());
}
@Test
public void getPathForFile() {
void getPathForFile() {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.getPath()).isEqualTo(TEST_FILE);
}
@Test
public void getPathForDir() {
void getPathForDir() {
PathResource resource = new PathResource(TEST_DIR);
assertThat(resource.getPath()).isEqualTo(TEST_DIR);
}
@Test
public void fileExists() {
void fileExists() {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.exists()).isEqualTo(true);
}
@Test
public void dirExists() {
void dirExists() {
PathResource resource = new PathResource(TEST_DIR);
assertThat(resource.exists()).isEqualTo(true);
}
@Test
public void fileDoesNotExist() {
void fileDoesNotExist() {
PathResource resource = new PathResource(NON_EXISTING_FILE);
assertThat(resource.exists()).isEqualTo(false);
}
@Test
public void fileIsReadable() {
void fileIsReadable() {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.isReadable()).isEqualTo(true);
}
@Test
public void doesNotExistIsNotReadable() {
void doesNotExistIsNotReadable() {
PathResource resource = new PathResource(NON_EXISTING_FILE);
assertThat(resource.isReadable()).isEqualTo(false);
}
@Test
public void directoryIsNotReadable() {
void directoryIsNotReadable() {
PathResource resource = new PathResource(TEST_DIR);
assertThat(resource.isReadable()).isEqualTo(false);
}
@Test
public void getInputStream() throws IOException {
void getInputStream() throws IOException {
PathResource resource = new PathResource(TEST_FILE);
byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
assertThat(bytes.length).isGreaterThan(0);
}
@Test
public void getInputStreamForDir() throws IOException {
void getInputStreamForDir() throws IOException {
PathResource resource = new PathResource(TEST_DIR);
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
resource::getInputStream);
}
@Test
public void getInputStreamDoesNotExist() throws IOException {
void getInputStreamDoesNotExist() throws IOException {
PathResource resource = new PathResource(NON_EXISTING_FILE);
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
resource::getInputStream);
}
@Test
public void getUrl() throws IOException {
void getUrl() throws IOException {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.getURL().toString()).endsWith("core/io/example.properties");
}
@Test
public void getUri() throws IOException {
void getUri() throws IOException {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.getURI().toString()).endsWith("core/io/example.properties");
}
@Test
public void getFile() throws IOException {
void getFile() throws IOException {
PathResource resource = new PathResource(TEST_FILE);
File file = new File(TEST_FILE);
assertThat(resource.getFile().getAbsoluteFile()).isEqualTo(file.getAbsoluteFile());
}
@Test
public void getFileUnsupported() throws IOException {
void getFileUnsupported() throws IOException {
Path path = mock(Path.class);
given(path.normalize()).willReturn(path);
given(path.toFile()).willThrow(new UnsupportedOperationException());
@ -208,72 +208,72 @@ public class PathResourceTests {
}
@Test
public void contentLength() throws IOException {
void contentLength() throws IOException {
PathResource resource = new PathResource(TEST_FILE);
File file = new File(TEST_FILE);
assertThat(resource.contentLength()).isEqualTo(file.length());
}
@Test
public void contentLengthForDirectory() throws IOException {
void contentLengthForDirectory() throws IOException {
PathResource resource = new PathResource(TEST_DIR);
File file = new File(TEST_DIR);
assertThat(resource.contentLength()).isEqualTo(file.length());
}
@Test
public void lastModified() throws IOException {
void lastModified() throws IOException {
PathResource resource = new PathResource(TEST_FILE);
File file = new File(TEST_FILE);
assertThat(resource.lastModified() / 1000).isEqualTo(file.lastModified() / 1000);
}
@Test
public void createRelativeFromDir() throws IOException {
void createRelativeFromDir() throws IOException {
Resource resource = new PathResource(TEST_DIR).createRelative("example.properties");
assertThat(resource).isEqualTo(new PathResource(TEST_FILE));
}
@Test
public void createRelativeFromFile() throws IOException {
void createRelativeFromFile() throws IOException {
Resource resource = new PathResource(TEST_FILE).createRelative("../example.properties");
assertThat(resource).isEqualTo(new PathResource(TEST_FILE));
}
@Test
public void filename() {
void filename() {
Resource resource = new PathResource(TEST_FILE);
assertThat(resource.getFilename()).isEqualTo("example.properties");
}
@Test
public void description() {
void description() {
Resource resource = new PathResource(TEST_FILE);
assertThat(resource.getDescription()).contains("path [");
assertThat(resource.getDescription()).contains(TEST_FILE);
}
@Test
public void fileIsWritable() {
void fileIsWritable() {
PathResource resource = new PathResource(TEST_FILE);
assertThat(resource.isWritable()).isEqualTo(true);
}
@Test
public void directoryIsNotWritable() {
void directoryIsNotWritable() {
PathResource resource = new PathResource(TEST_DIR);
assertThat(resource.isWritable()).isEqualTo(false);
}
@Test
public void outputStream(@TempDir Path temporaryFolder) throws IOException {
void outputStream(@TempDir Path temporaryFolder) throws IOException {
PathResource resource = new PathResource(temporaryFolder.resolve("test"));
FileCopyUtils.copy("test".getBytes(StandardCharsets.UTF_8), resource.getOutputStream());
assertThat(resource.contentLength()).isEqualTo(4L);
}
@Test
public void doesNotExistOutputStream(@TempDir Path temporaryFolder) throws IOException {
void doesNotExistOutputStream(@TempDir Path temporaryFolder) throws IOException {
File file = temporaryFolder.resolve("test").toFile();
file.delete();
PathResource resource = new PathResource(file.toPath());
@ -282,14 +282,14 @@ public class PathResourceTests {
}
@Test
public void directoryOutputStream() throws IOException {
void directoryOutputStream() throws IOException {
PathResource resource = new PathResource(TEST_DIR);
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
resource::getOutputStream);
}
@Test
public void getReadableByteChannel() throws IOException {
void getReadableByteChannel() throws IOException {
PathResource resource = new PathResource(TEST_FILE);
ReadableByteChannel channel = null;
try {
@ -307,7 +307,7 @@ public class PathResourceTests {
}
@Test
public void getReadableByteChannelForDir() throws IOException {
void getReadableByteChannelForDir() throws IOException {
PathResource resource = new PathResource(TEST_DIR);
try {
resource.readableChannel();
@ -318,14 +318,14 @@ public class PathResourceTests {
}
@Test
public void getReadableByteChannelDoesNotExist() throws IOException {
void getReadableByteChannelDoesNotExist() throws IOException {
PathResource resource = new PathResource(NON_EXISTING_FILE);
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
resource::readableChannel);
}
@Test
public void getWritableChannel(@TempDir Path temporaryFolder) throws IOException {
void getWritableChannel(@TempDir Path temporaryFolder) throws IOException {
Path testPath = temporaryFolder.resolve("test");
Files.createFile(testPath);
PathResource resource = new PathResource(testPath);

View File

@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Arjen Poutsma
* @author Dave Syer
*/
public class ResourceEditorTests {
class ResourceEditorTests {
@Test
public void sunnyDay() {
void sunnyDay() {
PropertyEditor editor = new ResourceEditor();
editor.setAsText("classpath:org/springframework/core/io/ResourceEditorTests.class");
Resource resource = (Resource) editor.getValue();
@ -44,27 +44,27 @@ public class ResourceEditorTests {
}
@Test
public void ctorWithNullCtorArgs() {
void ctorWithNullCtorArgs() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ResourceEditor(null, null));
}
@Test
public void setAndGetAsTextWithNull() {
void setAndGetAsTextWithNull() {
PropertyEditor editor = new ResourceEditor();
editor.setAsText(null);
assertThat(editor.getAsText()).isEqualTo("");
}
@Test
public void setAndGetAsTextWithWhitespaceResource() {
void setAndGetAsTextWithWhitespaceResource() {
PropertyEditor editor = new ResourceEditor();
editor.setAsText(" ");
assertThat(editor.getAsText()).isEqualTo("");
}
@Test
public void testSystemPropertyReplacement() {
void systemPropertyReplacement() {
PropertyEditor editor = new ResourceEditor();
System.setProperty("test.prop", "foo");
try {
@ -78,7 +78,7 @@ public class ResourceEditorTests {
}
@Test
public void testSystemPropertyReplacementWithUnresolvablePlaceholder() {
void systemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceEditor();
System.setProperty("test.prop", "foo");
try {
@ -92,7 +92,7 @@ public class ResourceEditorTests {
}
@Test
public void testStrictSystemPropertyReplacementWithUnresolvablePlaceholder() {
void strictSystemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceEditor(new DefaultResourceLoader(), new StandardEnvironment(), false);
System.setProperty("test.prop", "foo");
try {

View File

@ -43,10 +43,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Sam Brannen
* @since 09.09.2004
*/
public class ResourceTests {
class ResourceTests {
@Test
public void testByteArrayResource() throws IOException {
void byteArrayResource() throws IOException {
Resource resource = new ByteArrayResource("testString".getBytes());
assertThat(resource.exists()).isTrue();
assertThat(resource.isOpen()).isFalse();
@ -56,7 +56,7 @@ public class ResourceTests {
}
@Test
public void testByteArrayResourceWithDescription() throws IOException {
void byteArrayResourceWithDescription() throws IOException {
Resource resource = new ByteArrayResource("testString".getBytes(), "my description");
assertThat(resource.exists()).isTrue();
assertThat(resource.isOpen()).isFalse();
@ -67,7 +67,7 @@ public class ResourceTests {
}
@Test
public void testInputStreamResource() throws IOException {
void inputStreamResource() throws IOException {
InputStream is = new ByteArrayInputStream("testString".getBytes());
Resource resource = new InputStreamResource(is);
assertThat(resource.exists()).isTrue();
@ -78,7 +78,7 @@ public class ResourceTests {
}
@Test
public void testInputStreamResourceWithDescription() throws IOException {
void inputStreamResourceWithDescription() throws IOException {
InputStream is = new ByteArrayInputStream("testString".getBytes());
Resource resource = new InputStreamResource(is, "my description");
assertThat(resource.exists()).isTrue();
@ -90,7 +90,7 @@ public class ResourceTests {
}
@Test
public void testClassPathResource() throws IOException {
void classPathResource() throws IOException {
Resource resource = new ClassPathResource("org/springframework/core/io/Resource.class");
doTestResource(resource);
Resource resource2 = new ClassPathResource("org/springframework/core/../core/io/./Resource.class");
@ -106,7 +106,7 @@ public class ResourceTests {
}
@Test
public void testClassPathResourceWithClassLoader() throws IOException {
void classPathResourceWithClassLoader() throws IOException {
Resource resource =
new ClassPathResource("org/springframework/core/io/Resource.class", getClass().getClassLoader());
doTestResource(resource);
@ -114,14 +114,14 @@ public class ResourceTests {
}
@Test
public void testClassPathResourceWithClass() throws IOException {
void classPathResourceWithClass() throws IOException {
Resource resource = new ClassPathResource("Resource.class", getClass());
doTestResource(resource);
assertThat(new ClassPathResource("Resource.class", getClass())).isEqualTo(resource);
}
@Test
public void testFileSystemResource() throws IOException {
void fileSystemResource() throws IOException {
String file = getClass().getResource("Resource.class").getFile();
Resource resource = new FileSystemResource(file);
doTestResource(resource);
@ -129,7 +129,7 @@ public class ResourceTests {
}
@Test
public void testFileSystemResourceWithFilePath() throws Exception {
void fileSystemResourceWithFilePath() throws Exception {
Path filePath = Paths.get(getClass().getResource("Resource.class").toURI());
Resource resource = new FileSystemResource(filePath);
doTestResource(resource);
@ -137,13 +137,13 @@ public class ResourceTests {
}
@Test
public void testFileSystemResourceWithPlainPath() {
void fileSystemResourceWithPlainPath() {
Resource resource = new FileSystemResource("core/io/Resource.class");
assertThat(new FileSystemResource("core/../core/io/./Resource.class")).isEqualTo(resource);
}
@Test
public void testUrlResource() throws IOException {
void urlResource() throws IOException {
Resource resource = new UrlResource(getClass().getResource("Resource.class"));
doTestResource(resource);
assertThat(resource).isEqualTo(new UrlResource(getClass().getResource("Resource.class")));
@ -198,21 +198,21 @@ public class ResourceTests {
}
@Test
public void testClassPathResourceWithRelativePath() throws IOException {
void classPathResourceWithRelativePath() throws IOException {
Resource resource = new ClassPathResource("dir/");
Resource relative = resource.createRelative("subdir");
assertThat(relative).isEqualTo(new ClassPathResource("dir/subdir"));
}
@Test
public void testFileSystemResourceWithRelativePath() throws IOException {
void fileSystemResourceWithRelativePath() throws IOException {
Resource resource = new FileSystemResource("dir/");
Resource relative = resource.createRelative("subdir");
assertThat(relative).isEqualTo(new FileSystemResource("dir/subdir"));
}
@Test
public void testUrlResourceWithRelativePath() throws IOException {
void urlResourceWithRelativePath() throws IOException {
Resource resource = new UrlResource("file:dir/");
Resource relative = resource.createRelative("subdir");
assertThat(relative).isEqualTo(new UrlResource("file:dir/subdir"));
@ -220,13 +220,13 @@ public class ResourceTests {
@Disabled
@Test // this test is quite slow. TODO: re-enable with JUnit categories
public void testNonFileResourceExists() throws Exception {
void testNonFileResourceExists() throws Exception {
Resource resource = new UrlResource("https://www.springframework.org");
assertThat(resource.exists()).isTrue();
}
@Test
public void testAbstractResourceExceptions() throws Exception {
void abstractResourceExceptions() throws Exception {
final String name = "test-resource";
Resource resource = new AbstractResource() {
@ -254,7 +254,7 @@ public class ResourceTests {
}
@Test
public void testContentLength() throws IOException {
void contentLength() throws IOException {
AbstractResource resource = new AbstractResource() {
@Override
public InputStream getInputStream() {
@ -269,7 +269,7 @@ public class ResourceTests {
}
@Test
public void testReadableChannel() throws IOException {
void readableChannel() throws IOException {
Resource resource = new FileSystemResource(getClass().getResource("Resource.class").getFile());
ReadableByteChannel channel = null;
try {
@ -287,25 +287,25 @@ public class ResourceTests {
}
@Test
public void testInputStreamNotFoundOnFileSystemResource() throws IOException {
void inputStreamNotFoundOnFileSystemResource() throws IOException {
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() ->
new FileSystemResource(getClass().getResource("Resource.class").getFile()).createRelative("X").getInputStream());
}
@Test
public void testReadableChannelNotFoundOnFileSystemResource() throws IOException {
void readableChannelNotFoundOnFileSystemResource() throws IOException {
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() ->
new FileSystemResource(getClass().getResource("Resource.class").getFile()).createRelative("X").readableChannel());
}
@Test
public void testInputStreamNotFoundOnClassPathResource() throws IOException {
void inputStreamNotFoundOnClassPathResource() throws IOException {
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() ->
new ClassPathResource("Resource.class", getClass()).createRelative("X").getInputStream());
}
@Test
public void testReadableChannelNotFoundOnClassPathResource() throws IOException {
void readableChannelNotFoundOnClassPathResource() throws IOException {
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() ->
new ClassPathResource("Resource.class", getClass()).createRelative("X").readableChannel());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ public abstract class AbstractLeakCheckingTestCase {
* released, throwing an assertion error if so.
*/
@AfterEach
public final void checkForLeaks() {
final void checkForLeaks() {
this.bufferFactory.checkForLeaks();
}

View File

@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class DataBufferTests extends AbstractDataBufferAllocatingTests {
@ParameterizedDataBufferAllocatingTest
public void byteCountsAndPositions(String displayName, DataBufferFactory bufferFactory) {
void byteCountsAndPositions(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(2);
@ -76,7 +76,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readPositionSmallerThanZero(String displayName, DataBufferFactory bufferFactory) {
void readPositionSmallerThanZero(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -90,7 +90,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readPositionGreaterThanWritePosition(String displayName, DataBufferFactory bufferFactory) {
void readPositionGreaterThanWritePosition(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -104,7 +104,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writePositionSmallerThanReadPosition(String displayName, DataBufferFactory bufferFactory) {
void writePositionSmallerThanReadPosition(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(2);
@ -120,7 +120,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writePositionGreaterThanCapacity(String displayName, DataBufferFactory bufferFactory) {
void writePositionGreaterThanCapacity(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -134,7 +134,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeAndRead(String displayName, DataBufferFactory bufferFactory) {
void writeAndRead(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(5);
@ -155,7 +155,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeNullString(String displayName, DataBufferFactory bufferFactory) {
void writeNullString(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -169,7 +169,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeNullCharset(String displayName, DataBufferFactory bufferFactory) {
void writeNullCharset(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -183,7 +183,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeEmptyString(String displayName, DataBufferFactory bufferFactory) {
void writeEmptyString(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -195,7 +195,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeUtf8String(String displayName, DataBufferFactory bufferFactory) {
void writeUtf8String(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(6);
@ -209,7 +209,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeUtf8StringOutGrowsCapacity(String displayName, DataBufferFactory bufferFactory) {
void writeUtf8StringOutGrowsCapacity(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(5);
@ -223,7 +223,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeIsoString(String displayName, DataBufferFactory bufferFactory) {
void writeIsoString(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(3);
@ -237,7 +237,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeMultipleUtf8String(String displayName, DataBufferFactory bufferFactory) {
void writeMultipleUtf8String(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -259,7 +259,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void toStringNullCharset(String displayName, DataBufferFactory bufferFactory) {
void toStringNullCharset(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -273,7 +273,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void toStringUtf8(String displayName, DataBufferFactory bufferFactory) {
void toStringUtf8(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
String spring = "Spring";
@ -288,7 +288,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void toStringSection(String displayName, DataBufferFactory bufferFactory) {
void toStringSection(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
String spring = "Spring";
@ -303,7 +303,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void inputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
void inputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(4);
@ -337,7 +337,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void inputStreamReleaseOnClose(String displayName, DataBufferFactory bufferFactory) throws Exception {
void inputStreamReleaseOnClose(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(3);
@ -360,7 +360,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void outputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
void outputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(4);
@ -380,7 +380,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void expand(String displayName, DataBufferFactory bufferFactory) {
void expand(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -394,7 +394,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void increaseCapacity(String displayName, DataBufferFactory bufferFactory) {
void increaseCapacity(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -407,7 +407,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void decreaseCapacityLowReadPosition(String displayName, DataBufferFactory bufferFactory) {
void decreaseCapacityLowReadPosition(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(2);
@ -419,7 +419,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void decreaseCapacityHighReadPosition(String displayName, DataBufferFactory bufferFactory) {
void decreaseCapacityHighReadPosition(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(2);
@ -432,7 +432,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void capacityLessThanZero(String displayName, DataBufferFactory bufferFactory) {
void capacityLessThanZero(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -446,7 +446,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeByteBuffer(String displayName, DataBufferFactory bufferFactory) {
void writeByteBuffer(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer1 = createDataBuffer(1);
@ -475,7 +475,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeDataBuffer(String displayName, DataBufferFactory bufferFactory) {
void writeDataBuffer(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer1 = createDataBuffer(1);
@ -498,7 +498,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void asByteBuffer(String displayName, DataBufferFactory bufferFactory) {
void asByteBuffer(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(4);
@ -519,7 +519,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void asByteBufferIndexLength(String displayName, DataBufferFactory bufferFactory) {
void asByteBufferIndexLength(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(3);
@ -539,7 +539,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void byteBufferContainsDataBufferChanges(String displayName, DataBufferFactory bufferFactory) {
void byteBufferContainsDataBufferChanges(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer dataBuffer = createDataBuffer(1);
@ -555,7 +555,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void dataBufferContainsByteBufferChanges(String displayName, DataBufferFactory bufferFactory) {
void dataBufferContainsByteBufferChanges(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer dataBuffer = createDataBuffer(1);
@ -571,7 +571,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void emptyAsByteBuffer(String displayName, DataBufferFactory bufferFactory) {
void emptyAsByteBuffer(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(1);
@ -583,7 +583,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void indexOf(String displayName, DataBufferFactory bufferFactory) {
void indexOf(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(3);
@ -605,7 +605,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void lastIndexOf(String displayName, DataBufferFactory bufferFactory) {
void lastIndexOf(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(3);
@ -636,7 +636,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void slice(String displayName, DataBufferFactory bufferFactory) {
void slice(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(3);
@ -665,7 +665,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void retainedSlice(String displayName, DataBufferFactory bufferFactory) {
void retainedSlice(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(3);
@ -694,7 +694,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void spr16351(String displayName, DataBufferFactory bufferFactory) {
void spr16351(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = createDataBuffer(6);
@ -714,7 +714,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void join(String displayName, DataBufferFactory bufferFactory) {
void join(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer composite = this.bufferFactory.join(Arrays.asList(stringBuffer("a"),
@ -729,7 +729,7 @@ class DataBufferTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void getByte(String displayName, DataBufferFactory bufferFactory) {
void getByte(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer buffer = stringBuffer("abc");

View File

@ -72,7 +72,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
@ParameterizedDataBufferAllocatingTest
public void readInputStream(String displayName, DataBufferFactory bufferFactory) {
void readInputStream(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> flux = DataBufferUtils.readInputStream(
@ -82,7 +82,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
URI uri = this.resource.getURI();
@ -94,7 +94,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readByteChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readByteChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
ReadableByteChannel channel = mock(ReadableByteChannel.class);
@ -117,7 +117,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
URI uri = this.resource.getURI();
@ -132,7 +132,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
URI uri = this.resource.getURI();
@ -144,7 +144,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readAsynchronousFileChannelPosition(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readAsynchronousFileChannelPosition(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
URI uri = this.resource.getURI();
@ -159,7 +159,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readAsynchronousFileChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readAsynchronousFileChannelError(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
AsynchronousFileChannel channel = mock(AsynchronousFileChannel.class);
@ -191,7 +191,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readAsynchronousFileChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readAsynchronousFileChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
URI uri = this.resource.getURI();
@ -206,7 +206,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest // gh-22107
public void readAsynchronousFileChannelCancelWithoutDemand(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readAsynchronousFileChannelCancelWithoutDemand(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
URI uri = this.resource.getURI();
@ -220,7 +220,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readPath(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readPath(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource.getFile().toPath(), super.bufferFactory, 3);
@ -229,7 +229,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readResource(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readResource(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource, super.bufferFactory, 3);
@ -238,7 +238,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readResourcePosition(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readResourcePosition(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> flux = DataBufferUtils.read(this.resource, 9, super.bufferFactory, 3);
@ -260,7 +260,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
Resource resource = new ClassPathResource("DataBufferUtilsTests.txt", getClass());
@ -277,7 +277,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readByteArrayResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readByteArrayResourcePositionAndTakeUntil(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
Resource resource = new ByteArrayResource("foobarbazqux" .getBytes());
@ -294,7 +294,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeOutputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeOutputStream(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -311,7 +311,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeWritableByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeWritableByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -328,7 +328,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeWritableByteChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeWritableByteChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -351,7 +351,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeWritableByteChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeWritableByteChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -379,7 +379,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeWritableByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeWritableByteChannelCancel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -403,7 +403,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -435,7 +435,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeAsynchronousFileChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeAsynchronousFileChannelErrorInFlux(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -461,7 +461,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
@ParameterizedDataBufferAllocatingTest
@SuppressWarnings("unchecked")
public void writeAsynchronousFileChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeAsynchronousFileChannelErrorInWrite(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -502,7 +502,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writeAsynchronousFileChannelCanceled(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writeAsynchronousFileChannelCanceled(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -527,7 +527,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void writePath(String displayName, DataBufferFactory bufferFactory) throws Exception {
void writePath(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -544,7 +544,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readAndWriteByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readAndWriteByteChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
Path source = Paths.get(
@ -578,7 +578,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void readAndWriteAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
void readAndWriteAsynchronousFileChannel(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
Path source = Paths.get(
@ -619,7 +619,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void takeUntilByteCount(String displayName, DataBufferFactory bufferFactory) {
void takeUntilByteCount(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> result = DataBufferUtils.takeUntilByteCount(
@ -633,7 +633,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void takeUntilByteCountCanceled(String displayName, DataBufferFactory bufferFactory) {
void takeUntilByteCountCanceled(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> source = Flux.concat(
@ -650,7 +650,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void takeUntilByteCountError(String displayName, DataBufferFactory bufferFactory) {
void takeUntilByteCountError(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> source = Flux.concat(
@ -667,7 +667,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void takeUntilByteCountExact(String displayName, DataBufferFactory bufferFactory) {
void takeUntilByteCountExact(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> source = Flux.concat(
@ -686,7 +686,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void skipUntilByteCount(String displayName, DataBufferFactory bufferFactory) {
void skipUntilByteCount(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> source = Flux.concat(
@ -704,7 +704,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void skipUntilByteCountCancelled(String displayName, DataBufferFactory bufferFactory) {
void skipUntilByteCountCancelled(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> source = Flux.concat(
@ -720,7 +720,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void skipUntilByteCountErrorInFlux(String displayName, DataBufferFactory bufferFactory) {
void skipUntilByteCountErrorInFlux(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -734,7 +734,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void skipUntilByteCountShouldSkipAll(String displayName, DataBufferFactory bufferFactory) {
void skipUntilByteCountShouldSkipAll(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -749,7 +749,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void releaseConsumer(String displayName, DataBufferFactory bufferFactory) {
void releaseConsumer(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -772,7 +772,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void SPR16070(String displayName, DataBufferFactory bufferFactory) throws Exception {
void SPR16070(String displayName, DataBufferFactory bufferFactory) throws Exception {
super.bufferFactory = bufferFactory;
ReadableByteChannel channel = mock(ReadableByteChannel.class);
@ -803,7 +803,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void join(String displayName, DataBufferFactory bufferFactory) {
void join(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -821,7 +821,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void joinErrors(String displayName, DataBufferFactory bufferFactory) {
void joinErrors(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -835,7 +835,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void joinCanceled(String displayName, DataBufferFactory bufferFactory) {
void joinCanceled(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
Flux<DataBuffer> source = Flux.concat(
@ -851,7 +851,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void matcher(String displayName, DataBufferFactory bufferFactory) {
void matcher(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("foo");
@ -869,7 +869,7 @@ class DataBufferUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void matcher2(String displayName, DataBufferFactory bufferFactory) {
void matcher2(String displayName, DataBufferFactory bufferFactory) {
super.bufferFactory = bufferFactory;
DataBuffer foo = stringBuffer("fooobar");

View File

@ -30,7 +30,7 @@ class LeakAwareDataBufferFactoryTests {
@Test
public void leak() {
void leak() {
DataBuffer dataBuffer = this.bufferFactory.allocateBuffer();
try {
assertThatExceptionOfType(AssertionError.class).isThrownBy(
@ -42,7 +42,7 @@ class LeakAwareDataBufferFactoryTests {
}
@Test
public void noLeak() {
void noLeak() {
DataBuffer dataBuffer = this.bufferFactory.allocateBuffer();
release(dataBuffer);
this.bufferFactory.checkForLeaks();

View File

@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class DataBufferTestUtilsTests extends AbstractDataBufferAllocatingTests {
@ParameterizedDataBufferAllocatingTest
public void dumpBytes(String displayName, DataBufferFactory bufferFactory) {
void dumpBytes(String displayName, DataBufferFactory bufferFactory) {
this.bufferFactory = bufferFactory;
DataBuffer buffer = this.bufferFactory.allocateBuffer(4);
@ -46,7 +46,7 @@ class DataBufferTestUtilsTests extends AbstractDataBufferAllocatingTests {
}
@ParameterizedDataBufferAllocatingTest
public void dumpString(String displayName, DataBufferFactory bufferFactory) {
void dumpString(String displayName, DataBufferFactory bufferFactory) {
this.bufferFactory = bufferFactory;
DataBuffer buffer = this.bufferFactory.allocateBuffer(4);

View File

@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 3.2.14
*/
public class EncodedResourceTests {
class EncodedResourceTests {
private static final String UTF8 = "UTF-8";
private static final String UTF16 = "UTF-16";
@ -42,40 +42,40 @@ public class EncodedResourceTests {
@Test
public void equalsWithNullOtherObject() {
void equalsWithNullOtherObject() {
assertThat(new EncodedResource(resource).equals(null)).isFalse();
}
@Test
public void equalsWithSameEncoding() {
void equalsWithSameEncoding() {
EncodedResource er1 = new EncodedResource(resource, UTF8);
EncodedResource er2 = new EncodedResource(resource, UTF8);
assertThat(er2).isEqualTo(er1);
}
@Test
public void equalsWithDifferentEncoding() {
void equalsWithDifferentEncoding() {
EncodedResource er1 = new EncodedResource(resource, UTF8);
EncodedResource er2 = new EncodedResource(resource, UTF16);
assertThat(er2).isNotEqualTo(er1);
}
@Test
public void equalsWithSameCharset() {
void equalsWithSameCharset() {
EncodedResource er1 = new EncodedResource(resource, UTF8_CS);
EncodedResource er2 = new EncodedResource(resource, UTF8_CS);
assertThat(er2).isEqualTo(er1);
}
@Test
public void equalsWithDifferentCharset() {
void equalsWithDifferentCharset() {
EncodedResource er1 = new EncodedResource(resource, UTF8_CS);
EncodedResource er2 = new EncodedResource(resource, UTF16_CS);
assertThat(er2).isNotEqualTo(er1);
}
@Test
public void equalsWithEncodingAndCharset() {
void equalsWithEncodingAndCharset() {
EncodedResource er1 = new EncodedResource(resource, UTF8);
EncodedResource er2 = new EncodedResource(resource, UTF8_CS);
assertThat(er2).isNotEqualTo(er1);

View File

@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Sam Brannen
* @since 17.11.2004
*/
public class PathMatchingResourcePatternResolverTests {
class PathMatchingResourcePatternResolverTests {
private static final String[] CLASSES_IN_CORE_IO_SUPPORT =
new String[] {"EncodedResource.class", "LocalizedResourceHelper.class",
@ -59,13 +59,13 @@ public class PathMatchingResourcePatternResolverTests {
@Test
public void invalidPrefixWithPatternElementInIt() throws IOException {
void invalidPrefixWithPatternElementInIt() throws IOException {
assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(() ->
resolver.getResources("xx**:**/*.xy"));
}
@Test
public void singleResourceOnFileSystem() throws IOException {
void singleResourceOnFileSystem() throws IOException {
Resource[] resources =
resolver.getResources("org/springframework/core/io/support/PathMatchingResourcePatternResolverTests.class");
assertThat(resources.length).isEqualTo(1);
@ -73,7 +73,7 @@ public class PathMatchingResourcePatternResolverTests {
}
@Test
public void singleResourceInJar() throws IOException {
void singleResourceInJar() throws IOException {
Resource[] resources = resolver.getResources("org/reactivestreams/Publisher.class");
assertThat(resources.length).isEqualTo(1);
assertProtocolAndFilenames(resources, "jar", "Publisher.class");
@ -81,7 +81,7 @@ public class PathMatchingResourcePatternResolverTests {
@Disabled
@Test
public void classpathStarWithPatternOnFileSystem() throws IOException {
void classpathStarWithPatternOnFileSystem() throws IOException {
Resource[] resources = resolver.getResources("classpath*:org/springframework/core/io/sup*/*.class");
// Have to exclude Clover-generated class files here,
// as we might be running as part of a Clover test run.
@ -97,19 +97,19 @@ public class PathMatchingResourcePatternResolverTests {
}
@Test
public void classpathWithPatternInJar() throws IOException {
void classpathWithPatternInJar() throws IOException {
Resource[] resources = resolver.getResources("classpath:org/reactivestreams/*.class");
assertProtocolAndFilenames(resources, "jar", CLASSES_IN_REACTIVESTREAMS);
}
@Test
public void classpathStarWithPatternInJar() throws IOException {
void classpathStarWithPatternInJar() throws IOException {
Resource[] resources = resolver.getResources("classpath*:org/reactivestreams/*.class");
assertProtocolAndFilenames(resources, "jar", CLASSES_IN_REACTIVESTREAMS);
}
@Test
public void rootPatternRetrievalInJarFiles() throws IOException {
void rootPatternRetrievalInJarFiles() throws IOException {
Resource[] resources = resolver.getResources("classpath*:*.dtd");
boolean found = false;
for (Resource resource : resources) {

View File

@ -30,10 +30,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Dave Syer
* @author Juergen Hoeller
*/
public class ResourceArrayPropertyEditorTests {
class ResourceArrayPropertyEditorTests {
@Test
public void testVanillaResource() {
void vanillaResource() {
PropertyEditor editor = new ResourceArrayPropertyEditor();
editor.setAsText("classpath:org/springframework/core/io/support/ResourceArrayPropertyEditor.class");
Resource[] resources = (Resource[]) editor.getValue();
@ -42,7 +42,7 @@ public class ResourceArrayPropertyEditorTests {
}
@Test
public void testPatternResource() {
void patternResource() {
// N.B. this will sometimes fail if you use classpath: instead of classpath*:.
// The result depends on the classpath - if test-classes are segregated from classes
// and they come first on the classpath (like in Maven) then it breaks, if classes
@ -55,7 +55,7 @@ public class ResourceArrayPropertyEditorTests {
}
@Test
public void testSystemPropertyReplacement() {
void systemPropertyReplacement() {
PropertyEditor editor = new ResourceArrayPropertyEditor();
System.setProperty("test.prop", "foo");
try {
@ -69,7 +69,7 @@ public class ResourceArrayPropertyEditorTests {
}
@Test
public void testStrictSystemPropertyReplacementWithUnresolvablePlaceholder() {
void strictSystemPropertyReplacementWithUnresolvablePlaceholder() {
PropertyEditor editor = new ResourceArrayPropertyEditor(
new PathMatchingResourcePatternResolver(), new StandardEnvironment(),
false);

View File

@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 3.1
*/
public class ResourcePropertySourceTests {
class ResourcePropertySourceTests {
private static final String PROPERTIES_PATH = "org/springframework/core/io/example.properties";
private static final String PROPERTIES_LOCATION = "classpath:" + PROPERTIES_PATH;
@ -44,56 +44,56 @@ public class ResourcePropertySourceTests {
private static final String XML_PROPERTIES_RESOURCE_DESCRIPTION = "class path resource [" + XML_PROPERTIES_PATH + "]";
@Test
public void withLocationAndGeneratedName() throws IOException {
void withLocationAndGeneratedName() throws IOException {
PropertySource<?> ps = new ResourcePropertySource(PROPERTIES_LOCATION);
assertThat(ps.getProperty("foo")).isEqualTo("bar");
assertThat(ps.getName()).isEqualTo(PROPERTIES_RESOURCE_DESCRIPTION);
}
@Test
public void xmlWithLocationAndGeneratedName() throws IOException {
void xmlWithLocationAndGeneratedName() throws IOException {
PropertySource<?> ps = new ResourcePropertySource(XML_PROPERTIES_LOCATION);
assertThat(ps.getProperty("foo")).isEqualTo("bar");
assertThat(ps.getName()).isEqualTo(XML_PROPERTIES_RESOURCE_DESCRIPTION);
}
@Test
public void withLocationAndExplicitName() throws IOException {
void withLocationAndExplicitName() throws IOException {
PropertySource<?> ps = new ResourcePropertySource("ps1", PROPERTIES_LOCATION);
assertThat(ps.getProperty("foo")).isEqualTo("bar");
assertThat(ps.getName()).isEqualTo("ps1");
}
@Test
public void withLocationAndExplicitNameAndExplicitClassLoader() throws IOException {
void withLocationAndExplicitNameAndExplicitClassLoader() throws IOException {
PropertySource<?> ps = new ResourcePropertySource("ps1", PROPERTIES_LOCATION, getClass().getClassLoader());
assertThat(ps.getProperty("foo")).isEqualTo("bar");
assertThat(ps.getName()).isEqualTo("ps1");
}
@Test
public void withLocationAndGeneratedNameAndExplicitClassLoader() throws IOException {
void withLocationAndGeneratedNameAndExplicitClassLoader() throws IOException {
PropertySource<?> ps = new ResourcePropertySource(PROPERTIES_LOCATION, getClass().getClassLoader());
assertThat(ps.getProperty("foo")).isEqualTo("bar");
assertThat(ps.getName()).isEqualTo(PROPERTIES_RESOURCE_DESCRIPTION);
}
@Test
public void withResourceAndGeneratedName() throws IOException {
void withResourceAndGeneratedName() throws IOException {
PropertySource<?> ps = new ResourcePropertySource(new ClassPathResource(PROPERTIES_PATH));
assertThat(ps.getProperty("foo")).isEqualTo("bar");
assertThat(ps.getName()).isEqualTo(PROPERTIES_RESOURCE_DESCRIPTION);
}
@Test
public void withResourceAndExplicitName() throws IOException {
void withResourceAndExplicitName() throws IOException {
PropertySource<?> ps = new ResourcePropertySource("ps1", new ClassPathResource(PROPERTIES_PATH));
assertThat(ps.getProperty("foo")).isEqualTo("bar");
assertThat(ps.getName()).isEqualTo("ps1");
}
@Test
public void withResourceHavingNoDescription() throws IOException {
void withResourceHavingNoDescription() throws IOException {
PropertySource<?> ps = new ResourcePropertySource(new ByteArrayResource("foo=bar".getBytes(), ""));
assertThat(ps.getProperty("foo")).isEqualTo("bar");
assertThat(ps.getName()).isEqualTo("Byte array resource []");

View File

@ -28,22 +28,22 @@ import static org.mockito.Mockito.mock;
*
* @author Brian Clozel
*/
public class ResourceRegionTests {
class ResourceRegionTests {
@Test
public void shouldThrowExceptionWithNullResource() {
void shouldThrowExceptionWithNullResource() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ResourceRegion(null, 0, 1));
}
@Test
public void shouldThrowExceptionForNegativePosition() {
void shouldThrowExceptionForNegativePosition() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ResourceRegion(mock(Resource.class), -1, 1));
}
@Test
public void shouldThrowExceptionForNegativeCount() {
void shouldThrowExceptionForNegativeCount() {
assertThatIllegalArgumentException().isThrownBy(() ->
new ResourceRegion(mock(Resource.class), 0, -1));
}

View File

@ -31,10 +31,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* @author Phillip Webb
* @author Sam Brannen
*/
public class SpringFactoriesLoaderTests {
class SpringFactoriesLoaderTests {
@Test
public void loadFactoriesInCorrectOrder() {
void loadFactoriesInCorrectOrder() {
List<DummyFactory> factories = SpringFactoriesLoader.loadFactories(DummyFactory.class, null);
assertThat(factories.size()).isEqualTo(2);
boolean condition1 = factories.get(0) instanceof MyDummyFactory1;
@ -44,7 +44,7 @@ public class SpringFactoriesLoaderTests {
}
@Test
public void loadPackagePrivateFactory() {
void loadPackagePrivateFactory() {
List<DummyPackagePrivateFactory> factories =
SpringFactoriesLoader.loadFactories(DummyPackagePrivateFactory.class, null);
assertThat(factories.size()).isEqualTo(1);
@ -52,7 +52,7 @@ public class SpringFactoriesLoaderTests {
}
@Test
public void attemptToLoadFactoryOfIncompatibleType() {
void attemptToLoadFactoryOfIncompatibleType() {
assertThatIllegalArgumentException().isThrownBy(() ->
SpringFactoriesLoader.loadFactories(String.class, null))
.withMessageContaining("Unable to instantiate factory class "

View File

@ -24,45 +24,45 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Juergen Hoeller
* @since 5.2
*/
public class LogSupportTests {
class LogSupportTests {
@Test
public void testLogMessageWithSupplier() {
void logMessageWithSupplier() {
LogMessage msg = LogMessage.of(() -> new StringBuilder("a").append(" b"));
assertThat(msg.toString()).isEqualTo("a b");
assertThat(msg.toString()).isSameAs(msg.toString());
}
@Test
public void testLogMessageWithFormat1() {
void logMessageWithFormat1() {
LogMessage msg = LogMessage.format("a %s", "b");
assertThat(msg.toString()).isEqualTo("a b");
assertThat(msg.toString()).isSameAs(msg.toString());
}
@Test
public void testLogMessageWithFormat2() {
void logMessageWithFormat2() {
LogMessage msg = LogMessage.format("a %s %s", "b", "c");
assertThat(msg.toString()).isEqualTo("a b c");
assertThat(msg.toString()).isSameAs(msg.toString());
}
@Test
public void testLogMessageWithFormat3() {
void logMessageWithFormat3() {
LogMessage msg = LogMessage.format("a %s %s %s", "b", "c", "d");
assertThat(msg.toString()).isEqualTo("a b c d");
assertThat(msg.toString()).isSameAs(msg.toString());
}
@Test
public void testLogMessageWithFormat4() {
void logMessageWithFormat4() {
LogMessage msg = LogMessage.format("a %s %s %s %s", "b", "c", "d", "e");
assertThat(msg.toString()).isEqualTo("a b c d e");
assertThat(msg.toString()).isSameAs(msg.toString());
}
@Test
public void testLogMessageWithFormatX() {
void logMessageWithFormatX() {
LogMessage msg = LogMessage.format("a %s %s %s %s %s", "b", "c", "d", "e", "f");
assertThat(msg.toString()).isEqualTo("a b c d e f");
assertThat(msg.toString()).isSameAs(msg.toString());

View File

@ -33,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Mark Fisher
* @since 3.0.5
*/
public class SerializationConverterTests {
class SerializationConverterTests {
@Test
public void serializeAndDeserializeString() {
void serializeAndDeserializeString() {
SerializingConverter toBytes = new SerializingConverter();
byte[] bytes = toBytes.convert("Testing");
DeserializingConverter fromBytes = new DeserializingConverter();
@ -44,7 +44,7 @@ public class SerializationConverterTests {
}
@Test
public void nonSerializableObject() {
void nonSerializableObject() {
SerializingConverter toBytes = new SerializingConverter();
assertThatExceptionOfType(SerializationFailedException.class).isThrownBy(() ->
toBytes.convert(new Object()))
@ -52,7 +52,7 @@ public class SerializationConverterTests {
}
@Test
public void nonSerializableField() {
void nonSerializableField() {
SerializingConverter toBytes = new SerializingConverter();
assertThatExceptionOfType(SerializationFailedException.class).isThrownBy(() ->
toBytes.convert(new UnSerializable()))
@ -60,7 +60,7 @@ public class SerializationConverterTests {
}
@Test
public void deserializationFailure() {
void deserializationFailure() {
DeserializingConverter fromBytes = new DeserializingConverter();
assertThatExceptionOfType(SerializationFailedException.class).isThrownBy(() ->
fromBytes.convert("Junk".getBytes()));

View File

@ -33,13 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @since 5.2
*/
public class DefaultValueStylerTests {
class DefaultValueStylerTests {
private final DefaultValueStyler styler = new DefaultValueStyler();
@Test
public void styleBasics() throws NoSuchMethodException {
void styleBasics() throws NoSuchMethodException {
assertThat(styler.style(null)).isEqualTo("[null]");
assertThat(styler.style("str")).isEqualTo("'str'");
assertThat(styler.style(String.class)).isEqualTo("String");
@ -47,14 +47,14 @@ public class DefaultValueStylerTests {
}
@Test
public void stylePlainObject() {
void stylePlainObject() {
Object obj = new Object();
assertThat(styler.style(obj)).isEqualTo(String.valueOf(obj));
}
@Test
public void styleMaps() {
void styleMaps() {
Map<String, Integer> map = Collections.emptyMap();
assertThat(styler.style(map)).isEqualTo("map[[empty]]");
@ -68,7 +68,7 @@ public class DefaultValueStylerTests {
}
@Test
public void styleMapEntries() {
void styleMapEntries() {
Map<String, Integer> map = new LinkedHashMap<>();
map.put("key1", 1);
map.put("key2", 2);
@ -80,7 +80,7 @@ public class DefaultValueStylerTests {
}
@Test
public void styleCollections() {
void styleCollections() {
List<Integer> list = Collections.emptyList();
assertThat(styler.style(list)).isEqualTo("list[[empty]]");
@ -92,7 +92,7 @@ public class DefaultValueStylerTests {
}
@Test
public void stylePrimitiveArrays() {
void stylePrimitiveArrays() {
int[] array = new int[0];
assertThat(styler.style(array)).isEqualTo("array<Object>[[empty]]");
@ -104,7 +104,7 @@ public class DefaultValueStylerTests {
}
@Test
public void styleObjectArrays() {
void styleObjectArrays() {
String[] array = new String[0];
assertThat(styler.style(array)).isEqualTo("array<String>[[empty]]");

Some files were not shown because too many files have changed in this diff Show More