Package org.auraframework.def

Examples of org.auraframework.def.ControllerDef


                    // mark injectee component as loaded
                    // only when not using async because component defs will be printed onto HTML
                    definitionService.updateLoaded(descriptor);

                    ControllerDef componentControllerDef = definitionService.getDefDescriptor("aura://ComponentController",
                            ControllerDef.class).getDef();

                    Map<String, Object> paramValues = Maps.newHashMap();
                    paramValues.put("name", descriptor.getQualifiedName());
                    paramValues.put("attributes", actionAttributes);

                    Action action = componentControllerDef.createAction("getComponent", paramValues);
                    action.setId("ais");

                    Action previous = context.setCurrentAction(action);
                    try {
                        action.run();
View Full Code Here


     */
    public void testInvalidJSController() throws Exception {
        DefDescriptor<ControllerDef> descriptor = DefDescriptorImpl.getInstance("js://test.testInvalidJSController",
                ControllerDef.class);
        Source<?> source = getJavascriptSourceLoader().getSource(descriptor);
        ControllerDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Javascript controller must only contain functions");
        } catch (Exception e) {
            this.checkExceptionContains(e, InvalidDefinitionException.class, "Expected ':'");
        }
    }
View Full Code Here

    public void testNonFunctionElementsInJSController() throws Exception {
        DefDescriptor<ControllerDef> descriptor = DefDescriptorImpl
                .getInstance("js://test.testNonFunctionElementsInJSController",
                        ControllerDef.class);
        Source<?> source = getJavascriptSourceLoader().getSource(descriptor);
        ControllerDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Javascript controller must only contain functions");
        } catch (Exception e) {
          this.checkExceptionContains(e, InvalidDefinitionException.class,
                            "JsonStreamParseException");
        }
View Full Code Here

                                "action_java://org.auraframework.impl.java.controller.JavaTestController/ACTION$getMultiParamLogging{we,we}{two,two}"));
    }

    @ThreadHostileTest("TestLoggingAdapter not thread-safe")
    public void testParamLogging_NullValuesForParameters() throws Exception {
        ControllerDef controller = getJavaController("java://org.auraframework.impl.java.controller.JavaTestController");
        Map<String, Object> params = Maps.newHashMap();
        Action selectParamLoggingAction = controller.createAction("getLoggableString", params);
        List<Map<String, Object>> logs = runActionsAndReturnLogs(Lists.newArrayList(selectParamLoggingAction));
        assertEquals(1, logs.size());
        assertTrue(
                "Failed to log a server action and param with null value",
                logs.get(0)
View Full Code Here

                                "action_java://org.auraframework.impl.java.controller.JavaTestController/ACTION$getLoggableString{param,null}"));
    }

    @ThreadHostileTest("TestLoggingAdapter not thread-safe")
    public void testParamLogging_ParametersOfCustomDataType() throws Exception {
        ControllerDef controller = getJavaController("java://org.auraframework.impl.java.controller.JavaTestController");
        Map<String, Object> params = Maps.newHashMap();
        params.put("param", new JavaTestController.CustomParamType());
        Action selectParamLoggingAction = controller.createAction("getCustomParamLogging", params);
        List<Map<String, Object>> logs = runActionsAndReturnLogs(Lists.newArrayList(selectParamLoggingAction));
        assertEquals(1, logs.size());
        assertTrue(
                "Logging custom action param time failed to call toString() of the custom type",
                logs.get(0)
View Full Code Here

                                "action_java://org.auraframework.impl.java.controller.JavaTestController/ACTION$getCustomParamLogging{param,CustomParamType_toString}"));
    }

    @ThreadHostileTest("TestLoggingAdapter not thread-safe")
    public void testParamLogging_ChainingActions() throws Exception {
        ControllerDef controller = getJavaController("java://org.auraframework.java.controller.ActionChainingController");
        Map<String, Object> params = Maps.newHashMap();
        params.put("a", 1);
        params.put("b", 1);
        params.put(
                "actions",
                "{\"actions\":[{\"descriptor\":\"java://org.auraframework.java.controller.ActionChainingController/ACTION$multiply\",\"params\":{\"a\":2}}]}");
        Action selectParamLoggingAction = controller.createAction("add", params);
        List<Map<String, Object>> logs = runActionsAndReturnLogs(Lists.newArrayList(selectParamLoggingAction));
        assertEquals(1, logs.size());
        assertTrue(
                "Failed to log server action",
                logs.get(0).containsKey(
View Full Code Here

     * Ensure that an action must be public. Currently, we do not actualy process non-public members. This is due to a
     * limitation in the way java returns methods. If we do want to do this, we'd have to process all methods in a
     * rather complex way (walking up the class hierarchy).
     */
    public void testProtectedAction() throws Exception {
        ControllerDef cont = getJavaController("java://org.auraframework.impl.java.controller.TestControllerWithProtectedAction");

        assertNotNull("could not find controller", cont);
        assertNull("should not have appendStrings", cont.getActionDefs().get("appendStrings"));
        assertNull("should not have doSomething", cont.getActionDefs().get("doSomething"));
        assertEquals("should have one method", 1, cont.getActionDefs().size());
        assertNotNull("should have doNothing", cont.getActionDefs().get("doNothing"));
    }
View Full Code Here

                InvalidDefinitionException.class, "Invalid non-static action in a controller: appendStrings",
                "java://org.auraframework.impl.java.controller.TestControllerWithNonStaticAction");
    }

    public void testActionNoParameters() throws Exception {
        ControllerDef controller = getJavaController("java://org.auraframework.impl.java.controller.TestController");
        Map<String, Object> empty = new HashMap<>();
        Map<String, Object> hasOne = new HashMap<>();
        hasOne.put("a", "don't care");
        assertNotNull("unable to load test controller", controller);
View Full Code Here

    /**
     * Verify correct errors are thrown when invalid parameters are passed to the controller.
     */
    public void testActionWithParametersError() throws Exception {
        ControllerDef controller = getJavaController("java://org.auraframework.impl.java.controller.TestControllerWithParameters");
        Map<String, Object> args = new HashMap<>();

        // A custom type parameter without a converter for what's passed to it (String)
        args.put("a", "x");
        checkFailAction(controller, "customParam", args, State.ERROR, AuraUnhandledException.class,
View Full Code Here

    /**
     * Test to ensure that parameters get passed correctly.
     */
    public void testActionWithParameters() throws Exception {
        ControllerDef controller = getJavaController("java://org.auraframework.impl.java.controller.TestControllerWithParameters");
        Map<String, Object> args = new HashMap<>();

        args.put("a", "x");
        args.put("b", "y");
        checkPassAction(controller, "appendStrings", args, State.SUCCESS, "xy");
View Full Code Here

TOP

Related Classes of org.auraframework.def.ControllerDef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.