|
|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2012-2019 the original author or authors. |
|
|
|
|
* Copyright 2012-2021 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. |
|
|
|
|
@ -82,7 +82,7 @@ class JsonMarshallerTests {
@@ -82,7 +82,7 @@ class JsonMarshallerTests {
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
JsonMarshaller marshaller = new JsonMarshaller(); |
|
|
|
|
marshaller.write(metadata, outputStream); |
|
|
|
|
String json = new String(outputStream.toByteArray()); |
|
|
|
|
String json = outputStream.toString(); |
|
|
|
|
assertThat(json).containsSubsequence("\"groups\"", "\"com.acme.alpha\"", "\"com.acme.bravo\"", "\"properties\"", |
|
|
|
|
"\"com.example.alpha.ccc\"", "\"com.example.alpha.ddd\"", "\"com.example.bravo.aaa\"", |
|
|
|
|
"\"com.example.bravo.bbb\"", "\"hints\"", "\"eee\"", "\"fff\""); |
|
|
|
|
@ -100,9 +100,71 @@ class JsonMarshallerTests {
@@ -100,9 +100,71 @@ class JsonMarshallerTests {
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
JsonMarshaller marshaller = new JsonMarshaller(); |
|
|
|
|
marshaller.write(metadata, outputStream); |
|
|
|
|
String json = new String(outputStream.toByteArray()); |
|
|
|
|
String json = outputStream.toString(); |
|
|
|
|
assertThat(json).containsSubsequence("\"properties\"", "\"com.example.alpha.ddd\"", "\"com.example.bravo.bbb\"", |
|
|
|
|
"\"com.example.alpha.ccc\"", "\"com.example.bravo.aaa\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void orderingForSameGroupNames() throws IOException { |
|
|
|
|
ConfigurationMetadata metadata = new ConfigurationMetadata(); |
|
|
|
|
metadata.add(ItemMetadata.newGroup("com.acme.alpha", null, "com.example.Foo", null)); |
|
|
|
|
metadata.add(ItemMetadata.newGroup("com.acme.alpha", null, "com.example.Bar", null)); |
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
JsonMarshaller marshaller = new JsonMarshaller(); |
|
|
|
|
marshaller.write(metadata, outputStream); |
|
|
|
|
String json = outputStream.toString(); |
|
|
|
|
assertThat(json).containsSubsequence("\"groups\"", "\"name\": \"com.acme.alpha\"", |
|
|
|
|
"\"sourceType\": \"com.example.Bar\"", "\"name\": \"com.acme.alpha\"", |
|
|
|
|
"\"sourceType\": \"com.example.Foo\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void orderingForSamePropertyNames() throws IOException { |
|
|
|
|
ConfigurationMetadata metadata = new ConfigurationMetadata(); |
|
|
|
|
metadata.add(ItemMetadata.newProperty("com.example.bravo", "aaa", "java.lang.Boolean", "com.example.Foo", null, |
|
|
|
|
null, null, null)); |
|
|
|
|
metadata.add(ItemMetadata.newProperty("com.example.bravo", "aaa", "java.lang.Integer", "com.example.Bar", null, |
|
|
|
|
null, null, null)); |
|
|
|
|
metadata.add( |
|
|
|
|
ItemMetadata.newProperty("com.example.alpha", "ddd", null, "com.example.Bar", null, null, null, null)); |
|
|
|
|
metadata.add( |
|
|
|
|
ItemMetadata.newProperty("com.example.alpha", "ccc", null, "com.example.Foo", null, null, null, null)); |
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
JsonMarshaller marshaller = new JsonMarshaller(); |
|
|
|
|
marshaller.write(metadata, outputStream); |
|
|
|
|
String json = outputStream.toString(); |
|
|
|
|
assertThat(json).containsSubsequence("\"groups\"", "\"properties\"", "\"com.example.alpha.ccc\"", |
|
|
|
|
"com.example.Foo", "\"com.example.alpha.ddd\"", "com.example.Bar", "\"com.example.bravo.aaa\"", |
|
|
|
|
"com.example.Bar", "\"com.example.bravo.aaa\"", "com.example.Foo"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void orderingForSameGroupWithNullSourceType() throws IOException { |
|
|
|
|
ConfigurationMetadata metadata = new ConfigurationMetadata(); |
|
|
|
|
metadata.add(ItemMetadata.newGroup("com.acme.alpha", null, "com.example.Foo", null)); |
|
|
|
|
metadata.add(ItemMetadata.newGroup("com.acme.alpha", null, null, null)); |
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
JsonMarshaller marshaller = new JsonMarshaller(); |
|
|
|
|
marshaller.write(metadata, outputStream); |
|
|
|
|
String json = outputStream.toString(); |
|
|
|
|
assertThat(json).containsSubsequence("\"groups\"", "\"name\": \"com.acme.alpha\"", |
|
|
|
|
"\"name\": \"com.acme.alpha\"", "\"sourceType\": \"com.example.Foo\""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void orderingForSamePropertyNamesWithNullSourceType() throws IOException { |
|
|
|
|
ConfigurationMetadata metadata = new ConfigurationMetadata(); |
|
|
|
|
metadata.add(ItemMetadata.newProperty("com.example.bravo", "aaa", "java.lang.Boolean", null, null, null, null, |
|
|
|
|
null)); |
|
|
|
|
metadata.add(ItemMetadata.newProperty("com.example.bravo", "aaa", "java.lang.Integer", "com.example.Bar", null, |
|
|
|
|
null, null, null)); |
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
JsonMarshaller marshaller = new JsonMarshaller(); |
|
|
|
|
marshaller.write(metadata, outputStream); |
|
|
|
|
String json = outputStream.toString(); |
|
|
|
|
assertThat(json).containsSubsequence("\"groups\"", "\"properties\"", "\"com.example.bravo.aaa\"", |
|
|
|
|
"\"java.lang.Boolean\"", "\"com.example.bravo.aaa\"", "\"java.lang.Integer\"", "\"com.example.Bar"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|