use of com.haulmont.cuba.security.entity.RoleType in project cuba by cuba-platform.
the class ConfigProviderTest method testAppProperties.
@Test
public void testAppProperties() {
TestConfig config = AppBeans.get(Configuration.class).getConfig(TestConfig.class);
// String property
String stringProp = config.getStringProp();
assertNull(stringProp);
String stringPropDef = config.getStringPropDef();
assertEquals("def_value", stringPropDef);
config.setStringProp("test_value");
stringProp = config.getStringProp();
assertEquals("test_value", stringProp);
// Integer property
Integer integerProp = config.getIntegerProp();
assertNull(integerProp);
Integer integerPropDef = config.getIntegerPropDef();
assertEquals(Integer.valueOf(100), integerPropDef);
Integer integerPropDefRuntime = config.getIntegerPropDefRuntime(200);
assertEquals(Integer.valueOf(200), integerPropDefRuntime);
config.setIntegerProp(10);
integerProp = config.getIntegerProp();
assertEquals(Integer.valueOf(10), integerProp);
// primitive int
int intPropDef = config.getIntPropDef();
assertEquals(0, intPropDef);
config.setIntPropDef(1);
intPropDef = config.getIntPropDef();
assertEquals(1, intPropDef);
int intPropDefRuntime = config.getIntPropDefRuntime(11);
assertEquals(11, intPropDefRuntime);
config.setIntPropDefRuntime(12);
intPropDefRuntime = config.getIntPropDefRuntime(11);
assertEquals(12, intPropDefRuntime);
// Boolean property
Boolean booleanProp = config.getBooleanProp();
assertNull(booleanProp);
config.setBooleanProp(true);
booleanProp = config.getBooleanProp();
assertTrue(booleanProp);
Boolean booleanPropDef = config.getBooleanPropDef();
assertTrue(booleanPropDef);
// primitive boolean
boolean boolProp = config.getBoolProp();
assertFalse(boolProp);
config.setBoolProp(true);
boolProp = config.getBoolProp();
assertTrue(boolProp);
// UUID property
UUID uuidProp = config.getUuidProp();
assertNull(uuidProp);
UUID uuid = UUID.randomUUID();
config.setUuidProp(uuid);
uuidProp = config.getUuidProp();
assertEquals(uuid, uuidProp);
// Entity property
User adminUser = config.getAdminUser();
assertNotNull(adminUser);
assertEquals("admin", adminUser.getLogin());
// Enum property
RoleType roleType = config.getRoleTypeProp();
assertTrue(roleType == RoleType.STANDARD);
// Date property
Date date = config.getDateProp();
try {
assertEquals(new SimpleDateFormat("yyyy-MM-dd").parse("2013-12-12"), date);
} catch (ParseException e) {
throw new RuntimeException(e);
}
// List of Integer
List<Integer> integerList = config.getIntegerListProp();
assertEquals(Arrays.asList(1, 2, 3), integerList);
// List of String
List<String> stringList = config.getStringListProp();
assertEquals(Arrays.asList("aaa", "bbb", "ccc"), stringList);
}
Aggregations