@Test public void testIntrospect() { java.io.InputStream is= ClassLoader.getSystemResourceAsStream("testmodels/bpmn2/choreo/PurchaseGoodsNoInterfaces.bpmn"); try { org.savara.bpmn2.model.TDefinitions defns=BPMN2ModelUtil.deserialize(is); if (defns == null) { fail("No definitions returned"); } java.util.Map<TParticipant, TInterface> intfs=BPMN2ServiceUtil.introspect(defns); if (intfs == null) { fail("Null returned"); } if (intfs.size() != 3) { fail("Expected 3 participants: "+intfs.size()); } ModelInfo modelInfo=new ModelInfo(null, null, null, defns.getRootElement(), defns.getTargetNamespace()); for (TParticipant p : intfs.keySet()) { TInterface intf=intfs.get(p); if (intf == null) { fail("No interface for participant: "+p.getName()); } if (!intf.getName().equals(BPMN2ServiceUtil.getInterfaceName(p))) { fail("Interface name '"+intf.getName()+"' is incorrect"); } if (intf.getOperation().size() != 1) { fail("Should only be one operation:"+intf.getOperation().size()); } TOperation op=intf.getOperation().get(0); if (op.getOutMessageRef() == null || op.getInMessageRef() == null) { fail("Expected in and out message ref"); } String reqType=null; String respType=null; java.util.List<String> errorCodes=new java.util.Vector<String>(); if (p.getName().equals("Store")) { reqType = "BuyRequest"; respType = "BuyConfirmed"; errorCodes.add("AccountNotFound"); errorCodes.add("InsufficientCredit"); } else if (p.getName().equals("CreditAgency")) { reqType = "CreditCheck"; respType = "CreditRating"; errorCodes.add("CustomerUnknown"); } else if (p.getName().equals("Logistics")) { reqType = "DeliveryRequest"; respType = "DeliveryConfirmed"; } else { fail("Unknown participant: "+p.getName()); } TMessage m=modelInfo.getMessage(op.getInMessageRef().getLocalPart()); if (!m.getName().equals(reqType)) { fail("Expected "+reqType+": "+m.getName()); } m = modelInfo.getMessage(op.getOutMessageRef().getLocalPart()); if (!m.getName().equals(respType)) { fail("Expected "+respType+": "+m.getName()); } for (QName qname : op.getErrorRef()) { TError err = modelInfo.getError(qname.getLocalPart()); if (!errorCodes.contains(err.getErrorCode())) { fail("Invalid error code"); } else { errorCodes.remove(err.getErrorCode()); } } if (errorCodes.size() > 0) { fail("Not all expected error codes found"); } } } catch(Exception e) { e.printStackTrace(); fail("Failed to load BPMN2 definition: "+e); } }
public static java.util.Map<TParticipant,TInterface> introspect(TDefinitions defns) { java.util.Map<TParticipant,TInterface> ret=new java.util.HashMap<TParticipant,TInterface>(); for (JAXBElement<? extends TRootElement> elem : defns.getRootElement()) { if (elem.getDeclaredType() == TChoreography.class) { TChoreography choreo=(TChoreography)elem.getValue(); TStartEvent startEvent=null; for (JAXBElement<? extends TFlowElement> jaxb : choreo.getFlowElement()) { if (jaxb.getValue().getClass() == TStartEvent.class) { if (startEvent != null) { LOG.severe("Multiple start events found in choreography"); } else { startEvent = (TStartEvent)jaxb.getValue(); } } } if (startEvent != null) { processNode(defns, startEvent, ret, new java.util.Vector<InteractionInfo>(), new ModelInfo(choreo.getParticipant(), choreo.getMessageFlow(), choreo.getFlowElement(), defns.getRootElement(), defns.getTargetNamespace()), new java.util.Vector<TFlowNode>()); } } } return (ret); }
BPMN2ServiceUtil { public static java.util.Map<TParticipant,TInterface> introspect(TDefinitions defns) { java.util.Map<TParticipant,TInterface> ret=new java.util.HashMap<TParticipant,TInterface>(); for (JAXBElement<? extends TRootElement> elem : defns.getRootElement()) { if (elem.getDeclaredType() == TChoreography.class) { TChoreography choreo=(TChoreography)elem.getValue(); TStartEvent startEvent=null; for (JAXBElement<? extends TFlowElement> jaxb : choreo.getFlowElement()) { if (jaxb.getValue().getClass() == TStartEvent.class) { if (startEvent != null) { LOG.severe("Multiple start events found in choreography"); } else { startEvent = (TStartEvent)jaxb.getValue(); } } } if (startEvent != null) { processNode(defns, startEvent, ret, new java.util.Vector<InteractionInfo>(), new ModelInfo(choreo.getParticipant(), choreo.getMessageFlow(), choreo.getFlowElement(), defns.getRootElement(), defns.getTargetNamespace()), new java.util.Vector<TFlowNode>()); } } } return (ret); } }
BPMN2ServiceUtil { public static java.util.Map<TParticipant,TInterface> introspect(TDefinitions defns) { java.util.Map<TParticipant,TInterface> ret=new java.util.HashMap<TParticipant,TInterface>(); for (JAXBElement<? extends TRootElement> elem : defns.getRootElement()) { if (elem.getDeclaredType() == TChoreography.class) { TChoreography choreo=(TChoreography)elem.getValue(); TStartEvent startEvent=null; for (JAXBElement<? extends TFlowElement> jaxb : choreo.getFlowElement()) { if (jaxb.getValue().getClass() == TStartEvent.class) { if (startEvent != null) { LOG.severe("Multiple start events found in choreography"); } else { startEvent = (TStartEvent)jaxb.getValue(); } } } if (startEvent != null) { processNode(defns, startEvent, ret, new java.util.Vector<InteractionInfo>(), new ModelInfo(choreo.getParticipant(), choreo.getMessageFlow(), choreo.getFlowElement(), defns.getRootElement(), defns.getTargetNamespace()), new java.util.Vector<TFlowNode>()); } } } return (ret); }  }
BPMN2ServiceUtil { public static java.util.Map<TParticipant,TInterface> introspect(TDefinitions defns) { java.util.Map<TParticipant,TInterface> ret=new java.util.HashMap<TParticipant,TInterface>(); for (JAXBElement<? extends TRootElement> elem : defns.getRootElement()) { if (elem.getDeclaredType() == TChoreography.class) { TChoreography choreo=(TChoreography)elem.getValue(); TStartEvent startEvent=null; for (JAXBElement<? extends TFlowElement> jaxb : choreo.getFlowElement()) { if (jaxb.getValue().getClass() == TStartEvent.class) { if (startEvent != null) { LOG.severe("Multiple start events found in choreography"); } else { startEvent = (TStartEvent)jaxb.getValue(); } } } if (startEvent != null) { processNode(defns, startEvent, ret, new java.util.Vector<InteractionInfo>(), new ModelInfo(choreo.getParticipant(), choreo.getMessageFlow(), choreo.getFlowElement(), defns.getRootElement(), defns.getTargetNamespace()), new java.util.Vector<TFlowNode>()); } } } return (ret); }  static java.util.Map<TParticipant,TInterface> introspect(TDefinitions defns); static String getInterfaceName(TParticipant participant); static String getOperationName(TMessage message); static void merge(TDefinitions defns, java.util.Map<TParticipant,TInterface> interfaces); }
BPMN2ServiceUtil { public static java.util.Map<TParticipant,TInterface> introspect(TDefinitions defns) { java.util.Map<TParticipant,TInterface> ret=new java.util.HashMap<TParticipant,TInterface>(); for (JAXBElement<? extends TRootElement> elem : defns.getRootElement()) { if (elem.getDeclaredType() == TChoreography.class) { TChoreography choreo=(TChoreography)elem.getValue(); TStartEvent startEvent=null; for (JAXBElement<? extends TFlowElement> jaxb : choreo.getFlowElement()) { if (jaxb.getValue().getClass() == TStartEvent.class) { if (startEvent != null) { LOG.severe("Multiple start events found in choreography"); } else { startEvent = (TStartEvent)jaxb.getValue(); } } } if (startEvent != null) { processNode(defns, startEvent, ret, new java.util.Vector<InteractionInfo>(), new ModelInfo(choreo.getParticipant(), choreo.getMessageFlow(), choreo.getFlowElement(), defns.getRootElement(), defns.getTargetNamespace()), new java.util.Vector<TFlowNode>()); } } } return (ret); }  static java.util.Map<TParticipant,TInterface> introspect(TDefinitions defns); static String getInterfaceName(TParticipant participant); static String getOperationName(TMessage message); static void merge(TDefinitions defns, java.util.Map<TParticipant,TInterface> interfaces); static final String INTERFACE_ID_SUFFIX; }