CallTraceServiceImpl implements CallTraceService { protected static java.util.List<ActivityUnit> getTopLevelAUs(CTState state) { java.util.List<ActivityUnit> ret=new java.util.ArrayList<ActivityUnit>(); for (ActivityUnit au : state.getActivityUnits()) { for (ActivityType at : au.getActivityTypes()) { if (at instanceof RequestReceived && state.getSOAActivity(RequestSent.class, ((RequestReceived)at).getServiceType(), ((RequestReceived)at).getOperation()) == null) { ret.add(au); continue; } } } return (ret); }  void setActivityServer(ActivityServer as); ActivityServer getActivityServer(); CallTrace createCallTrace(Context context);  }
@Test public void testTopLevelAUs1() { ActivityUnit au1=new ActivityUnit(); RequestReceived rr1=new RequestReceived(); rr1.setServiceType("st1"); rr1.setOperation("op1"); au1.getActivityTypes().add(rr1); ActivityUnit au2=new ActivityUnit(); RequestReceived rr2=new RequestReceived(); rr2.setServiceType("st2"); rr2.setOperation("op2"); au2.getActivityTypes().add(rr2); CTState state=new CTState(); state.add(au1); state.add(au2); java.util.List<ActivityUnit> tl=CallTraceServiceImpl.getTopLevelAUs(state); if (tl.size() != 2) { fail("Should be two top level aus: "+tl.size()); } }
@Test public void testTopLevelAUs2() { ActivityUnit au1=new ActivityUnit(); RequestReceived rr1=new RequestReceived(); rr1.setServiceType("st1"); rr1.setOperation("op1"); au1.getActivityTypes().add(rr1); ActivityUnit au2=new ActivityUnit(); RequestReceived rr2=new RequestReceived(); rr2.setServiceType("st2"); rr2.setOperation("op2"); au2.getActivityTypes().add(rr2); ActivityUnit au3=new ActivityUnit(); RequestSent rs2=new RequestSent(); rs2.setServiceType("st2"); rs2.setOperation("op2"); au3.getActivityTypes().add(rs2); CTState state=new CTState(); state.add(au1); state.add(au2); state.add(au3); java.util.List<ActivityUnit> tl=CallTraceServiceImpl.getTopLevelAUs(state); if (tl.size() != 1) { fail("Should be 1 top level aus: "+tl.size()); } if (tl.get(0) != au1) { fail("Should be au1"); } }