CallTraceServiceImpl implements CallTraceService { protected static CallTrace processAUs(CTState state) { CallTrace ret=new CallTrace(); java.util.List<ActivityUnit> topLevel=getTopLevelAUs(state); state.getTasksStack().push(ret.getTasks()); for (ActivityUnit au : topLevel) { processAU(state, au, topLevel); } state.finalizeScope(); long duration=0; for (TraceNode tn : ret.getTasks()) { duration += tn.getDuration(); } for (TraceNode tn : ret.getTasks()) { initPercentages(duration, tn); } return (ret); }  void setActivityServer(ActivityServer as); ActivityServer getActivityServer(); CallTrace createCallTrace(Context context);  }
@Test public void testProcessAUSingleUnit2Service() { ActivityUnit au1=new ActivityUnit(); au1.setId("au1"); RequestReceived a1=new RequestReceived(); a1.setServiceType("st1"); a1.setOperation("op1"); a1.setTimestamp(0); au1.getActivityTypes().add(a1); ProcessStarted p1=new ProcessStarted(); p1.setProcessType("proc1"); p1.setVersion("1"); p1.setInstanceId("456"); p1.setTimestamp(10); au1.getActivityTypes().add(p1); RequestSent a2=new RequestSent(); a2.setServiceType("st2"); a2.setOperation("op2"); a2.setTimestamp(30); au1.getActivityTypes().add(a2); RequestReceived a3=new RequestReceived(); a3.setServiceType("st2"); a3.setOperation("op2"); a3.setTimestamp(37); au1.getActivityTypes().add(a3); ProcessStarted p2=new ProcessStarted(); p2.setProcessType("proc2"); p2.setVersion("2"); p2.setInstanceId("123"); p2.setTimestamp(48); au1.getActivityTypes().add(p2); ProcessCompleted p3=new ProcessCompleted(); p3.setInstanceId("123"); p3.setStatus(Status.Success); p3.setTimestamp(57); au1.getActivityTypes().add(p3); ResponseSent a4=new ResponseSent(); a4.setServiceType("st2"); a4.setOperation("op2"); a4.setTimestamp(59); au1.getActivityTypes().add(a4); ResponseReceived a5=new ResponseReceived(); a5.setServiceType("st2"); a5.setOperation("op2"); a5.setTimestamp(67); au1.getActivityTypes().add(a5); ProcessCompleted p4=new ProcessCompleted(); p4.setInstanceId("456"); p4.setStatus(Status.Fail); p4.setTimestamp(83); au1.getActivityTypes().add(p4); ResponseSent a6=new ResponseSent(); a6.setServiceType("st1"); a6.setOperation("op1"); a6.setTimestamp(88); au1.getActivityTypes().add(a6); CTState state=new CTState(); au1.init(); state.add(au1); CallTrace ct=CallTraceServiceImpl.processAUs(state); compare(ct, "SingleUnit2Service", "CallTrace1"); }
@Test public void testProcessAUSeparateUnits2Service() { ActivityUnit au1=new ActivityUnit(); au1.setId("au1"); ActivityUnit au2=new ActivityUnit(); au2.setId("au2"); RequestReceived a1=new RequestReceived(); a1.setServiceType("st1"); a1.setOperation("op1"); a1.setTimestamp(0); au1.getActivityTypes().add(a1); ProcessStarted p1=new ProcessStarted(); p1.setProcessType("proc1"); p1.setVersion("1"); p1.setInstanceId("456"); p1.setTimestamp(10); au1.getActivityTypes().add(p1); RequestSent a2=new RequestSent(); a2.setServiceType("st2"); a2.setOperation("op2"); a2.setTimestamp(30); au1.getActivityTypes().add(a2); RequestReceived a3=new RequestReceived(); a3.setServiceType("st2"); a3.setOperation("op2"); a3.setTimestamp(37); au2.getActivityTypes().add(a3); ProcessStarted p2=new ProcessStarted(); p2.setProcessType("proc2"); p2.setVersion("2"); p2.setInstanceId("123"); p2.setTimestamp(48); au2.getActivityTypes().add(p2); ProcessCompleted p3=new ProcessCompleted(); p3.setInstanceId("123"); p3.setStatus(Status.Success); p3.setTimestamp(57); au2.getActivityTypes().add(p3); ResponseSent a4=new ResponseSent(); a4.setServiceType("st2"); a4.setOperation("op2"); a4.setTimestamp(59); au2.getActivityTypes().add(a4); ResponseReceived a5=new ResponseReceived(); a5.setServiceType("st2"); a5.setOperation("op2"); a5.setTimestamp(67); au1.getActivityTypes().add(a5); ProcessCompleted p4=new ProcessCompleted(); p4.setInstanceId("456"); p4.setStatus(Status.Fail); p4.setTimestamp(83); au1.getActivityTypes().add(p4); ResponseSent a6=new ResponseSent(); a6.setServiceType("st1"); a6.setOperation("op1"); a6.setTimestamp(88); au1.getActivityTypes().add(a6); CTState state=new CTState(); au1.init(); state.add(au1); au2.init(); state.add(au2); CallTrace ct=CallTraceServiceImpl.processAUs(state); compare(ct, "SeparateUnits2Service", "CallTrace1"); }
@Test public void testProcessAUSeparateUnits2Service2() { ActivityUnit au1=new ActivityUnit(); au1.setId("au1"); ActivityUnit au2=new ActivityUnit(); au2.setId("au2"); ActivityUnit au3=new ActivityUnit(); au3.setId("au3"); RequestReceived a1=new RequestReceived(); a1.setServiceType("st1"); a1.setOperation("op1"); a1.setTimestamp(0); au1.getActivityTypes().add(a1); ProcessStarted p1=new ProcessStarted(); p1.setProcessType("proc1"); p1.setVersion("1"); p1.setInstanceId("456"); p1.setTimestamp(10); au1.getActivityTypes().add(p1); RequestSent a2=new RequestSent(); a2.setServiceType("st2"); a2.setOperation("op2"); a2.setTimestamp(30); au1.getActivityTypes().add(a2); RequestReceived a3=new RequestReceived(); a3.setServiceType("st2"); a3.setOperation("op2"); a3.setTimestamp(37); au2.getActivityTypes().add(a3); ProcessStarted p2=new ProcessStarted(); p2.setProcessType("proc2"); p2.setVersion("2"); p2.setInstanceId("123"); p2.setTimestamp(48); au2.getActivityTypes().add(p2); ProcessCompleted p3=new ProcessCompleted(); p3.setInstanceId("123"); p3.setStatus(Status.Success); p3.setTimestamp(57); au3.getActivityTypes().add(p3); ResponseSent a4=new ResponseSent(); a4.setServiceType("st2"); a4.setOperation("op2"); a4.setTimestamp(59); au3.getActivityTypes().add(a4); ResponseReceived a5=new ResponseReceived(); a5.setServiceType("st2"); a5.setOperation("op2"); a5.setTimestamp(67); au1.getActivityTypes().add(a5); ProcessCompleted p4=new ProcessCompleted(); p4.setInstanceId("456"); p4.setStatus(Status.Fail); p4.setTimestamp(83); au1.getActivityTypes().add(p4); ResponseSent a6=new ResponseSent(); a6.setServiceType("st1"); a6.setOperation("op1"); a6.setTimestamp(88); au1.getActivityTypes().add(a6); CTState state=new CTState(); au1.init(); state.add(au1); au2.init(); state.add(au2); au3.init(); state.add(au3); CallTrace ct=CallTraceServiceImpl.processAUs(state); compare(ct, "SeparateUnits2Service2", "CallTrace1"); }
@Test public void testProcessAUSingleUnit2ServiceFault() { ActivityUnit au1=new ActivityUnit(); au1.setId("au1"); RequestReceived a1=new RequestReceived(); a1.setServiceType("st1"); a1.setOperation("op1"); a1.setTimestamp(0); au1.getActivityTypes().add(a1); ProcessStarted p1=new ProcessStarted(); p1.setProcessType("proc1"); p1.setVersion("1"); p1.setInstanceId("456"); p1.setTimestamp(10); au1.getActivityTypes().add(p1); RequestSent a2=new RequestSent(); a2.setServiceType("st2"); a2.setOperation("op2"); a2.setTimestamp(30); au1.getActivityTypes().add(a2); RequestReceived a3=new RequestReceived(); a3.setServiceType("st2"); a3.setOperation("op2"); a3.setTimestamp(37); au1.getActivityTypes().add(a3); ProcessStarted p2=new ProcessStarted(); p2.setProcessType("proc2"); p2.setVersion("2"); p2.setInstanceId("123"); p2.setTimestamp(48); au1.getActivityTypes().add(p2); ProcessCompleted p3=new ProcessCompleted(); p3.setInstanceId("123"); p3.setStatus(Status.Success); p3.setTimestamp(57); au1.getActivityTypes().add(p3); ResponseSent a4=new ResponseSent(); a4.setServiceType("st2"); a4.setOperation("op2"); a4.setFault("Failed"); a4.setTimestamp(59); au1.getActivityTypes().add(a4); ResponseReceived a5=new ResponseReceived(); a5.setServiceType("st2"); a5.setOperation("op2"); a5.setFault("Failed"); a5.setTimestamp(67); au1.getActivityTypes().add(a5); ProcessCompleted p4=new ProcessCompleted(); p4.setInstanceId("456"); p4.setStatus(Status.Fail); p4.setTimestamp(83); au1.getActivityTypes().add(p4); ResponseSent a6=new ResponseSent(); a6.setServiceType("st1"); a6.setOperation("op1"); a6.setTimestamp(88); au1.getActivityTypes().add(a6); CTState state=new CTState(); au1.init(); state.add(au1); CallTrace ct=CallTraceServiceImpl.processAUs(state); compare(ct, "SingleUnit2ServiceFault", "CallTrace2"); }
@Test public void testProcessAUSeparateUnits2ServiceOneWayWithSentResp() { ActivityUnit au1=new ActivityUnit(); au1.setId("au1"); ActivityUnit au2=new ActivityUnit(); au2.setId("au2"); ActivityUnit au3=new ActivityUnit(); au3.setId("au3"); RequestReceived a1=new RequestReceived(); a1.setServiceType("st1"); a1.setOperation("op1"); a1.setTimestamp(0); au1.getActivityTypes().add(a1); ProcessStarted p1=new ProcessStarted(); p1.setProcessType("proc1"); p1.setVersion("1"); p1.setInstanceId("456"); p1.setTimestamp(10); au1.getActivityTypes().add(p1); RequestSent a2=new RequestSent(); a2.setServiceType("st2"); a2.setOperation("op2"); a2.setTimestamp(30); au1.getActivityTypes().add(a2); RequestReceived a3=new RequestReceived(); a3.setServiceType("st2"); a3.setOperation("op2"); a3.setTimestamp(37); au2.getActivityTypes().add(a3); ProcessStarted p2=new ProcessStarted(); p2.setProcessType("proc2"); p2.setVersion("2"); p2.setInstanceId("123"); p2.setTimestamp(48); au2.getActivityTypes().add(p2); ProcessCompleted p3=new ProcessCompleted(); p3.setInstanceId("123"); p3.setStatus(Status.Success); p3.setTimestamp(57); au3.getActivityTypes().add(p3); ResponseSent a4=new ResponseSent(); a4.setServiceType("st2"); a4.setOperation("op2"); a4.setTimestamp(59); au3.getActivityTypes().add(a4); ProcessCompleted p4=new ProcessCompleted(); p4.setInstanceId("456"); p4.setStatus(Status.Fail); p4.setTimestamp(83); au1.getActivityTypes().add(p4); ResponseSent a6=new ResponseSent(); a6.setServiceType("st1"); a6.setOperation("op1"); a6.setTimestamp(88); au1.getActivityTypes().add(a6); CTState state=new CTState(); au1.init(); state.add(au1); au2.init(); state.add(au2); au3.init(); state.add(au3); CallTrace ct=CallTraceServiceImpl.processAUs(state); compare(ct, "testProcessAUSeparateUnits2ServiceOneWayWithSentResp", "CallTrace3"); }
@Test public void testProcessAUSeparateUnits2ServiceOneWayNoResp() { ActivityUnit au1=new ActivityUnit(); au1.setId("au1"); ActivityUnit au2=new ActivityUnit(); au2.setId("au2"); ActivityUnit au3=new ActivityUnit(); au3.setId("au3"); RequestReceived a1=new RequestReceived(); a1.setServiceType("st1"); a1.setOperation("op1"); a1.setTimestamp(0); au1.getActivityTypes().add(a1); ProcessStarted p1=new ProcessStarted(); p1.setProcessType("proc1"); p1.setVersion("1"); p1.setInstanceId("456"); p1.setTimestamp(10); au1.getActivityTypes().add(p1); RequestSent a2=new RequestSent(); a2.setServiceType("st2"); a2.setOperation("op2"); a2.setTimestamp(30); au1.getActivityTypes().add(a2); RequestReceived a3=new RequestReceived(); a3.setServiceType("st2"); a3.setOperation("op2"); a3.setTimestamp(37); au2.getActivityTypes().add(a3); ProcessStarted p2=new ProcessStarted(); p2.setProcessType("proc2"); p2.setVersion("2"); p2.setInstanceId("123"); p2.setTimestamp(48); au2.getActivityTypes().add(p2); ProcessCompleted p3=new ProcessCompleted(); p3.setInstanceId("123"); p3.setStatus(Status.Success); p3.setTimestamp(57); au3.getActivityTypes().add(p3); ProcessCompleted p4=new ProcessCompleted(); p4.setInstanceId("456"); p4.setStatus(Status.Fail); p4.setTimestamp(83); au1.getActivityTypes().add(p4); ResponseSent a6=new ResponseSent(); a6.setServiceType("st1"); a6.setOperation("op1"); a6.setTimestamp(88); au1.getActivityTypes().add(a6); CTState state=new CTState(); au1.init(); state.add(au1); au2.init(); state.add(au2); au3.init(); state.add(au3); CallTrace ct=CallTraceServiceImpl.processAUs(state); compare(ct, "testProcessAUSeparateUnits2ServiceOneWayNoResp", "CallTrace3"); }
@Test public void testProcessAUSOAAndBPMInterleaved() { try { ActivityUnit au1=new ActivityUnit(); au1.setId("au1"); ActivityUnit au2=new ActivityUnit(); au2.setId("au2"); ActivityUnit au3=new ActivityUnit(); au3.setId("au3"); RequestReceived a1=new RequestReceived(); a1.setServiceType("st1"); a1.setOperation("op1"); a1.setMessageId("m0"); a1.setTimestamp(0); a1.getContext().add(new Context(Type.Conversation, "1")); au1.getActivityTypes().add(a1); ProcessStarted p1=new ProcessStarted(); p1.setProcessType("proc1"); p1.setVersion("1"); p1.setInstanceId("456"); p1.setTimestamp(10); au1.getActivityTypes().add(p1); RequestSent a2=new RequestSent(); a2.setServiceType("st2"); a2.setOperation("op2"); a2.setMessageId("m1"); a2.setTimestamp(30); a2.getContext().add(new Context(Type.Conversation, "1")); au1.getActivityTypes().add(a2); RequestReceived a3=new RequestReceived(); a3.setServiceType("st2"); a3.setOperation("op2"); a3.setMessageId("m1"); a3.setTimestamp(37); a3.getContext().add(new Context(Type.Conversation, "1")); au2.getActivityTypes().add(a3); ProcessStarted p2=new ProcessStarted(); p2.setProcessType("proc2"); p2.setVersion("2"); p2.setInstanceId("123"); p2.setTimestamp(48); au2.getActivityTypes().add(p2); ProcessCompleted p3=new ProcessCompleted(); p3.setInstanceId("123"); p3.setStatus(Status.Success); p3.setTimestamp(57); au3.getActivityTypes().add(p3); ResponseSent a4=new ResponseSent(); a4.setServiceType("st2"); a4.setOperation("op2"); a4.setMessageId("m2"); a4.setReplyToId("m1"); a4.setTimestamp(59); a4.getContext().add(new Context(Type.Conversation, "1")); au3.getActivityTypes().add(a4); ResponseReceived a5=new ResponseReceived(); a5.setServiceType("st2"); a5.setOperation("op2"); a5.setMessageId("m2"); a5.setReplyToId("m1"); a5.setTimestamp(67); a5.getContext().add(new Context(Type.Conversation, "1")); au1.getActivityTypes().add(a5); ProcessCompleted p4=new ProcessCompleted(); p4.setInstanceId("456"); p4.setStatus(Status.Fail); p4.setTimestamp(83); au1.getActivityTypes().add(p4); ResponseSent a6=new ResponseSent(); a6.setServiceType("st1"); a6.setOperation("op1"); a4.setMessageId("m3"); a4.setReplyToId("m0"); a6.setTimestamp(88); a6.getContext().add(new Context(Type.Conversation, "1")); au1.getActivityTypes().add(a6); au1.init(); au2.init(); au3.init(); java.util.List<ActivityUnit> activities=new java.util.ArrayList<ActivityUnit>(); activities.add(au1); activities.add(au2); activities.add(au3); CTState state=new CTState(); au1.init(); state.add(au1); au2.init(); state.add(au2); au3.init(); state.add(au3); CallTrace ct=CallTraceServiceImpl.processAUs(state); compare(ct, "testProcessAUSOAAndBPMInterleaved", "CallTrace4"); } catch(Exception e) { e.printStackTrace(); fail("Failed to access activity server: "+e); } }