Search in sources :

Example 1 with SetterMethod

use of com.tvd12.properties.file.struct.SetterMethod 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");
}
Also used : PropertyAnnotations(com.tvd12.properties.file.annotation.PropertyAnnotations) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) Method(java.lang.reflect.Method) Test(org.testng.annotations.Test)

Example 2 with SetterMethod

use of com.tvd12.properties.file.struct.SetterMethod 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");
}
Also used : PropertyAnnotations(com.tvd12.properties.file.annotation.PropertyAnnotations) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) Method(java.lang.reflect.Method) Test(org.testng.annotations.Test)

Example 3 with SetterMethod

use of com.tvd12.properties.file.struct.SetterMethod 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");
}
Also used : PropertyAnnotations(com.tvd12.properties.file.annotation.PropertyAnnotations) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) Test(org.testng.annotations.Test)

Example 4 with SetterMethod

use of com.tvd12.properties.file.struct.SetterMethod 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");
}
Also used : PropertyAnnotations(com.tvd12.properties.file.annotation.PropertyAnnotations) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) Method(java.lang.reflect.Method) Test(org.testng.annotations.Test)

Example 5 with SetterMethod

use of com.tvd12.properties.file.struct.SetterMethod 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");
}
Also used : PropertyAnnotations(com.tvd12.properties.file.annotation.PropertyAnnotations) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) SetterMethod(com.tvd12.properties.file.struct.SetterMethod) Method(java.lang.reflect.Method) Test(org.testng.annotations.Test)

Aggregations

PropertyAnnotations (com.tvd12.properties.file.annotation.PropertyAnnotations)6 SetterMethod (com.tvd12.properties.file.struct.SetterMethod)6 Test (org.testng.annotations.Test)6 Method (java.lang.reflect.Method)4