Package org.auraframework.instance

Examples of org.auraframework.instance.Action


            throws Exception {
        Map<String, Object> params = Maps.newHashMap();
        params.put("section", section);
        params.put("name", name);

        Action instance = (Action) Aura.getInstanceService().getInstance(getLabelDesc,
                ActionDef.class, params);
        instance.run();
        assertEquals(expectedStatus, instance.getState());
        assertEquals(expectedLabel, instance.getReturnValue());

        return instance;
    }
View Full Code Here


                    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();
                    } finally {
                        context.setCurrentAction(previous);
                    }
View Full Code Here

      attributesC.put("attr", "attrC");
    Component sharedCmp = Aura.getInstanceService().getInstance("ifTest:testIfWithModel", ComponentDef.class,
                attributes);
      StringWriter sw = new StringWriter();
        ServerService ss = Aura.getServerService();
        Action a = new EmptyAction(sw,"first action");
        Action b = new EmptyAction(sw,"second action");
        Action c = new EmptyAction(sw,"third action");
        Action d = new ShareCmpAction("d",a,sharedCmp,attributesA);
        Action e = new ShareCmpAction("e",b,sharedCmp,attributesB);
        Action f = new ShareCmpAction("f",c,sharedCmp,attributesC);
        List<Action> actions = Lists.newArrayList(d,e,f);
        Message message = new Message(actions);
        //run the list of actions.
        ss.run(message, Aura.getContextService().getCurrentContext(), sw, null);
       
        //sanity check, sharedCmp should have the latest attribute value.
        //this has nothing to do with the fix though
        assertEquals("attrC",sharedCmp.getAttributes().getValue("attr"));
        //Here are the checks for fix
        //returnValue of action e is going to have shared component from action d in Json format
        String returne = (String) e.getReturnValue();
        assertTrue(returne.contains("markup://ifTest:testIfWithModel"));
        assertTrue(returne.contains("\"attr\":\"attrA\""));
        //returnValue of action f is going to have shared component from action e in Json format
        String returnf = (String) f.getReturnValue();
        assertTrue(returnf.contains("markup://ifTest:testIfWithModel"));
        assertTrue(returnf.contains("\"attr\":\"attrB\""));
       
    }
View Full Code Here

     */
    public void testMultipleActions() throws Exception {
      Aura.getContextService().startContext(Mode.UTEST, Format.JSON, Authentication.AUTHENTICATED);
      StringWriter sw = new StringWriter();
        ServerService ss = Aura.getServerService();
        Action a = new EmptyAction(sw,"first action");
        Action b = new EmptyAction(sw,"second action");
        Action c = new EmptyAction(sw,"third action");
        List<Action> actions = Lists.newArrayList(a,b,c);
        Message message = new Message(actions);
        //run the list of actions.
        ss.run(message, Aura.getContextService().getCurrentContext(), sw, null);
        String returnValuea = "{\"actions\":[";
        String returnValueb = returnValuea+"{\"action\":\"firstaction\"}";
        String returnValuec = returnValueb+",{\"action\":\"secondaction\"}";
       
        List<String> returnValueList = Arrays.asList(returnValuea,returnValueb,returnValuec);
        for(int i=0;i<actions.size();i++) {
          Action act = actions.get(i);
          assertEquals("get different action return on i:"+i,
              returnValueList.get(i),((String)act.getReturnValue()).replaceAll("\\s+", ""));
        }
       
        validateEmptyActionSerialization(sw.toString(), null, Arrays.asList("first action","second action","third action"));
    }
View Full Code Here

     */
    public void testSameActionTwice() throws Exception {
      Aura.getContextService().startContext(Mode.UTEST, Format.JSON, Authentication.AUTHENTICATED);
      StringWriter sw = new StringWriter();
        ServerService ss = Aura.getServerService();
        Action a = new EmptyAction(sw,"first action");
        Action b = new EmptyAction(sw,"second action");
        List<Action> actions = Lists.newArrayList(a,b,a,b);
        Message message = new Message(actions);
        ss.run(message, Aura.getContextService().getCurrentContext(), sw, null);
        assertTrue(((EmptyAction)a).getCount()==2);
        assertTrue(((EmptyAction)b).getCount()==2);
View Full Code Here

     */
    public void testSimpleAction() throws Exception {
        Aura.getContextService().startContext(Mode.UTEST, Format.JSON, Authentication.AUTHENTICATED);

        ServerService ss = Aura.getServerService();
        Action a = new EmptyAction();
        List<Action> actions = Lists.newArrayList(a);
        Message message = new Message(actions);
        StringWriter sw = new StringWriter();
        ss.run(message, Aura.getContextService().getCurrentContext(), sw, null);
        validateEmptyActionSerialization(sw.toString(), null, Arrays.asList("simpleaction"));
View Full Code Here

     */
    public void testSimpleActionWithExtras() throws Exception {
        Aura.getContextService().startContext(Mode.UTEST, Format.JSON, Authentication.AUTHENTICATED);
     
        ServerService ss = Aura.getServerService();
        Action a = new EmptyAction();
        List<Action> actions = Lists.newArrayList(a);
        Map<String,String> extras = Maps.newHashMap();
        Message message = new Message(actions);
        StringWriter sw = new StringWriter();
        extras.put("this", "that");
View Full Code Here

        }
    }

    private void checkPassAction(ControllerDef controller, String name, Map<String, Object> args, State expState,
            Object returnValue) throws DefinitionNotFoundException {
        Action action = controller.createAction(name, args);
        action.run();
        assertEquals(name + " State", expState, action.getState());
        assertEquals(name + " expected no errors", 0, action.getErrors().size());
        assertEquals(name + " return", returnValue, action.getReturnValue());
    }
View Full Code Here

        assertEquals(name + " return", returnValue, action.getReturnValue());
    }

    private void checkFailAction(ControllerDef controller, String name, Map<String, Object> args, State expState,
            Class<? extends Exception> error, String errorMessage) throws DefinitionNotFoundException {
        Action action = controller.createAction(name, args);
        action.run();
        assertEquals(name + " State", expState, action.getState());
        assertEquals(name + " expected an error", 1, action.getErrors().size());
        checkExceptionContains((Exception) action.getErrors().get(0), error, errorMessage);
        assertEquals(name + " return", null, action.getReturnValue());
    }
View Full Code Here

    /**
     * Tests to verify the APIs on Action to mark actions as storable.
     */
    public void testStorable() throws Exception {
        ControllerDef controller = getJavaController("java://org.auraframework.impl.java.controller.TestController");
        Action freshAction = controller.createAction("getString", null);

        assertTrue("Expected an instance of JavaAction", freshAction instanceof JavaAction);
        JavaAction action = (JavaAction) freshAction;
        assertFalse("Actions should not be storable by default.", action.isStorable());
        action.run();
        assertFalse("isStorabel should not change values after action execution.", action.isStorable());

        Action storableAction = controller.createAction("getString", null);
        action = (JavaAction) storableAction;
        action.setStorable();
        assertTrue("Failed to mark a action as storable.", action.isStorable());
        action.run();
        assertTrue("Storable action was unmarked during execution", action.isStorable());
View Full Code Here

TOP

Related Classes of org.auraframework.instance.Action

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.