package com.framsticks.params; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.framsticks.params.types.ProcedureParam; import com.framsticks.params.types.StringParam; import com.framsticks.test.TestClass; import com.framsticks.test.TestConfiguration; import static org.fest.assertions.Assertions.*; @Test public class FramsClassBuilderTest extends TestConfiguration { FramsClass framsClass; ReflectionAccess access; TestClass test; @BeforeClass public void setUp() { test = new TestClass(); test.setName("test"); test.appendHistory("first"); framsClass = FramsClass.build().forClass(TestClass.class); } @Test public void checkProcedureParams() { assertThat(framsClass.getParamCount()).isEqualTo(4); assertThat(framsClass.getParam("name")).isInstanceOf(StringParam.class); assertThat(framsClass.getParam("history")).isInstanceOf(StringParam.class); assertThat(framsClass.getParam("appendHistory")).isInstanceOf(ProcedureParam.class); assertThat(framsClass.getParam("resetHistory")).isInstanceOf(ProcedureParam.class); ProcedureParam appendHistory = framsClass.getParamEntry("appendHistory", ProcedureParam.class); assertThat(appendHistory.getArgumentsType().size()).isEqualTo(1); assertThat(appendHistory.getArgumentsType().get(0).getId()).isEqualTo("arg0"); } @Test(dependsOnMethods = "checkProcedureParams") public void callProcedures() { access = new ReflectionAccess(TestClass.class, framsClass); access.select(test); assertThat(access.get("history", String.class)).isEqualTo("first|"); Object result = access.call("appendHistory", new Object[] {"second"}); assertThat(result).isInstanceOf(Integer.class); assertThat(result).isEqualTo(13); assertThat(access.get("history", String.class)).isEqualTo("first|second|"); result = access.call("resetHistory", null); assertThat(result).isNull(); assertThat(access.get("history", String.class)).isEqualTo(""); } }