Package org.auraframework.instance

Examples of org.auraframework.instance.Action$Serializer


    public static int i = 0;

    @AuraEnabled
    public static int add(@Key("a") Integer a, @Key("b") Integer b, @Key("actions") String chainedActions)
            throws Exception {
        Action currentAction = Aura.getContextService().getCurrentContext().getCurrentAction();
        Collection<Action> actions = Aura.getSerializationService().readCollection(new StringReader(chainedActions),
                Action.class);
        currentAction.add(Lists.newArrayList(actions));
        i = a + b;
        return i;
    }
View Full Code Here


        return i;
    }

    @AuraEnabled
    public static void doNothing(@Key("actions") String chainedActions) throws Exception {
        Action currentAction = Aura.getContextService().getCurrentContext().getCurrentAction();
        Collection<Action> actions = Aura.getSerializationService().readCollection(new StringReader(chainedActions),
                Action.class);
        currentAction.add(Lists.newArrayList(actions));
    }
View Full Code Here

        currentAction.add(Lists.newArrayList(actions));
    }

    @AuraEnabled
    public static void infiniteChain() throws Exception {
        Action currentAction = Aura.getContextService().getCurrentContext().getCurrentAction();
        Action actions = Aura.getInstanceService().getInstance(
                "java://org.auraframework.java.controller.ActionChainingController/ACTION$infiniteChain",
                ActionDef.class, null);
        currentAction.add(Lists.newArrayList(actions));
    }
View Full Code Here

            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

TOP

Related Classes of org.auraframework.instance.Action$Serializer

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.