Polish
This commit is contained in:
@@ -330,7 +330,6 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
@Test
|
||||
public void mergingOfAdditionalProperty() throws Exception {
|
||||
File additionalMetadataFile = createAdditionalMetadataFile();
|
||||
|
||||
JSONObject property = new JSONObject();
|
||||
property.put("name", "foo");
|
||||
property.put("type", "java.lang.String");
|
||||
@@ -339,12 +338,9 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
properties.put(property);
|
||||
JSONObject additionalMetadata = new JSONObject();
|
||||
additionalMetadata.put("properties", properties);
|
||||
|
||||
writeMetadata(additionalMetadataFile, additionalMetadata);
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
|
||||
assertThat(metadata, containsProperty("simple.comparator"));
|
||||
|
||||
assertThat(metadata,
|
||||
containsProperty("foo", String.class)
|
||||
.fromSource(AdditionalMetadata.class));
|
||||
@@ -354,7 +350,6 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
public void mergingOfSimpleHint() throws Exception {
|
||||
writeAdditionalHints(ItemHint.newHint("simple.the-name", new ItemHint.ValueHint(
|
||||
"boot", "Bla bla"), new ItemHint.ValueHint("spring", null)));
|
||||
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata,
|
||||
containsHint("simple.the-name").withValue(0, "boot", "Bla bla")
|
||||
@@ -365,7 +360,6 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
public void mergingOfHintWithNonCanonicalName() throws Exception {
|
||||
writeAdditionalHints(ItemHint.newHint("simple.theName", new ItemHint.ValueHint(
|
||||
"boot", "Bla bla")));
|
||||
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata,
|
||||
containsHint("simple.the-name").withValue(0, "boot", "Bla bla"));
|
||||
@@ -373,16 +367,16 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
|
||||
@Test
|
||||
public void mergingOfHintWithProvider() throws Exception {
|
||||
writeAdditionalHints(
|
||||
new ItemHint("simple.theName", Collections.<ItemHint.ValueHint>emptyList(), Arrays.asList(
|
||||
new ItemHint.ProviderHint("first", Collections.<String,Object>singletonMap("target", "org.foo")),
|
||||
new ItemHint.ProviderHint("second", null))
|
||||
));
|
||||
|
||||
writeAdditionalHints(new ItemHint("simple.theName",
|
||||
Collections.<ItemHint.ValueHint> emptyList(), Arrays.asList(
|
||||
new ItemHint.ProviderHint("first", Collections
|
||||
.<String, Object> singletonMap("target", "org.foo")),
|
||||
new ItemHint.ProviderHint("second", null))));
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
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
|
||||
|
||||
@@ -212,10 +212,12 @@ public class ConfigurationMetadataMatchers {
|
||||
private final List<ProviderHintMatcher> providers;
|
||||
|
||||
public ContainsHintMatcher(String name) {
|
||||
this(name, new ArrayList<ValueHintMatcher>(), new ArrayList<ProviderHintMatcher>());
|
||||
this(name, new ArrayList<ValueHintMatcher>(),
|
||||
new ArrayList<ProviderHintMatcher>());
|
||||
}
|
||||
|
||||
public ContainsHintMatcher(String name, List<ValueHintMatcher> values, List<ProviderHintMatcher> providers) {
|
||||
public ContainsHintMatcher(String name, List<ValueHintMatcher> values,
|
||||
List<ProviderHintMatcher> providers) {
|
||||
this.name = name;
|
||||
this.values = values;
|
||||
this.providers = providers;
|
||||
@@ -273,14 +275,17 @@ public class ConfigurationMetadataMatchers {
|
||||
return new ContainsHintMatcher(this.name, values, this.providers);
|
||||
}
|
||||
|
||||
public ContainsHintMatcher withProvider(int index, String provider, Map<String,Object> parameters) {
|
||||
List<ProviderHintMatcher> providers = new ArrayList<ProviderHintMatcher>(this.providers);
|
||||
public ContainsHintMatcher withProvider(int index, String provider,
|
||||
Map<String, Object> parameters) {
|
||||
List<ProviderHintMatcher> providers = new ArrayList<ProviderHintMatcher>(
|
||||
this.providers);
|
||||
providers.add(new ProviderHintMatcher(index, provider, parameters));
|
||||
return new ContainsHintMatcher(this.name, this.values, providers);
|
||||
}
|
||||
|
||||
public ContainsHintMatcher withProvider(String provider, String key, Object value) {
|
||||
return withProvider(this.providers.size(), provider, Collections.singletonMap(key, value));
|
||||
return withProvider(this.providers.size(), provider,
|
||||
Collections.singletonMap(key, value));
|
||||
}
|
||||
|
||||
public ContainsHintMatcher withProvider(String provider) {
|
||||
@@ -359,9 +364,8 @@ public class ConfigurationMetadataMatchers {
|
||||
if (this.index + 1 > hint.getProviders().size()) {
|
||||
return false;
|
||||
}
|
||||
ItemHint.ProviderHint providerHint = hint.getProviders().get(index);
|
||||
if (this.name != null
|
||||
&& !this.name.equals(providerHint.getName())) {
|
||||
ItemHint.ProviderHint providerHint = hint.getProviders().get(this.index);
|
||||
if (this.name != null && !this.name.equals(providerHint.getName())) {
|
||||
return false;
|
||||
}
|
||||
if (this.parameters != null) {
|
||||
|
||||
@@ -58,8 +58,8 @@ 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.ProviderHint("first", Collections.<String,Object>singletonMap("target", "foo")),
|
||||
metadata.add(new ItemHint("d", null, Arrays.asList(new ItemHint.ProviderHint(
|
||||
"first", Collections.<String, Object> singletonMap("target", "foo")),
|
||||
new ItemHint.ProviderHint("second", null))));
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
JsonMarshaller marshaller = new JsonMarshaller();
|
||||
@@ -81,8 +81,7 @@ public class JsonMarshallerTests {
|
||||
assertThat(read, containsHint("a.b"));
|
||||
assertThat(read,
|
||||
containsHint("c").withValue(0, 123, "hey").withValue(1, 456, null));
|
||||
assertThat(read, containsHint("d")
|
||||
.withProvider("first", "target", "foo")
|
||||
assertThat(read, containsHint("d").withProvider("first", "target", "foo")
|
||||
.withProvider("second"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user