Commit ba67e162 authored by Phillip Webb's avatar Phillip Webb

Formatting

parent 50920190
...@@ -34,7 +34,8 @@ class ExpressionTree extends ReflectionWrapper { ...@@ -34,7 +34,8 @@ class ExpressionTree extends ReflectionWrapper {
private final Class<?> newArrayTreeType = findClass("com.sun.source.tree.NewArrayTree"); 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) { public ExpressionTree(Object instance) {
super(instance); super(instance);
......
...@@ -115,7 +115,8 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser { ...@@ -115,7 +115,8 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
return defaultValue; return defaultValue;
} }
private Object getValue(ExpressionTree expression, Object defaultValue) throws Exception { private Object getValue(ExpressionTree expression, Object defaultValue)
throws Exception {
Object literalValue = expression.getLiteralValue(); Object literalValue = expression.getLiteralValue();
if (literalValue != null) { if (literalValue != null) {
return literalValue; return literalValue;
......
...@@ -78,12 +78,15 @@ public abstract class AbstractFieldValuesProcessorTests { ...@@ -78,12 +78,15 @@ public abstract class AbstractFieldValuesProcessorTests {
assertThat(values.get("objectNone"), nullValue()); assertThat(values.get("objectNone"), nullValue());
assertThat(values.get("objectConst"), equalToObject("c")); assertThat(values.get("objectConst"), equalToObject("c"));
assertThat(values.get("objectInstance"), nullValue()); 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("stringArrayNone"), nullValue());
assertThat(values.get("stringEmptyArray"), equalToObject(new Object[0])); assertThat(values.get("stringEmptyArray"), equalToObject(new Object[0]));
assertThat(values.get("stringArrayConst"), equalToObject(new Object[]{"OK", "KO"})); assertThat(values.get("stringArrayConst"), equalToObject(new Object[] { "OK",
assertThat(values.get("stringArrayConstElements"), equalToObject(new Object[] {"c"})); "KO" }));
assertThat(values.get("integerArray"), equalToObject(new Object[] {42, 24})); assertThat(values.get("stringArrayConstElements"),
equalToObject(new Object[] { "c" }));
assertThat(values.get("integerArray"), equalToObject(new Object[] { 42, 24 }));
assertThat(values.get("unknownArray"), nullValue()); assertThat(values.get("unknownArray"), nullValue());
} }
......
...@@ -23,9 +23,7 @@ import java.io.InputStream; ...@@ -23,9 +23,7 @@ import java.io.InputStream;
import org.junit.Test; import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.Matchers.array;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsGroup; import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsGroup;
import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsProperty; import static org.springframework.boot.configurationprocessor.ConfigurationMetadataMatchers.containsProperty;
...@@ -49,10 +47,10 @@ public class JsonMarshallerTests { ...@@ -49,10 +47,10 @@ public class JsonMarshallerTests {
false)); false));
metadata.add(ItemMetadata.newProperty("d", null, null, null, null, null, true, metadata.add(ItemMetadata.newProperty("d", null, null, null, null, null, true,
false)); false));
metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null, new String[]{"y", "n"}, metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null,
false)); new String[] { "y", "n" }, false));
metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null, new Boolean[]{true, false}, metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null,
false)); new Boolean[] { true, false }, false));
metadata.add(ItemMetadata.newGroup("d", null, null, null)); metadata.add(ItemMetadata.newGroup("d", null, null, null));
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JsonMarshaller marshaller = new JsonMarshaller(); JsonMarshaller marshaller = new JsonMarshaller();
...@@ -61,12 +59,15 @@ public class JsonMarshallerTests { ...@@ -61,12 +59,15 @@ public class JsonMarshallerTests {
outputStream.toByteArray())); outputStream.toByteArray()));
assertThat(read, assertThat(read,
containsProperty("a.b", StringBuffer.class).fromSource(InputStream.class) 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("b.c.d"));
assertThat(read, containsProperty("c").withDefaultValue(is(123))); assertThat(read, containsProperty("c").withDefaultValue(is(123)));
assertThat(read, containsProperty("d").withDefaultValue(is(true))); assertThat(read, containsProperty("d").withDefaultValue(is(true)));
assertThat(read, containsProperty("e").withDefaultValue(is(array(equalTo("y"), equalTo("n"))))); assertThat(read,
assertThat(read, containsProperty("f").withDefaultValue(is(array(equalTo(true), equalTo(false))))); containsProperty("e").withDefaultValue(is(new String[] { "y", "n" })));
assertThat(read,
containsProperty("f").withDefaultValue(is(new boolean[] { true, false })));
assertThat(read, containsGroup("d")); assertThat(read, containsGroup("d"));
} }
......
...@@ -38,7 +38,7 @@ public class FieldValues { ...@@ -38,7 +38,7 @@ public class FieldValues {
private static final Integer INTEGER_OBJ_CONST = 4; 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"; private String string = "1";
...@@ -78,7 +78,7 @@ public class FieldValues { ...@@ -78,7 +78,7 @@ public class FieldValues {
private Object objectInstance = new StringBuffer(); private Object objectInstance = new StringBuffer();
private String[] stringArray = new String[] {"FOO", "BAR"}; private String[] stringArray = new String[] { "FOO", "BAR" };
private String[] stringArrayNone; private String[] stringArrayNone;
...@@ -88,8 +88,8 @@ public class FieldValues { ...@@ -88,8 +88,8 @@ public class FieldValues {
private String[] stringArrayConstElements = new String[] { STRING_CONST }; 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() };
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment