提交 fab96cad 编写于 作者: S Sam Brannen

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

See gh-23451
上级 cf1bf3d9
......@@ -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 {
}
}
......@@ -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 {
}
}
......@@ -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 {
}
}
/*
* 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 {
}
/*
* 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 {
}
......@@ -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();
......
......@@ -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);
}
......
......@@ -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));
}
......
......@@ -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));
}
......
......@@ -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";
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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";
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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();
......
......@@ -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);
......
......@@ -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");
......
......@@ -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");
......
......@@ -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();
......
......@@ -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);
}
}
......@@ -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");
......
......@@ -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);
......
......@@ -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");
......
......@@ -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();
......
......@@ -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(
......
......@@ -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,
......
......@@ -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());
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册