use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project kie-wb-common by kiegroup.
the class BPMNValidatorImpl method init.
@PostConstruct
protected void init() {
modules = new SemanticModules();
modules.addSemanticModule(new BPMNSemanticModule());
modules.addSemanticModule(new BPMNDISemanticModule());
}
use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project jbpm by kiegroup.
the class BPMN2XMLTest method testInvalidXMLInCompositeNode.
public void testInvalidXMLInCompositeNode() throws Exception, SAXException {
SemanticModules modules = new SemanticModules();
modules.addSemanticModule(new BPMNSemanticModule());
modules.addSemanticModule(new BPMNDISemanticModule());
XmlProcessReader processReader = new XmlProcessReader(modules, getClass().getClassLoader()) {
@Override
protected String processParserMessage(Collection<Object> parents, org.xml.sax.Attributes attr, String errorMessage) {
setErrorMessage(super.processParserMessage(parents, attr, errorMessage));
return errorMessage;
}
};
processReader.read(BPMN2XMLTest.class.getResourceAsStream("/BPMN2-XMLProcessWithErrorInCompositeNode.bpmn2"));
assertNotNull(getErrorMessage());
assertThat(getErrorMessage()).contains("Process Info: id:abc.abc, pkg:org.drools.bpmn2, name:abc, version:1.0 \n" + "Node Info: id:_47489F3D-FEBD-4452-B62E-B04EF191C6C3 name: \n" + "Parser message: (null: 24, 185): cvc-complex-type.2.4.a: Invalid content was found");
}
use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project jbpm by kiegroup.
the class BPMN2XMLTest method testXML.
public void testXML() throws IOException, SAXException {
SemanticModules modules = new SemanticModules();
modules.addSemanticModule(new BPMNSemanticModule());
modules.addSemanticModule(new BPMNDISemanticModule());
XmlProcessReader processReader = new XmlProcessReader(modules, getClass().getClassLoader());
for (String processName : processes) {
String original = slurp(BPMN2XMLTest.class.getResourceAsStream("/" + processName));
List<Process> processes = processReader.read(BPMN2XMLTest.class.getResourceAsStream("/" + processName));
assertNotNull(processes);
assertEquals(1, processes.size());
RuleFlowProcess p = (RuleFlowProcess) processes.get(0);
String result = XmlBPMNProcessDumper.INSTANCE.dump(p, XmlBPMNProcessDumper.META_DATA_USING_DI);
// Compare original with result using XMLUnit
Diff diff = new Diff(original, result);
// Ignore the sequence of nodes (or children nodes) when looking at these nodes
final HashSet<String> sequenceDoesNotMatter = new HashSet<String>();
sequenceDoesNotMatter.add("startEvent");
sequenceDoesNotMatter.add("scriptTask");
sequenceDoesNotMatter.add("endEvent");
sequenceDoesNotMatter.add("bpmndi:BPMNShape");
diff.overrideDifferenceListener(new DifferenceListener() {
public int differenceFound(Difference diff) {
String nodeName = diff.getTestNodeDetail().getNode().getNodeName();
if (sequenceDoesNotMatter.contains(nodeName) && diff.getId() == DifferenceConstants.CHILD_NODELIST_SEQUENCE_ID) {
return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
}
logger.info("! {}", diff.getTestNodeDetail().getNode().getNodeName());
return RETURN_ACCEPT_DIFFERENCE;
}
public void skippedComparison(Node one, Node two) {
logger.info("{} : {}", one.getLocalName(), two.getLocalName());
}
});
// nodes should only be compared if their attributes are the same
diff.overrideElementQualifier(new ElementNameAndAttributeQualifier());
assertTrue("Original and generated output is not the same.", diff.identical());
}
}
use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project jbpm by kiegroup.
the class BPMN2XMLTest method testInvalidXML.
public void testInvalidXML() throws Exception, SAXException {
SemanticModules modules = new SemanticModules();
modules.addSemanticModule(new BPMNSemanticModule());
modules.addSemanticModule(new BPMNDISemanticModule());
XmlProcessReader processReader = new XmlProcessReader(modules, getClass().getClassLoader()) {
@Override
protected String processParserMessage(Collection<Object> parents, org.xml.sax.Attributes attr, String errorMessage) {
setErrorMessage(super.processParserMessage(parents, attr, errorMessage));
return errorMessage;
}
};
processReader.read(BPMN2XMLTest.class.getResourceAsStream("/BPMN2-XMLProcessWithError.bpmn2"));
assertNotNull(getErrorMessage());
assertThat(getErrorMessage()).contains("Process Info: id:error.process, pkg:org.jbpm, name:errorprocess, version:1.0 \n" + "Node Info: id:_F8A89567-7416-4CCA-9CCD-BC1DDE870F1E name: \n" + "Parser message: (null: 45, 181): cvc-complex-type.2.4.a: Invalid content was found");
}
use of io.automatiko.engine.workflow.bpmn2.xml.BPMNSemanticModule in project jbpm by kiegroup.
the class BPMN2ProcessProviderImpl method configurePackageBuilder.
public void configurePackageBuilder(KnowledgeBuilder knowledgeBuilder) {
KnowledgeBuilderConfigurationImpl conf = ((KnowledgeBuilderImpl) knowledgeBuilder).getBuilderConfiguration();
if (conf.getSemanticModules().getSemanticModule(BPMNSemanticModule.BPMN2_URI) == null) {
conf.addSemanticModule(new BPMNSemanticModule());
conf.addSemanticModule(new BPMNDISemanticModule());
conf.addSemanticModule(new BPMNExtensionsSemanticModule());
}
}
Aggregations