public void testCreatingJavaActionDef(){
DefDescriptor<ControllerDef> controllerDesc = DefDescriptorImpl.getInstance("java://org.auraframework.impl.java.controller.TestController", ControllerDef.class);
DefDescriptor<ActionDef> actionDefDesc = SubDefDescriptorImpl.getInstance("getString", controllerDesc, ActionDef.class);
try{
ActionDef actionDef = actionDefDesc.getDef();
assertNotNull(actionDef);
assertTrue(actionDef instanceof JavaActionDef);
assertTrue(actionDef.getParameters().isEmpty());
assertEquals(DefDescriptorImpl.getInstance("java://java.lang.String", TypeDef.class), actionDef.getReturnType());
assertEquals(ActionType.SERVER,actionDef.getActionType());
}catch(Exception e){
fail("Failed to create a valid java actiondef without parameters");
}
controllerDesc = DefDescriptorImpl.getInstance("java://org.auraframework.impl.java.controller.TestControllerWithParameters", ControllerDef.class);
actionDefDesc = SubDefDescriptorImpl.getInstance("sumValues", controllerDesc, ActionDef.class);
try{
ActionDef actionDef = actionDefDesc.getDef();
assertNotNull(actionDef);
assertEquals(2, actionDef.getParameters().size());
assertEquals("a", actionDef.getParameters().get(0).getName());
assertEquals("java://java.lang.Integer", actionDef.getParameters().get(0).getType().toString());
assertEquals("b", actionDef.getParameters().get(1).getName());
assertEquals("java://java.lang.Integer", actionDef.getParameters().get(0).getType().toString());
assertEquals(DefDescriptorImpl.getInstance("java://java.lang.Integer", TypeDef.class), actionDef.getReturnType());
}catch(Exception e){
fail("Failed to create a valid java actiondef with parameters");
}
}