Create test classes

This commit is contained in:
azhwani 2020-07-04 11:58:20 +01:00
parent 8f99163df7
commit a1732d99a7
2 changed files with 61 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}