use of org.springframework.cloud.config.environment.PropertySource in project spring-cloud-config by spring-cloud.
the class EnvironmentControllerTests method arrayAtTopLevelInYaml.
@Test
public void arrayAtTopLevelInYaml() throws Exception {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("document[0]", "c");
map.put("document[1]", "d");
this.environment.add(new PropertySource("one", map));
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
String yaml = this.controller.yaml("foo", "bar", false).getBody();
assertEquals("- c\n- d\n", yaml);
}
use of org.springframework.cloud.config.environment.PropertySource in project spring-cloud-config by spring-cloud.
the class EnvironmentControllerTests method vanillaYaml.
@Test
public void vanillaYaml() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("a.b.c", "d");
this.environment.add(new PropertySource("one", map));
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
String yaml = this.controller.yaml("foo", "bar", false).getBody();
assertEquals("a:\n b:\n c: d\n", yaml);
}
use of org.springframework.cloud.config.environment.PropertySource in project spring-cloud-config by spring-cloud.
the class EnvironmentControllerTests method arrayOfObjectInYaml.
@Test
public void arrayOfObjectInYaml() throws Exception {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("a.b[0].c", "d");
map.put("a.b[0].d", "e");
map.put("a.b[1].c", "d");
this.environment.add(new PropertySource("one", map));
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
String yaml = this.controller.yaml("foo", "bar", false).getBody();
assertTrue("Wrong output: " + yaml, "a:\n b:\n - d: e\n c: d\n - c: d\n".equals(yaml) || "a:\n b:\n - c: d\n d: e\n - c: d\n".equals(yaml));
}
use of org.springframework.cloud.config.environment.PropertySource in project spring-cloud-config by spring-cloud.
the class EnvironmentControllerTests method nestedArraysOfObjectInYaml.
@Test
public void nestedArraysOfObjectInYaml() throws Exception {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("a.b[0].c", "x");
map.put("a.b[2].e[0].d", "z");
map.put("a.b[0].d[2]", "yy");
map.put("a.b[0].d[0]", "xx");
map.put("a.b[2].c", "y");
map.put("a.b[3][0]", "r");
map.put("a.b[3][1]", "s");
this.environment.add(new PropertySource("one", map));
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
String yaml = this.controller.yaml("foo", "bar", false).getBody();
// @formatter:off
String expected = "a:\n" + " b:\n" + " - c: x\n" + " d:\n" + " - xx\n" + " - null\n" + " - yy\n" + " - null\n" + " - c: y\n" + " e:\n" + " - d: z\n" + " - - r\n" + " - s\n";
// @formatter:on
assertThat("Wrong output: " + yaml, yaml, is(expected));
}
use of org.springframework.cloud.config.environment.PropertySource in project spring-cloud-config by spring-cloud.
the class EnvironmentControllerTests method arrayOfObjectAtTopLevelInYaml.
@Test
public void arrayOfObjectAtTopLevelInYaml() throws Exception {
Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("b[0].c", "d");
map.put("b[1].c", "d");
this.environment.add(new PropertySource("one", map));
Mockito.when(this.repository.findOne("foo", "bar", null)).thenReturn(this.environment);
String yaml = this.controller.yaml("foo", "bar", false).getBody();
assertEquals("b:\n- c: d\n- c: d\n", yaml);
}
Aggregations