Merge branch '1.3.x'

This commit is contained in:
Stephane Nicoll
2016-03-08 10:07:06 +01:00
4 changed files with 81 additions and 3 deletions

View File

@@ -138,6 +138,22 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
}
}
@Test
public void emptyGroups() throws IOException {
InputStream in = getInputStreamFor("empty-groups");
try {
ConfigurationMetadataRepository repo = ConfigurationMetadataRepositoryJsonBuilder
.create(in).build();
validateEmptyGroup(repo);
assertThat(repo.getAllGroups()).hasSize(1);
contains(repo.getAllProperties(), "name", "title");
assertThat(repo.getAllProperties()).hasSize(2);
}
finally {
in.close();
}
}
@Test
public void builderInstancesAreIsolated() throws IOException {
InputStream foo = getInputStreamFor("foo");
@@ -241,6 +257,20 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests
.get("target")).isEqualTo("java.lang.Integer");
}
private void validateEmptyGroup(ConfigurationMetadataRepository repo) {
ConfigurationMetadataGroup group = repo.getAllGroups().get("");
contains(group.getSources(), "org.acme.Foo", "org.acme.Bar");
ConfigurationMetadataSource source = group.getSources().get("org.acme.Foo");
contains(source.getProperties(), "name");
assertThat(source.getProperties()).hasSize(1);
ConfigurationMetadataSource source2 = group.getSources()
.get("org.acme.Bar");
contains(source2.getProperties(), "title");
assertThat(source2.getProperties()).hasSize(1);
validatePropertyHints(repo.getAllProperties().get("name"), 0, 0);
validatePropertyHints(repo.getAllProperties().get("title"), 0, 0);
}
private void validatePropertyHints(ConfigurationMetadataProperty property,
int valueHints, int valueProviders) {
assertThat(property.getHints().getValueHints().size()).isEqualTo(valueHints);

View File

@@ -49,6 +49,18 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
readFor("invalid");
}
@Test
public void emptyGroupName() throws IOException {
RawConfigurationMetadata rawMetadata = readFor("empty-groups");
List<ConfigurationMetadataItem> items = rawMetadata.getItems();
assertThat(items).hasSize(2);
ConfigurationMetadataItem name = items.get(0);
assertProperty(name, "name", "name", String.class, null);
ConfigurationMetadataItem dotTitle = items.get(1);
assertProperty(dotTitle, "title", "title", String.class, null);
}
@Test
public void simpleMetadata() throws IOException {
RawConfigurationMetadata rawMetadata = readFor("foo");

View File

@@ -0,0 +1,30 @@
{
"groups": [
{
"name": "",
"type": "org.acme.Foo",
"sourceType": "org.acme.config.FooApp",
"sourceMethod": "foo()",
"description": "This is Foo."
},
{
"name": "",
"type": "org.acme.Bar",
"sourceType": "org.acme.config.FooApp",
"sourceMethod": "bar()",
"description": "This is Bar."
}
],
"properties": [
{
"name": "name",
"type": "java.lang.String",
"sourceType": "org.acme.Foo"
},
{
"name": "title",
"type": "java.lang.String",
"sourceType": "org.acme.Bar"
}
]
}