Introduce Checkstyle rule for separator symbol location
This commit is contained in:
@@ -71,8 +71,8 @@ class GeneratedFilesTests {
|
||||
TypeSpec helloWorld = TypeSpec.classBuilder("HelloWorld").build();
|
||||
JavaFile javaFile = JavaFile.builder("", helloWorld).build();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.generatedFiles.addSourceFile(javaFile))
|
||||
.withMessage("Could not add 'HelloWorld', processing classes in the "
|
||||
+ "default package is not supported. Did you forget to add a package statement?");
|
||||
.withMessage("Could not add 'HelloWorld', processing classes in the " +
|
||||
"default package is not supported. Did you forget to add a package statement?");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -92,8 +92,8 @@ class GeneratedFilesTests {
|
||||
void addSourceFileWithCharSequenceWhenClassNameIsInTheDefaultPackageThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.generatedFiles.addSourceFile("HelloWorld", "{}"))
|
||||
.withMessage("Could not add 'HelloWorld', processing classes in the "
|
||||
+ "default package is not supported. Did you forget to add a package statement?");
|
||||
.withMessage("Could not add 'HelloWorld', processing classes in the " +
|
||||
"default package is not supported. Did you forget to add a package statement?");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 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.
|
||||
@@ -64,20 +64,17 @@ import static org.mockito.Mockito.verifyNoInteractions;
|
||||
*/
|
||||
class ValueCodeGeneratorTests {
|
||||
|
||||
|
||||
@Nested
|
||||
class ConfigurationTests {
|
||||
|
||||
@Test
|
||||
void createWithListOfDelegatesInvokeThemInOrder() {
|
||||
Delegate first = mock(Delegate.class);
|
||||
Delegate second = mock(Delegate.class);
|
||||
Delegate third = mock(Delegate.class);
|
||||
ValueCodeGenerator codeGenerator = ValueCodeGenerator
|
||||
.with(List.of(first, second, third));
|
||||
Delegate first = mock();
|
||||
Delegate second = mock();
|
||||
Delegate third = mock();
|
||||
ValueCodeGenerator codeGenerator = ValueCodeGenerator.with(List.of(first, second, third));
|
||||
Object value = "";
|
||||
given(third.generateCode(codeGenerator, value))
|
||||
.willReturn(CodeBlock.of("test"));
|
||||
given(third.generateCode(codeGenerator, value)).willReturn(CodeBlock.of("test"));
|
||||
CodeBlock code = codeGenerator.generateCode(value);
|
||||
assertThat(code).hasToString("test");
|
||||
InOrder ordered = inOrder(first, second, third);
|
||||
@@ -88,13 +85,11 @@ class ValueCodeGeneratorTests {
|
||||
|
||||
@Test
|
||||
void generateCodeWithMatchingDelegateStops() {
|
||||
Delegate first = mock(Delegate.class);
|
||||
Delegate second = mock(Delegate.class);
|
||||
ValueCodeGenerator codeGenerator = ValueCodeGenerator
|
||||
.with(List.of(first, second));
|
||||
Delegate first = mock();
|
||||
Delegate second = mock();
|
||||
ValueCodeGenerator codeGenerator = ValueCodeGenerator.with(List.of(first, second));
|
||||
Object value = "";
|
||||
given(first.generateCode(codeGenerator, value))
|
||||
.willReturn(CodeBlock.of("test"));
|
||||
given(first.generateCode(codeGenerator, value)).willReturn(CodeBlock.of("test"));
|
||||
CodeBlock code = codeGenerator.generateCode(value);
|
||||
assertThat(code).hasToString("test");
|
||||
verify(first).generateCode(codeGenerator, value);
|
||||
@@ -198,7 +193,6 @@ class ValueCodeGeneratorTests {
|
||||
assertThat(generateCode("test")).hasToString("\"test\"");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void generateWhenStringWithCarriageReturn() {
|
||||
assertThat(generateCode("test\n")).isEqualTo(CodeBlock.of("$S", "test\n"));
|
||||
@@ -285,9 +279,9 @@ class ValueCodeGeneratorTests {
|
||||
ResolvableType resolvableType = ResolvableType.forClassWithGenerics(Map.class,
|
||||
ResolvableType.forClass(Integer.class), stringList);
|
||||
assertThat(resolve(generateCode(resolvableType)))
|
||||
.hasImport(ResolvableType.class, List.class, Map.class).hasValueCode(
|
||||
"ResolvableType.forClassWithGenerics(Map.class, ResolvableType.forClass(Integer.class), "
|
||||
+ "ResolvableType.forClassWithGenerics(List.class, String.class))");
|
||||
.hasImport(ResolvableType.class, List.class, Map.class).hasValueCode("""
|
||||
ResolvableType.forClassWithGenerics(Map.class, ResolvableType.forClass(Integer.class), \
|
||||
ResolvableType.forClassWithGenerics(List.class, String.class))""");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -216,10 +216,10 @@ class ReflectionHintsTests {
|
||||
typeHint -> typeHint.withMembers(MemberCategory.INTROSPECT_PUBLIC_METHODS));
|
||||
assertThat(this.reflectionHints.typeHints()).hasSize(2)
|
||||
.noneMatch(typeHint -> typeHint.getType().getCanonicalName().equals(Serializable.class.getCanonicalName()))
|
||||
.anyMatch(typeHint -> typeHint.getType().getCanonicalName().equals(SecondInterface.class.getCanonicalName())
|
||||
&& typeHint.getMemberCategories().contains(MemberCategory.INTROSPECT_PUBLIC_METHODS))
|
||||
.anyMatch(typeHint -> typeHint.getType().getCanonicalName().equals(FirstInterface.class.getCanonicalName())
|
||||
&& typeHint.getMemberCategories().contains(MemberCategory.INTROSPECT_PUBLIC_METHODS));
|
||||
.anyMatch(typeHint -> typeHint.getType().getCanonicalName().equals(SecondInterface.class.getCanonicalName()) &&
|
||||
typeHint.getMemberCategories().contains(MemberCategory.INTROSPECT_PUBLIC_METHODS))
|
||||
.anyMatch(typeHint -> typeHint.getType().getCanonicalName().equals(FirstInterface.class.getCanonicalName()) &&
|
||||
typeHint.getMemberCategories().contains(MemberCategory.INTROSPECT_PUBLIC_METHODS));
|
||||
}
|
||||
|
||||
private void assertTestTypeMethodHints(Consumer<ExecutableHint> methodHint) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2025 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.
|
||||
@@ -54,27 +54,24 @@ class AnnotationTypeMappingsTests {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SimpleAnnotation.class);
|
||||
assertThat(mappings.size()).isEqualTo(1);
|
||||
assertThat(mappings.get(0).getAnnotationType()).isEqualTo(SimpleAnnotation.class);
|
||||
assertThat(getAll(mappings)).flatExtracting(
|
||||
AnnotationTypeMapping::getAnnotationType).containsExactly(SimpleAnnotation.class);
|
||||
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||
.containsExactly(SimpleAnnotation.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenMetaAnnotationsReturnsMappings() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MetaAnnotated.class);
|
||||
assertThat(mappings.size()).isEqualTo(6);
|
||||
assertThat(getAll(mappings)).flatExtracting(
|
||||
AnnotationTypeMapping::getAnnotationType).containsExactly(
|
||||
MetaAnnotated.class, A.class, B.class, AA.class, AB.class,
|
||||
ABC.class);
|
||||
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||
.containsExactly(MetaAnnotated.class, A.class, B.class, AA.class, AB.class, ABC.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenHasRepeatingMetaAnnotationReturnsMapping() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(WithRepeatedMetaAnnotations.class);
|
||||
assertThat(mappings.size()).isEqualTo(3);
|
||||
assertThat(getAll(mappings)).flatExtracting(
|
||||
AnnotationTypeMapping::getAnnotationType).containsExactly(
|
||||
WithRepeatedMetaAnnotations.class, Repeating.class, Repeating.class);
|
||||
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||
.containsExactly(WithRepeatedMetaAnnotations.class, Repeating.class, Repeating.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,56 +86,52 @@ class AnnotationTypeMappingsTests {
|
||||
void forAnnotationTypeWhenSelfAnnotatedReturnsMapping() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(SelfAnnotated.class);
|
||||
assertThat(mappings.size()).isEqualTo(1);
|
||||
assertThat(getAll(mappings)).flatExtracting(
|
||||
AnnotationTypeMapping::getAnnotationType).containsExactly(SelfAnnotated.class);
|
||||
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||
.containsExactly(SelfAnnotated.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenFormsLoopReturnsMapping() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(LoopA.class);
|
||||
assertThat(mappings.size()).isEqualTo(2);
|
||||
assertThat(getAll(mappings)).flatExtracting(
|
||||
AnnotationTypeMapping::getAnnotationType).containsExactly(LoopA.class, LoopB.class);
|
||||
assertThat(getAll(mappings)).flatExtracting(AnnotationTypeMapping::getAnnotationType)
|
||||
.containsExactly(LoopA.class, LoopB.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenHasAliasForWithBothValueAndAttributeThrowsException() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasForWithBothValueAndAttribute.class))
|
||||
.withMessage("In @AliasFor declared on attribute 'test' in annotation ["
|
||||
+ AliasForWithBothValueAndAttribute.class.getName()
|
||||
+ "], attribute 'attribute' and its alias 'value' are present with values of 'foo' and 'bar', but only one is permitted.");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForWithBothValueAndAttribute.class))
|
||||
.withMessage("In @AliasFor declared on attribute 'test' in annotation [%s], attribute 'attribute' " +
|
||||
"and its alias 'value' are present with values of 'foo' and 'bar', but only one is permitted.",
|
||||
AliasForWithBothValueAndAttribute.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenAliasForToSelfNonExistingAttribute() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonExistingAttribute.class))
|
||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
|
||||
+ AliasForToSelfNonExistingAttribute.class.getName()
|
||||
+ "] declares an alias for 'missing' which is not present.");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonExistingAttribute.class))
|
||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation [%s] " +
|
||||
"declares an alias for 'missing' which is not present.",
|
||||
AliasForToSelfNonExistingAttribute.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenAliasForToOtherNonExistingAttribute() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasForToOtherNonExistingAttribute.class))
|
||||
.withMessage("Attribute 'test' in annotation ["
|
||||
+ AliasForToOtherNonExistingAttribute.class.getName()
|
||||
+ "] is declared as an @AliasFor nonexistent "
|
||||
+ "attribute 'missing' in annotation ["
|
||||
+ AliasForToOtherNonExistingAttributeTarget.class.getName()
|
||||
+ "].");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToOtherNonExistingAttribute.class))
|
||||
.withMessage("Attribute 'test' in annotation [%s] is declared as an @AliasFor nonexistent " +
|
||||
"attribute 'missing' in annotation [%s].", AliasForToOtherNonExistingAttribute.class.getName(),
|
||||
AliasForToOtherNonExistingAttributeTarget.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenAliasForToSelf() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasForToSelf.class))
|
||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
|
||||
+ AliasForToSelf.class.getName()
|
||||
+ "] points to itself. Specify 'annotation' to point to "
|
||||
+ "a same-named attribute on a meta-annotation.");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelf.class))
|
||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation [%s] points to itself. " +
|
||||
"Specify 'annotation' to point to a same-named attribute on a meta-annotation.",
|
||||
AliasForToSelf.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -152,13 +145,12 @@ class AnnotationTypeMappingsTests {
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasForWithIncompatibleReturnTypes.class))
|
||||
.withMessage("Misconfigured aliases: attribute 'test' in annotation ["
|
||||
+ AliasForWithIncompatibleReturnTypes.class.getName()
|
||||
+ "] and attribute 'test' in annotation ["
|
||||
+ AliasForWithIncompatibleReturnTypesTarget.class.getName()
|
||||
+ "] must declare the same return type.");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForWithIncompatibleReturnTypes.class))
|
||||
.withMessage("Misconfigured aliases: attribute 'test' in annotation [%s] and attribute 'test' " +
|
||||
"in annotation [%s] must declare the same return type.",
|
||||
AliasForWithIncompatibleReturnTypes.class.getName(),
|
||||
AliasForWithIncompatibleReturnTypesTarget.class.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -166,9 +158,8 @@ class AnnotationTypeMappingsTests {
|
||||
String annotationType = AliasForToSelfAnnotatedToOtherAttribute.class.getName();
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForToSelfAnnotatedToOtherAttribute.class))
|
||||
.withMessage("Attribute 'b' in annotation [" + annotationType
|
||||
+ "] must be declared as an @AliasFor attribute 'a' in annotation [" + annotationType
|
||||
+ "], not attribute 'c' in annotation [" + annotationType + "].");
|
||||
.withMessage("Attribute 'b' in annotation [%1$s] must be declared as an @AliasFor attribute 'a' in " +
|
||||
"annotation [%1$s], not attribute 'c' in annotation [%1$s].", annotationType);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -182,53 +173,45 @@ class AnnotationTypeMappingsTests {
|
||||
String metaAnnotationName = AliasPair.class.getName();
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(annotationType))
|
||||
.withMessage("Attribute 'b' in annotation [" + annotationName
|
||||
+ "] must be declared as an @AliasFor attribute 'a' in annotation [" + annotationName
|
||||
+ "], not attribute '" + overriddenAttribute + "' in annotation [" + metaAnnotationName + "].");
|
||||
.withMessage("Attribute 'b' in annotation [" + annotationName +
|
||||
"] must be declared as an @AliasFor attribute 'a' in annotation [" + annotationName +
|
||||
"], not attribute '" + overriddenAttribute + "' in annotation [" + metaAnnotationName + "].");
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenAliasForNonMetaAnnotated() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasForNonMetaAnnotated.class))
|
||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation ["
|
||||
+ AliasForNonMetaAnnotated.class.getName()
|
||||
+ "] declares an alias for attribute 'test' in annotation ["
|
||||
+ AliasForNonMetaAnnotatedTarget.class.getName()
|
||||
+ "] which is not meta-present.");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForNonMetaAnnotated.class))
|
||||
.withMessage("@AliasFor declaration on attribute 'test' in annotation [" + AliasForNonMetaAnnotated.class.getName() +
|
||||
"] declares an alias for attribute 'test' in annotation [" + AliasForNonMetaAnnotatedTarget.class.getName() +
|
||||
"] which is not meta-present.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenAliasForSelfWithDifferentDefaults() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasForSelfWithDifferentDefaults.class))
|
||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
|
||||
+ AliasForSelfWithDifferentDefaults.class.getName()
|
||||
+ "] and attribute 'b' in annotation ["
|
||||
+ AliasForSelfWithDifferentDefaults.class.getName()
|
||||
+ "] must declare the same default value.");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForSelfWithDifferentDefaults.class))
|
||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation [" + AliasForSelfWithDifferentDefaults.class.getName() +
|
||||
"] and attribute 'b' in annotation [" + AliasForSelfWithDifferentDefaults.class.getName() +
|
||||
"] must declare the same default value.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenAliasForSelfWithMissingDefault() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasForSelfWithMissingDefault.class))
|
||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
|
||||
+ AliasForSelfWithMissingDefault.class.getName()
|
||||
+ "] and attribute 'b' in annotation ["
|
||||
+ AliasForSelfWithMissingDefault.class.getName()
|
||||
+ "] must declare default values.");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasForSelfWithMissingDefault.class))
|
||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation [" + AliasForSelfWithMissingDefault.class.getName() +
|
||||
"] and attribute 'b' in annotation [" + AliasForSelfWithMissingDefault.class.getName() +
|
||||
"] must declare default values.");
|
||||
}
|
||||
|
||||
@Test
|
||||
void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() {
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
AnnotationTypeMappings.forAnnotationType(AliasWithExplicitMirrorAndDifferentDefaults.class))
|
||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation ["
|
||||
+ AliasWithExplicitMirrorAndDifferentDefaults.class.getName()
|
||||
+ "] and attribute 'c' in annotation ["
|
||||
+ AliasWithExplicitMirrorAndDifferentDefaults.class.getName()
|
||||
+ "] must declare the same default value.");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> AnnotationTypeMappings.forAnnotationType(AliasWithExplicitMirrorAndDifferentDefaults.class))
|
||||
.withMessage("Misconfigured aliases: attribute 'a' in annotation [" + AliasWithExplicitMirrorAndDifferentDefaults.class.getName() +
|
||||
"] and attribute 'c' in annotation [" + AliasWithExplicitMirrorAndDifferentDefaults.class.getName() +
|
||||
"] must declare the same default value.");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -375,18 +358,16 @@ class AnnotationTypeMappingsTests {
|
||||
@Test
|
||||
void resolveMirrorsWhenHasDifferentValuesThrowsException() {
|
||||
AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType(AliasPair.class).get(0);
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
|
||||
resolveMirrorSets(mapping, WithDifferentValueAliasPair.class, AliasPair.class))
|
||||
.withMessage("Different @AliasFor mirror values for annotation ["
|
||||
+ AliasPair.class.getName() + "] declared on "
|
||||
+ WithDifferentValueAliasPair.class.getName()
|
||||
+ "; attribute 'a' and its alias 'b' are declared with values of [test1] and [test2].");
|
||||
assertThatExceptionOfType(AnnotationConfigurationException.class)
|
||||
.isThrownBy(() -> resolveMirrorSets(mapping, WithDifferentValueAliasPair.class, AliasPair.class))
|
||||
.withMessage("Different @AliasFor mirror values for annotation [" + AliasPair.class.getName() + "] declared on " +
|
||||
WithDifferentValueAliasPair.class.getName() +
|
||||
"; attribute 'a' and its alias 'b' are declared with values of [test1] and [test2].");
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveMirrorsWhenHasWithMultipleRoutesToAliasReturnsMirrors() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
|
||||
MultipleRoutesToAliasA.class);
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MultipleRoutesToAliasA.class);
|
||||
AnnotationTypeMapping mappingsA = getMapping(mappings, MultipleRoutesToAliasA.class);
|
||||
assertThat(mappingsA.getMirrorSets().size()).isZero();
|
||||
AnnotationTypeMapping mappingsB = getMapping(mappings, MultipleRoutesToAliasB.class);
|
||||
@@ -397,8 +378,7 @@ class AnnotationTypeMappingsTests {
|
||||
|
||||
@Test
|
||||
void getAliasMappingWhenHasWithMultipleRoutesToAliasReturnsMappedAttributes() {
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(
|
||||
MultipleRoutesToAliasA.class);
|
||||
AnnotationTypeMappings mappings = AnnotationTypeMappings.forAnnotationType(MultipleRoutesToAliasA.class);
|
||||
AnnotationTypeMapping mappingsA = getMapping(mappings, MultipleRoutesToAliasA.class);
|
||||
assertThat(getAliasMapping(mappingsA, 0)).isNull();
|
||||
AnnotationTypeMapping mappingsB = getMapping(mappings, MultipleRoutesToAliasB.class);
|
||||
|
||||
@@ -925,8 +925,8 @@ class AnnotationUtilsTests {
|
||||
Map<String, Object> map = Collections.singletonMap(VALUE, 42L);
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
synthesizeAnnotation(map, Component.class, null).value())
|
||||
.withMessageContaining("Attribute 'value' in annotation org.springframework.core.testfixture.stereotype.Component "
|
||||
+ "should be compatible with java.lang.String but a java.lang.Long value was returned");
|
||||
.withMessageContaining("Attribute 'value' in annotation org.springframework.core.testfixture.stereotype.Component " +
|
||||
"should be compatible with java.lang.String but a java.lang.Long value was returned");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -120,9 +120,7 @@ class MergedAnnotationClassLoaderTests {
|
||||
|
||||
@Override
|
||||
protected boolean isEligibleForOverriding(String className) {
|
||||
return WITH_TEST_ANNOTATION.equals(className)
|
||||
|| TEST_ANNOTATION.equals(className)
|
||||
|| TEST_REFERENCE.equals(className);
|
||||
return WITH_TEST_ANNOTATION.equals(className) || TEST_ANNOTATION.equals(className) || TEST_REFERENCE.equals(className);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -171,8 +171,7 @@ class MergedAnnotationsCollectionTests {
|
||||
void getWithSelectorReturnsSelected() {
|
||||
MergedAnnotations annotations = getMultiRoute1();
|
||||
MergedAnnotationSelector<MultiRouteTarget> deepest = (existing,
|
||||
candidate) -> candidate.getDistance() > existing.getDistance() ? candidate
|
||||
: existing;
|
||||
candidate) -> candidate.getDistance() > existing.getDistance() ? candidate : existing;
|
||||
assertThat(annotations.get(MultiRouteTarget.class, null, deepest).getString(
|
||||
MergedAnnotation.VALUE)).isEqualTo("111");
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ class SpringFactoriesLoaderTests {
|
||||
void loadWhenIncompatibleTypeThrowsException() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> SpringFactoriesLoader.forDefaultResourceLocation().load(String.class))
|
||||
.withMessageContaining("Unable to instantiate factory class "
|
||||
+ "[org.springframework.core.io.support.MyDummyFactory1] for factory type [java.lang.String]");
|
||||
.withMessageContaining("Unable to instantiate factory class " +
|
||||
"[org.springframework.core.io.support.MyDummyFactory1] for factory type [java.lang.String]");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -127,8 +127,8 @@ class SpringFactoriesLoaderTests {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> SpringFactoriesLoader.forDefaultResourceLocation(LimitedClassLoader.multipleArgumentFactories)
|
||||
.load(DummyFactory.class, resolver))
|
||||
.withMessageContaining("Unable to instantiate factory class "
|
||||
+ "[org.springframework.core.io.support.MultipleConstructorArgsDummyFactory] for factory type [org.springframework.core.io.support.DummyFactory]")
|
||||
.withMessageContaining("Unable to instantiate factory class " +
|
||||
"[org.springframework.core.io.support.MultipleConstructorArgsDummyFactory] for factory type [org.springframework.core.io.support.DummyFactory]")
|
||||
.havingRootCause().withMessageContaining("Class [org.springframework.core.io.support.MultipleConstructorArgsDummyFactory] has no suitable constructor");
|
||||
}
|
||||
|
||||
|
||||
@@ -218,8 +218,8 @@ abstract class AbstractStaxXMLReaderTests {
|
||||
|
||||
@Override
|
||||
public Object[] adaptArguments(Object[] arguments) {
|
||||
if (arguments.length == 3 && arguments[0] instanceof char[]
|
||||
&& arguments[1] instanceof Integer && arguments[2] instanceof Integer) {
|
||||
if (arguments.length == 3 && arguments[0] instanceof char[] &&
|
||||
arguments[1] instanceof Integer && arguments[2] instanceof Integer) {
|
||||
return new Object[] {new String((char[]) arguments[0], (Integer) arguments[1], (Integer) arguments[2])};
|
||||
}
|
||||
return arguments;
|
||||
@@ -271,10 +271,10 @@ abstract class AbstractStaxXMLReaderTests {
|
||||
for (int i = 0; i < other.getLength(); i++) {
|
||||
boolean found = false;
|
||||
for (int j = 0; j < attributes.getLength(); j++) {
|
||||
if (other.getURI(i).equals(attributes.getURI(j))
|
||||
&& other.getQName(i).equals(attributes.getQName(j))
|
||||
&& other.getType(i).equals(attributes.getType(j))
|
||||
&& other.getValue(i).equals(attributes.getValue(j))) {
|
||||
if (other.getURI(i).equals(attributes.getURI(j)) &&
|
||||
other.getQName(i).equals(attributes.getQName(j)) &&
|
||||
other.getType(i).equals(attributes.getType(j)) &&
|
||||
other.getValue(i).equals(attributes.getValue(j))) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user