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\""));
}