use of com.tvd12.dahlia.core.entity.Database in project properties-file by tvd12.
the class PropertiesUtilTest method getFirstPropertyKeyListWithFirstDotIndex0.
@Test
public void getFirstPropertyKeyListWithFirstDotIndex0() {
// given
Properties properties = new Properties();
properties.put("", "foo");
properties.put(".", "database");
properties.put("hello", "world");
properties.put("hello.1", "world");
properties.put("hello1.2", "world");
// when
List<String> actual = PropertiesUtil.getFirstPropertyKeyList(properties);
// then
assertEquals(actual.size(), 4);
assertTrue(actual.containsAll(Arrays.asList("", ".", "hello", "hello1")));
}
use of com.tvd12.dahlia.core.entity.Database in project properties-file by tvd12.
the class PropertiesUtilTest method getPropertiesByEmptyPrefixTest.
@Test
public void getPropertiesByEmptyPrefixTest() {
Properties properties = new Properties();
properties.put("datasource", "database");
properties.put("datasource.username", "hello");
assertEquals(PropertiesUtil.getPropertiesByPrefix(properties, ""), properties);
}
use of com.tvd12.dahlia.core.entity.Database in project properties-file by tvd12.
the class PropertiesUtilTest method filterPropertiesByPrefixTest.
@Test
public void filterPropertiesByPrefixTest() {
Properties properties = new Properties();
properties.put("datasource", "database");
properties.put("datasource.username", "hello");
properties.put("cache.username", "hello");
properties.put("cache.pass", "pass");
Properties expected = new Properties();
expected.put("datasource", "database");
expected.put("datasource.username", "hello");
assertEquals(PropertiesUtil.filterPropertiesByKeyPrefix(properties, "datasource"), expected);
}
use of com.tvd12.dahlia.core.entity.Database in project properties-file by tvd12.
the class PropertiesUtilTest method getFirstPropertyKeysWithFirstDotIndex0.
@Test
public void getFirstPropertyKeysWithFirstDotIndex0() {
// given
Properties properties = new Properties();
properties.put("", "foo");
properties.put(".", "database");
properties.put("hello", "world");
properties.put("hello.1", "world");
properties.put("hello1.2", "world");
// when
Set<String> actual = PropertiesUtil.getFirstPropertyKeys(properties);
// then
Set<String> expected = new HashSet<>(Arrays.asList("", ".", "hello", "hello1"));
assertEquals(actual, expected);
}
use of com.tvd12.dahlia.core.entity.Database in project properties-file by tvd12.
the class PropertiesUtilTest method setVariableInValidTest.
@Test
public void setVariableInValidTest() {
// given
Properties properties = new Properties();
properties.put("datasource", "database: ${username}${password}${}} url ${not found}}");
properties.put("username", "foo");
properties.put("password", "bar");
// when
PropertiesUtil.setVariableValues(properties);
// then
Properties expectation = new Properties();
expectation.put("datasource", "database: foobar${}} url ${not found}}");
expectation.put("username", "foo");
expectation.put("password", "bar");
Asserts.assertEquals(properties, expectation);
}
Aggregations