/** * @Test this test needs to be revised (the json) public void testGroupUnmarshalling() throws * Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions * definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("group.json"), * "").getContents().get(0)); assertTrue(definitions.getRootElements().size() == 1); Process * process = getRootProcess(definitions); assertTrue(process.getArtifacts().iterator().next() * instanceof Group); definitions.eResource().save(System.out, Collections.emptyMap()); }* */ @Test public void testTextAnnotationUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller .unmarshall(getTestJsonFile("textAnnotation.json"), "") .getContents() .get(0)); assertTrue(definitions.getRootElements().size() == 1); Process process = getRootProcess(definitions); assertTrue(process.getArtifacts().iterator().next() instanceof TextAnnotation); TextAnnotation ta = (TextAnnotation) process.getArtifacts().iterator().next(); assertEquals("text annotation", ta.getText()); definitions.eResource().save(System.out, Collections.emptyMap()); }
@Test public void testAssociationUnmarshalling() throws Exception { Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller(); Definitions definitions = ((Definitions) unmarshaller.unmarshall(getTestJsonFile("association.json"), "").getContents().get(0)); assertTrue(definitions.getRootElements().size() == 1); Process process = getRootProcess(definitions); Task g = (Task) process.getFlowElements().get(0); assertEquals("task", g.getName()); TextAnnotation textA = (TextAnnotation) process.getArtifacts().get(0); Association association = (Association) process.getArtifacts().get(1); assertEquals(g, association.getSourceRef()); assertEquals(textA, association.getTargetRef()); assertEquals(AssociationDirection.NONE, association.getAssociationDirection()); definitions.eResource().save(System.out, Collections.emptyMap()); }
/** * @param <A> * @param target object that this artifact is being added to * @param artifact artifact to be added * @return */ public <T extends Artifact> T addArtifact(Object target, T artifact) { Process process = getOrCreateProcess(getParticipant(target)); process.getArtifacts().add(artifact); return artifact; }