From a1732d99a70942dcf95e315c5e46b1384f12dd85 Mon Sep 17 00:00:00 2001 From: azhwani <> Date: Sat, 4 Jul 2020 11:58:20 +0100 Subject: [PATCH] Create test classes --- .../YamlComplexListsIntegrationTest.java | 30 ++++++++++++++++++ .../YamlSimpleListIntegrationTest.java | 31 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlComplexListsIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlSimpleListIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlComplexListsIntegrationTest.java b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlComplexListsIntegrationTest.java new file mode 100644 index 0000000000..7e33d66917 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlComplexListsIntegrationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.properties.yamllist; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.properties.yamllist.pojo.ApplicationProps; + +@RunWith(SpringRunner.class) +@SpringBootTest +class YamlComplexListsIntegrationTest { + + @Autowired + private ApplicationProps applicationProps; + + @Test + public void whenYamlNestedLists_thenLoadComplexLists() { + assertThat(applicationProps.getUsers() + .get(0) + .getPassword()).isEqualTo("admin@10@"); + assertThat(applicationProps.getTeam() + .get(0) + .size()).isEqualTo(3); + } + +} diff --git a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlSimpleListIntegrationTest.java b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlSimpleListIntegrationTest.java new file mode 100644 index 0000000000..119733b9a3 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlSimpleListIntegrationTest.java @@ -0,0 +1,31 @@ +package com.baeldung.properties.yamllist; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.properties.yamllist.pojo.ApplicationProps; + +@RunWith(SpringRunner.class) +@SpringBootTest +class YamlSimpleListIntegrationTest { + + @Autowired + private ApplicationProps applicationProps; + + @Test + public void whenYamlList_thenLoadSimpleList() { + assertThat(applicationProps.getProfiles() + .get(0)).isEqualTo("dev"); + assertThat(applicationProps.getProfiles() + .get(4) + .getClass() + .toString()).isEqualTo("class java.lang.Integer"); + assertThat(applicationProps.getProfiles() + .size()).isEqualTo(5); + } +}