MarkerToActivityConverter { IScope createScopeForMarkers(IActivity a) { IActivityContainer parent = a.getParent(); IScope scope = parent.wrapActivityInNewScope(a); scope.setName(CoverageConstants.INSTRUMENTATION_SCOPE_NAME_PREFIX + a.getName()); ISequence sequence = scope.wrapActivityInNewSequence(a); IVariable v = scope.addVariable(); v.setName(CoverageConstants.VARIABLE_MARK_REQUEST); v.setMessageType(CoverageConstants.MARKER_SERVICE_MARK_REQUEST_MESSAGE_TYPE); IAssign assign = sequence.addAssign(); assign.setName(a.getName() + "_Prepare_Mark_Request"); ICopy copy = assign.addCopy(); Element msgElement = copy.getFrom().setNewLiteral( CoverageConstants.MARKER_SERVICE_NAMESPACE, CoverageConstants.COVERAGE_MSG_ELEMENT); buildCoverageMarkerMessage(msgElement, a); copy.getTo().setVariable(v); copy.getTo() .setPart(CoverageConstants.MARKER_SERVICE_MARK_REQUEST_PART); copy.getTo().setExpression("/"); IInvoke invoke = sequence.addInvoke(); invoke.setName(a.getName() + "_Invoke_Marker_Service"); invoke.setInputVariable(v); invoke.setOperation(CoverageConstants.COVERAGE_SERVICE_MARK_OPERATION); invoke.setPartnerLink(CoverageConstants.MARKER_SERVICE_PARTNERLINK); if (startsInstance(a)) { sequence.moveBefore(assign, a); sequence.moveBefore(invoke, a); } return scope; }  void convertMarkersToActivities(IBPELUnitContext context);  }
@Test public void testCreateScopeForMarkers() throws Exception { addThreeMarkersToActivity(); markerToActivityConverter.createScopeForMarkers(activity); IScope scope = (IScope)p.getMainActivity(); assertEquals("__BPELUNIT_MARK_REQUEST__", scope.getVariables().get(0).getName()); ISequence seq = (ISequence)scope.getMainActivity(); assertTrue(seq.getActivities().get(0) instanceof IAssign); assertTrue(seq.getActivities().get(1) instanceof IInvoke); assertSame(activity, seq.getActivities().get(2)); }