use of com.tvd12.properties.file.annotation.PropertyAnnotations in project properties-file by tvd12.
the class SetterMethodTest method getKeyStartWithNotSet.
@Test
public void getKeyStartWithNotSet() throws Exception {
// given
SetterMethod method = new SetterMethod(new PropertyAnnotations());
method.initWithMethod(ClassA.class.getDeclaredMethod("value", String.class));
// when
String key = method.getKey();
// then
assertEquals(key, "value");
}
use of com.tvd12.properties.file.annotation.PropertyAnnotations in project properties-file by tvd12.
the class PropertiesMapper method doMapToMapValue.
@SuppressWarnings({ "unchecked", "rawtypes" })
private Map doMapToMapValue(Type genericType) {
if (genericType == null) {
return properties;
}
Class<?> mapValueType = ReflectionGenericUtil.getTwoGenericClassArguments(genericType)[1];
if (mapValueType == null) {
return properties;
}
Map answer = new HashMap<>();
Map<String, Properties> propertiesMap = PropertiesUtil.getPropertiesMap(properties);
for (String key : propertiesMap.keySet()) {
Object value = new PropertiesMapper().data(properties).propertyPrefix(key).classLoader(classLoader).valueConverter(valueConverter).propertyAnnotations(propertyAnnotations).map(mapValueType);
answer.put(key, value);
}
return answer;
}
use of com.tvd12.properties.file.annotation.PropertyAnnotations in project properties-file by tvd12.
the class SetterMethodTest method test.
@Test
public void test() {
Method method = MethodBuilder.create().clazz(ClassA.class).method("setName").argument(String.class).build();
SetterMethod setterMethod = new SetterMethod(new PropertyAnnotations());
setterMethod.initWithMethod(method);
setterMethod.invoke(new ClassA(), "123");
}
use of com.tvd12.properties.file.annotation.PropertyAnnotations in project properties-file by tvd12.
the class SetterMethodTest method testInvalidCase.
@Test(expectedExceptions = { IllegalStateException.class })
public void testInvalidCase() {
Method method = MethodBuilder.create().clazz(ClassA.class).method("setValues").argument(String.class).argument(String.class).build();
SetterMethod setterMethod = new SetterMethod(new PropertyAnnotations());
setterMethod.initWithMethod(method);
setterMethod.invoke(new ClassA(), "123");
}
use of com.tvd12.properties.file.annotation.PropertyAnnotations in project properties-file by tvd12.
the class SetterMethodTest method getKeyStartWithNotSet.
@Test
public void getKeyStartWithNotSet() throws Exception {
// given
SetterMethod method = new SetterMethod(new PropertyAnnotations());
method.initWithMethod(ClassA.class.getDeclaredMethod("value", String.class));
// when
String key = method.getKey();
// then
assertEquals(key, "value");
}
Aggregations