Formatting
This commit is contained in:
parent
509201907c
commit
ba67e16258
|
|
@ -34,7 +34,8 @@ class ExpressionTree extends ReflectionWrapper {
|
|||
|
||||
private final Class<?> newArrayTreeType = findClass("com.sun.source.tree.NewArrayTree");
|
||||
|
||||
private final Method arrayValueMethod = findMethod(this.newArrayTreeType, "getInitializers");
|
||||
private final Method arrayValueMethod = findMethod(this.newArrayTreeType,
|
||||
"getInitializers");
|
||||
|
||||
public ExpressionTree(Object instance) {
|
||||
super(instance);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,8 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
|
|||
return defaultValue;
|
||||
}
|
||||
|
||||
private Object getValue(ExpressionTree expression, Object defaultValue) throws Exception {
|
||||
private Object getValue(ExpressionTree expression, Object defaultValue)
|
||||
throws Exception {
|
||||
Object literalValue = expression.getLiteralValue();
|
||||
if (literalValue != null) {
|
||||
return literalValue;
|
||||
|
|
|
|||
|
|
@ -78,12 +78,15 @@ public abstract class AbstractFieldValuesProcessorTests {
|
|||
assertThat(values.get("objectNone"), nullValue());
|
||||
assertThat(values.get("objectConst"), equalToObject("c"));
|
||||
assertThat(values.get("objectInstance"), nullValue());
|
||||
assertThat(values.get("stringArray"), equalToObject(new Object[] {"FOO", "BAR"}));
|
||||
assertThat(values.get("stringArray"),
|
||||
equalToObject(new Object[] { "FOO", "BAR" }));
|
||||
assertThat(values.get("stringArrayNone"), nullValue());
|
||||
assertThat(values.get("stringEmptyArray"), equalToObject(new Object[0]));
|
||||
assertThat(values.get("stringArrayConst"), equalToObject(new Object[]{"OK", "KO"}));
|
||||
assertThat(values.get("stringArrayConstElements"), equalToObject(new Object[] {"c"}));
|
||||
assertThat(values.get("integerArray"), equalToObject(new Object[] {42, 24}));
|
||||
assertThat(values.get("stringArrayConst"), equalToObject(new Object[] { "OK",
|
||||
"KO" }));
|
||||
assertThat(values.get("stringArrayConstElements"),
|
||||
equalToObject(new Object[] { "c" }));
|
||||
assertThat(values.get("integerArray"), equalToObject(new Object[] { 42, 24 }));
|
||||
assertThat(values.get("unknownArray"), nullValue());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import java.io.InputStream;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.array;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsGroup;
|
||||
import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsProperty;
|
||||
|
|
@ -49,10 +47,10 @@ public class JsonMarshallerTests {
|
|||
false));
|
||||
metadata.add(ItemMetadata.newProperty("d", null, null, null, null, null, true,
|
||||
false));
|
||||
metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null, new String[]{"y", "n"},
|
||||
false));
|
||||
metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null, new Boolean[]{true, false},
|
||||
false));
|
||||
metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null,
|
||||
new String[] { "y", "n" }, false));
|
||||
metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null,
|
||||
new Boolean[] { true, false }, false));
|
||||
metadata.add(ItemMetadata.newGroup("d", null, null, null));
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
JsonMarshaller marshaller = new JsonMarshaller();
|
||||
|
|
@ -61,12 +59,15 @@ public class JsonMarshallerTests {
|
|||
outputStream.toByteArray()));
|
||||
assertThat(read,
|
||||
containsProperty("a.b", StringBuffer.class).fromSource(InputStream.class)
|
||||
.withDescription("desc").withDefaultValue(is("x")).withDeprecated());
|
||||
.withDescription("desc").withDefaultValue(is("x"))
|
||||
.withDeprecated());
|
||||
assertThat(read, containsProperty("b.c.d"));
|
||||
assertThat(read, containsProperty("c").withDefaultValue(is(123)));
|
||||
assertThat(read, containsProperty("d").withDefaultValue(is(true)));
|
||||
assertThat(read, containsProperty("e").withDefaultValue(is(array(equalTo("y"), equalTo("n")))));
|
||||
assertThat(read, containsProperty("f").withDefaultValue(is(array(equalTo(true), equalTo(false)))));
|
||||
assertThat(read,
|
||||
containsProperty("e").withDefaultValue(is(new String[] { "y", "n" })));
|
||||
assertThat(read,
|
||||
containsProperty("f").withDefaultValue(is(new boolean[] { true, false })));
|
||||
assertThat(read, containsGroup("d"));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class FieldValues {
|
|||
|
||||
private static final Integer INTEGER_OBJ_CONST = 4;
|
||||
|
||||
private static final String[] STRING_ARRAY_CONST = new String[] {"OK", "KO"};
|
||||
private static final String[] STRING_ARRAY_CONST = new String[] { "OK", "KO" };
|
||||
|
||||
private String string = "1";
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ public class FieldValues {
|
|||
|
||||
private Object objectInstance = new StringBuffer();
|
||||
|
||||
private String[] stringArray = new String[] {"FOO", "BAR"};
|
||||
private String[] stringArray = new String[] { "FOO", "BAR" };
|
||||
|
||||
private String[] stringArrayNone;
|
||||
|
||||
|
|
@ -88,8 +88,8 @@ public class FieldValues {
|
|||
|
||||
private String[] stringArrayConstElements = new String[] { STRING_CONST };
|
||||
|
||||
private Integer[] integerArray = new Integer[] {42, 24};
|
||||
private Integer[] integerArray = new Integer[] { 42, 24 };
|
||||
|
||||
private FieldValues[] unknownArray = new FieldValues[] {new FieldValues()};
|
||||
private FieldValues[] unknownArray = new FieldValues[] { new FieldValues() };
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue