Reformat code using Eclipse Mars
This commit is contained in:
@@ -103,14 +103,12 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
public void simpleProperties() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata, containsGroup("simple").fromSource(SimpleProperties.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.the-name", String.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("The name of this simple properties.")
|
||||
.withDefaultValue(is("boot")).withDeprecation(null, null));
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.flag", Boolean.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("A simple flag.").withDeprecation(null, null));
|
||||
@@ -124,10 +122,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
ConfigurationMetadata metadata = compile(SimplePrefixValueProperties.class);
|
||||
assertThat(metadata,
|
||||
containsGroup("simple").fromSource(SimplePrefixValueProperties.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("simple.name", String.class).fromSource(
|
||||
SimplePrefixValueProperties.class));
|
||||
assertThat(metadata, containsProperty("simple.name", String.class)
|
||||
.fromSource(SimplePrefixValueProperties.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -195,77 +191,57 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
assertThat(metadata, containsGroup("singledeprecated").fromSource(type));
|
||||
assertThat(metadata, containsProperty("singledeprecated.new-name", String.class)
|
||||
.fromSource(type));
|
||||
assertThat(metadata, containsProperty("singledeprecated.name", String.class)
|
||||
.fromSource(type).withDeprecation("renamed", "singledeprecated.new-name"));
|
||||
assertThat(metadata,
|
||||
containsProperty("singledeprecated.name", String.class).fromSource(type)
|
||||
.withDeprecation("renamed", "singledeprecated.new-name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseCollectionConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(SimpleCollectionProperties.class);
|
||||
// getter and setter
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.integers-to-names",
|
||||
"java.util.Map<java.lang.Integer,java.lang.String>"));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.longs",
|
||||
"java.util.Collection<java.lang.Long>"));
|
||||
assertThat(metadata, containsProperty("collection.integers-to-names",
|
||||
"java.util.Map<java.lang.Integer,java.lang.String>"));
|
||||
assertThat(metadata, containsProperty("collection.longs",
|
||||
"java.util.Collection<java.lang.Long>"));
|
||||
assertThat(metadata,
|
||||
containsProperty("collection.floats", "java.util.List<java.lang.Float>"));
|
||||
// getter only
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.names-to-integers",
|
||||
"java.util.Map<java.lang.String,java.lang.Integer>"));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.bytes",
|
||||
"java.util.Collection<java.lang.Byte>"));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("collection.doubles", "java.util.List<java.lang.Double>"));
|
||||
assertThat(metadata, containsProperty("collection.names-to-integers",
|
||||
"java.util.Map<java.lang.String,java.lang.Integer>"));
|
||||
assertThat(metadata, containsProperty("collection.bytes",
|
||||
"java.util.Collection<java.lang.Byte>"));
|
||||
assertThat(metadata, containsProperty("collection.doubles",
|
||||
"java.util.List<java.lang.Double>"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleMethodConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(SimpleMethodConfig.class);
|
||||
assertThat(metadata, containsGroup("foo").fromSource(SimpleMethodConfig.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("foo.name", String.class).fromSource(
|
||||
SimpleMethodConfig.Foo.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("foo.flag", Boolean.class).fromSource(
|
||||
SimpleMethodConfig.Foo.class));
|
||||
assertThat(metadata, containsProperty("foo.name", String.class)
|
||||
.fromSource(SimpleMethodConfig.Foo.class));
|
||||
assertThat(metadata, containsProperty("foo.flag", Boolean.class)
|
||||
.fromSource(SimpleMethodConfig.Foo.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidMethodConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(InvalidMethodConfig.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("something.name", String.class).fromSource(
|
||||
InvalidMethodConfig.class));
|
||||
assertThat(metadata, containsProperty("something.name", String.class)
|
||||
.fromSource(InvalidMethodConfig.class));
|
||||
assertThat(metadata, not(containsProperty("invalid.name")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void methodAndClassConfig() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(MethodAndClassConfig.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("conflict.name", String.class).fromSource(
|
||||
MethodAndClassConfig.Foo.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("conflict.flag", Boolean.class).fromSource(
|
||||
MethodAndClassConfig.Foo.class));
|
||||
assertThat(
|
||||
metadata,
|
||||
containsProperty("conflict.value", String.class).fromSource(
|
||||
MethodAndClassConfig.class));
|
||||
assertThat(metadata, containsProperty("conflict.name", String.class)
|
||||
.fromSource(MethodAndClassConfig.Foo.class));
|
||||
assertThat(metadata, containsProperty("conflict.flag", Boolean.class)
|
||||
.fromSource(MethodAndClassConfig.Foo.class));
|
||||
assertThat(metadata, containsProperty("conflict.value", String.class)
|
||||
.fromSource(MethodAndClassConfig.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -342,7 +318,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
@Test
|
||||
public void lombokExplicitProperties() throws Exception {
|
||||
ConfigurationMetadata metadata = compile(LombokExplicitProperties.class);
|
||||
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class, "explicit");
|
||||
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class,
|
||||
"explicit");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -352,9 +329,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
writeAdditionalMetadata(property);
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata, containsProperty("simple.comparator"));
|
||||
assertThat(metadata,
|
||||
containsProperty("foo", String.class)
|
||||
.fromSource(AdditionalMetadata.class));
|
||||
assertThat(metadata, containsProperty("foo", String.class)
|
||||
.fromSource(AdditionalMetadata.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -363,8 +339,7 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
null, null, true, null);
|
||||
writeAdditionalMetadata(property);
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.flag", Boolean.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("A simple flag.").withDefaultValue(is(true)));
|
||||
@@ -377,41 +352,38 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
null, null, "A nice comparator.", null, null);
|
||||
writeAdditionalMetadata(property);
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.comparator", "java.util.Comparator<?>")
|
||||
.fromSource(SimpleProperties.class).withDescription(
|
||||
"A nice comparator."));
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("A nice comparator."));
|
||||
assertThat(metadata.getItems().size(), is(4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergeExistingPropertyDeprecation() throws Exception {
|
||||
ItemMetadata property = ItemMetadata.newProperty("simple", "comparator", null,
|
||||
null, null, null, null, new ItemDeprecation("Don't use this.",
|
||||
"simple.complex-comparator"));
|
||||
null, null, null, null,
|
||||
new ItemDeprecation("Don't use this.", "simple.complex-comparator"));
|
||||
writeAdditionalMetadata(property);
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.comparator", "java.util.Comparator<?>")
|
||||
.fromSource(SimpleProperties.class).withDeprecation(
|
||||
"Don't use this.", "simple.complex-comparator"));
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDeprecation("Don't use this.", "simple.complex-comparator"));
|
||||
assertThat(metadata.getItems().size(), is(4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergeExistingPropertyDeprecationOverride() throws Exception {
|
||||
ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name",
|
||||
null, null, null, null, null, new ItemDeprecation("Don't use this.",
|
||||
"single.name"));
|
||||
ItemMetadata property = ItemMetadata.newProperty("singledeprecated", "name", null,
|
||||
null, null, null, null,
|
||||
new ItemDeprecation("Don't use this.", "single.name"));
|
||||
writeAdditionalMetadata(property);
|
||||
ConfigurationMetadata metadata = compile(DeprecatedSingleProperty.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("singledeprecated.name", String.class.getName())
|
||||
.fromSource(DeprecatedSingleProperty.class).withDeprecation(
|
||||
"Don't use this.", "single.name"));
|
||||
.fromSource(DeprecatedSingleProperty.class)
|
||||
.withDeprecation("Don't use this.", "single.name"));
|
||||
assertThat(metadata.getItems().size(), is(3));
|
||||
}
|
||||
|
||||
@@ -427,27 +399,25 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
|
||||
@Test
|
||||
public void mergingOfSimpleHint() throws Exception {
|
||||
writeAdditionalHints(ItemHint.newHint("simple.the-name", new ItemHint.ValueHint(
|
||||
"boot", "Bla bla"), new ItemHint.ValueHint("spring", null)));
|
||||
writeAdditionalHints(ItemHint.newHint("simple.the-name",
|
||||
new ItemHint.ValueHint("boot", "Bla bla"),
|
||||
new ItemHint.ValueHint("spring", null)));
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.the-name", String.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("The name of this simple properties.")
|
||||
.withDefaultValue(is("boot")).withDeprecation(null, null));
|
||||
assertThat(metadata,
|
||||
containsHint("simple.the-name").withValue(0, "boot", "Bla bla")
|
||||
.withValue(1, "spring", null));
|
||||
assertThat(metadata, containsHint("simple.the-name")
|
||||
.withValue(0, "boot", "Bla bla").withValue(1, "spring", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergingOfHintWithNonCanonicalName() throws Exception {
|
||||
writeAdditionalHints(ItemHint.newHint("simple.theName", new ItemHint.ValueHint(
|
||||
"boot", "Bla bla")));
|
||||
writeAdditionalHints(ItemHint.newHint("simple.theName",
|
||||
new ItemHint.ValueHint("boot", "Bla bla")));
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.the-name", String.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("The name of this simple properties.")
|
||||
@@ -459,28 +429,27 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
@Test
|
||||
public void mergingOfHintWithProvider() throws Exception {
|
||||
writeAdditionalHints(new ItemHint("simple.theName",
|
||||
Collections.<ItemHint.ValueHint>emptyList(), Arrays.asList(
|
||||
new ItemHint.ValueProvider("first", Collections
|
||||
.<String, Object>singletonMap("target", "org.foo")),
|
||||
Collections.<ItemHint.ValueHint>emptyList(),
|
||||
Arrays.asList(
|
||||
new ItemHint.ValueProvider("first",
|
||||
Collections.<String, Object>singletonMap("target",
|
||||
"org.foo")),
|
||||
new ItemHint.ValueProvider("second", null))));
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(
|
||||
metadata,
|
||||
assertThat(metadata,
|
||||
containsProperty("simple.the-name", String.class)
|
||||
.fromSource(SimpleProperties.class)
|
||||
.withDescription("The name of this simple properties.")
|
||||
.withDefaultValue(is("boot")).withDeprecation(null, null));
|
||||
assertThat(metadata,
|
||||
containsHint("simple.the-name")
|
||||
.withProvider("first", "target", "org.foo")
|
||||
.withProvider("second"));
|
||||
assertThat(metadata, containsHint("simple.the-name")
|
||||
.withProvider("first", "target", "org.foo").withProvider("second"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergingOfAdditionalDeprecation() throws Exception {
|
||||
writePropertyDeprecation(ItemMetadata.newProperty("simple", "wrongName",
|
||||
"java.lang.String", null, null, null, null, new ItemDeprecation(
|
||||
"Lame name.", "simple.the-name")));
|
||||
"java.lang.String", null, null, null, null,
|
||||
new ItemDeprecation("Lame name.", "simple.the-name")));
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata, containsProperty("simple.wrong-name", String.class)
|
||||
.withDeprecation("Lame name.", "simple.the-name"));
|
||||
@@ -545,9 +514,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
containsProperty("foo.counter").fromSource(FooProperties.class));
|
||||
assertThat(metadata,
|
||||
containsProperty("bar.counter").fromSource(BarProperties.class));
|
||||
assertThat(metadata,
|
||||
not(containsProperty("bar.counter")
|
||||
.fromSource(RenamedBarProperties.class)));
|
||||
assertThat(metadata, not(
|
||||
containsProperty("bar.counter").fromSource(RenamedBarProperties.class)));
|
||||
|
||||
project.delete(BarProperties.class);
|
||||
project.add(RenamedBarProperties.class);
|
||||
@@ -564,9 +532,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
Class<?> source, String prefix) {
|
||||
assertThat(metadata, containsGroup(prefix).fromSource(source));
|
||||
assertThat(metadata, not(containsProperty(prefix + ".id")));
|
||||
assertThat(metadata,
|
||||
containsProperty(prefix + ".name", String.class).fromSource(source)
|
||||
.withDescription("Name description."));
|
||||
assertThat(metadata, containsProperty(prefix + ".name", String.class)
|
||||
.fromSource(source).withDescription("Name description."));
|
||||
assertThat(metadata, containsProperty(prefix + ".description"));
|
||||
assertThat(metadata, containsProperty(prefix + ".counter"));
|
||||
assertThat(metadata, containsProperty(prefix + ".number").fromSource(source)
|
||||
@@ -634,7 +601,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
return additionalMetadataFile;
|
||||
}
|
||||
|
||||
private void writeMetadata(File metadataFile, JSONObject metadata) throws IOException {
|
||||
private void writeMetadata(File metadataFile, JSONObject metadata)
|
||||
throws IOException {
|
||||
FileWriter writer = new FileWriter(metadataFile);
|
||||
try {
|
||||
metadata.write(writer);
|
||||
|
||||
@@ -136,12 +136,12 @@ public final class ConfigurationMetadataMatchers {
|
||||
ConfigurationMetadata metadata = (ConfigurationMetadata) item;
|
||||
ItemMetadata property = getFirstItemWithName(metadata, this.name);
|
||||
if (property == null) {
|
||||
description.appendText("missing "
|
||||
+ this.itemType.toString().toLowerCase() + " " + this.name);
|
||||
description.appendText("missing " + this.itemType.toString().toLowerCase()
|
||||
+ " " + this.name);
|
||||
}
|
||||
else {
|
||||
description.appendText(
|
||||
"was " + this.itemType.toString().toLowerCase() + " ")
|
||||
description
|
||||
.appendText("was " + this.itemType.toString().toLowerCase() + " ")
|
||||
.appendValue(property);
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,8 @@ public final class ConfigurationMetadataMatchers {
|
||||
}
|
||||
}
|
||||
|
||||
public ContainsHintMatcher withValue(int index, Object value, String description) {
|
||||
public ContainsHintMatcher withValue(int index, Object value,
|
||||
String description) {
|
||||
List<ValueHintMatcher> values = new ArrayList<ValueHintMatcher>(this.values);
|
||||
values.add(new ValueHintMatcher(index, value, description));
|
||||
return new ContainsHintMatcher(this.name, values, this.providers);
|
||||
@@ -288,7 +289,8 @@ public final class ConfigurationMetadataMatchers {
|
||||
return new ContainsHintMatcher(this.name, this.values, providers);
|
||||
}
|
||||
|
||||
public ContainsHintMatcher withProvider(String provider, String key, Object value) {
|
||||
public ContainsHintMatcher withProvider(String provider, String key,
|
||||
Object value) {
|
||||
return withProvider(this.providers.size(), provider,
|
||||
Collections.singletonMap(key, value));
|
||||
}
|
||||
@@ -297,7 +299,8 @@ public final class ConfigurationMetadataMatchers {
|
||||
return withProvider(this.providers.size(), provider, null);
|
||||
}
|
||||
|
||||
private ItemHint getFirstHintWithName(ConfigurationMetadata metadata, String name) {
|
||||
private ItemHint getFirstHintWithName(ConfigurationMetadata metadata,
|
||||
String name) {
|
||||
for (ItemHint hint : metadata.getHints()) {
|
||||
if (name.equals(hint.getName())) {
|
||||
return hint;
|
||||
@@ -357,7 +360,8 @@ public final class ConfigurationMetadataMatchers {
|
||||
private final String name;
|
||||
private final Map<String, Object> parameters;
|
||||
|
||||
public ValueProviderMatcher(int index, String name, Map<String, Object> parameters) {
|
||||
public ValueProviderMatcher(int index, String name,
|
||||
Map<String, Object> parameters) {
|
||||
this.index = index;
|
||||
this.name = name;
|
||||
this.parameters = parameters;
|
||||
|
||||
@@ -45,12 +45,12 @@ public class JsonMarshallerTests {
|
||||
metadata.add(ItemMetadata.newProperty("a", "b", StringBuffer.class.getName(),
|
||||
InputStream.class.getName(), "sourceMethod", "desc", "x",
|
||||
new ItemDeprecation("Deprecation comment", "b.c.d")));
|
||||
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null,
|
||||
null, null));
|
||||
metadata.add(ItemMetadata.newProperty("c", null, null, null, null, null, 123,
|
||||
null));
|
||||
metadata.add(ItemMetadata.newProperty("d", null, null, null, null, null, true,
|
||||
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null, null,
|
||||
null));
|
||||
metadata.add(
|
||||
ItemMetadata.newProperty("c", null, null, null, null, null, 123, null));
|
||||
metadata.add(
|
||||
ItemMetadata.newProperty("d", null, null, null, null, null, true, null));
|
||||
metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null,
|
||||
new String[] { "y", "n" }, null));
|
||||
metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null,
|
||||
@@ -59,14 +59,17 @@ public class JsonMarshallerTests {
|
||||
metadata.add(ItemHint.newHint("a.b"));
|
||||
metadata.add(ItemHint.newHint("c", new ItemHint.ValueHint(123, "hey"),
|
||||
new ItemHint.ValueHint(456, null)));
|
||||
metadata.add(new ItemHint("d", null, Arrays.asList(new ItemHint.ValueProvider(
|
||||
"first", Collections.<String, Object>singletonMap("target", "foo")),
|
||||
metadata.add(new ItemHint("d", null,
|
||||
Arrays.asList(
|
||||
new ItemHint.ValueProvider("first",
|
||||
Collections.<String, Object>singletonMap("target",
|
||||
"foo")),
|
||||
new ItemHint.ValueProvider("second", null))));
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
JsonMarshaller marshaller = new JsonMarshaller();
|
||||
marshaller.write(metadata, outputStream);
|
||||
ConfigurationMetadata read = marshaller.read(new ByteArrayInputStream(
|
||||
outputStream.toByteArray()));
|
||||
ConfigurationMetadata read = marshaller
|
||||
.read(new ByteArrayInputStream(outputStream.toByteArray()));
|
||||
assertThat(read,
|
||||
containsProperty("a.b", StringBuffer.class).fromSource(InputStream.class)
|
||||
.withDescription("desc").withDefaultValue(is("x"))
|
||||
@@ -76,8 +79,8 @@ public class JsonMarshallerTests {
|
||||
assertThat(read, containsProperty("d").withDefaultValue(is(true)));
|
||||
assertThat(read,
|
||||
containsProperty("e").withDefaultValue(is(new String[] { "y", "n" })));
|
||||
assertThat(read,
|
||||
containsProperty("f").withDefaultValue(is(new boolean[] { true, false })));
|
||||
assertThat(read, containsProperty("f")
|
||||
.withDefaultValue(is(new boolean[] { true, false })));
|
||||
assertThat(read, containsGroup("d"));
|
||||
assertThat(read, containsHint("a.b"));
|
||||
assertThat(read,
|
||||
|
||||
Reference in New Issue
Block a user