Search in sources :

Example 11 with Database

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")));
}
Also used : Properties(java.util.Properties) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 12 with Database

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);
}
Also used : Properties(java.util.Properties) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 13 with Database

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);
}
Also used : Properties(java.util.Properties) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 14 with Database

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);
}
Also used : Properties(java.util.Properties) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 15 with Database

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);
}
Also used : Properties(java.util.Properties) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Aggregations

BaseTest (com.tvd12.test.base.BaseTest)12 Properties (java.util.Properties)12 Test (org.testng.annotations.Test)12 Database (com.tvd12.dahlia.core.entity.Database)8 DatabaseSetting (com.tvd12.dahlia.core.setting.DatabaseSetting)7 Collection (com.tvd12.dahlia.core.entity.Collection)5 CollectionExistedException (com.tvd12.dahlia.exception.CollectionExistedException)5 DatabaseExistedException (com.tvd12.dahlia.exception.DatabaseExistedException)5 CommandCreateDatabase (com.tvd12.dahlia.core.command.CommandCreateDatabase)4 CollectionSetting (com.tvd12.dahlia.core.setting.CollectionSetting)4 DuplicatedIdException (com.tvd12.dahlia.exception.DuplicatedIdException)4 FindOptions (com.tvd12.dahlia.query.FindOptions)4 EzyArray (com.tvd12.ezyfox.entity.EzyArray)4 EzyObject (com.tvd12.ezyfox.entity.EzyObject)4 IDatabase (com.tvd12.dahlia.IDatabase)3 CommandCreateCollection (com.tvd12.dahlia.core.command.CommandCreateCollection)3 ICollection (com.tvd12.dahlia.ICollection)2 DahliaCore (com.tvd12.dahlia.core.DahliaCore)2 DahliaCoreLoader (com.tvd12.dahlia.core.DahliaCoreLoader)2 CommandCount (com.tvd12.dahlia.core.command.CommandCount)2