quick fix

This commit is contained in:
azhwani 2020-07-07 12:00:37 +01:00
parent a1732d99a7
commit aeb1653c89
4 changed files with 22 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package com.baeldung.properties.yamllist.pojo;
import java.util.List;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ -10,7 +11,7 @@ import org.springframework.stereotype.Component;
public class ApplicationProps {
private List<Object> profiles;
private List<List<String>> team;
private List<Map<String, Object>> props;
private List<User> users;
public List<Object> getProfiles() {
@ -21,12 +22,12 @@ public class ApplicationProps {
this.profiles = profiles;
}
public List<List<String>> getTeam() {
return team;
public List<Map<String, Object>> getProps() {
return props;
}
public void setTeam(List<List<String>> team) {
this.team = team;
public void setProps(List<Map<String, Object>> props) {
this.props = props;
}
public List<User> getUsers() {

View File

@ -28,15 +28,17 @@ application:
- prod
- 1
- 2
team:
props:
-
- James
- Matthew
- Olivia
name: YamlList
url: http://yamllist.dev
description: Mapping list in Yaml to list of objects in Spring Boot
-
- Natalie
- Brittany
- Christian
ip: 10.10.10.10
port: 8091
-
email: support@yamllist.dev
contact: http://yamllist.dev/contact
users:
-
username: admin

View File

@ -22,9 +22,13 @@ class YamlComplexListsIntegrationTest {
assertThat(applicationProps.getUsers()
.get(0)
.getPassword()).isEqualTo("admin@10@");
assertThat(applicationProps.getTeam()
assertThat(applicationProps.getProps()
.get(0)
.size()).isEqualTo(3);
.get("name")).isEqualTo("YamlList");
assertThat(applicationProps.getProps()
.get(1)
.get("port")
.getClass()).isEqualTo(Integer.class);
}
}

View File

@ -23,8 +23,7 @@ class YamlSimpleListIntegrationTest {
.get(0)).isEqualTo("dev");
assertThat(applicationProps.getProfiles()
.get(4)
.getClass()
.toString()).isEqualTo("class java.lang.Integer");
.getClass()).isEqualTo(Integer.class);
assertThat(applicationProps.getProfiles()
.size()).isEqualTo(5);
}