Search in sources :

Example 1 with InputStreamProvider

use of org.activiti.bpmn.converter.util.InputStreamProvider in project Activiti by Activiti.

the class PrefixConversionTest method shouldConvertWithoutDoublingTheBPMN2PrefixWhenAbpmnFileWithPrefixIsGiven.

@Test
public void shouldConvertWithoutDoublingTheBPMN2PrefixWhenAbpmnFileWithPrefixIsGiven() throws IOException {
    final InputStream originalXMLStream = this.getClass().getClassLoader().getResourceAsStream("checkConversionPrefix.bpmn");
    final InputStream copiedXMLStream = this.getClass().getClassLoader().getResourceAsStream("checkConversionPrefix.bpmn");
    BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
    byte[] byteOriginalXMLStream = new byte[originalXMLStream.available()];
    originalXMLStream.read(byteOriginalXMLStream);
    BpmnModel bpmnModel = bpmnXMLConverter.convertToBpmnModel(new InputStreamProvider() {

        @Override
        public InputStream getInputStream() {
            return copiedXMLStream;
        }
    }, false, false);
    byte[] bytesReconvertedXMLModel = bpmnXMLConverter.convertToXML(bpmnModel);
    String stringifyOriginalXML = new String(byteOriginalXMLStream);
    String stringifyReconvertedModel = new String(bytesReconvertedXMLModel);
    assertThat(stringifyReconvertedModel).isXmlEqualTo(stringifyOriginalXML);
}
Also used : InputStreamProvider(org.activiti.bpmn.converter.util.InputStreamProvider) InputStream(java.io.InputStream) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.jupiter.api.Test)

Example 2 with InputStreamProvider

use of org.activiti.bpmn.converter.util.InputStreamProvider in project Activiti by Activiti.

the class ProcessWithCompensationConverterTest method testConvertingAfterAutoLayout.

@Test
public void testConvertingAfterAutoLayout() {
    final InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("ProcessWithCompensationAssociation.bpmn20.xml");
    BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
    BpmnModel bpmnModel1 = bpmnXMLConverter.convertToBpmnModel(new InputStreamProvider() {

        @Override
        public InputStream getInputStream() {
            return inputStream;
        }
    }, false, false);
    if (bpmnModel1.getLocationMap().size() == 0) {
        BpmnAutoLayout bpmnLayout = new BpmnAutoLayout(bpmnModel1);
        bpmnLayout.execute();
    }
    byte[] xmlByte = bpmnXMLConverter.convertToXML(bpmnModel1);
    final InputStream byteArrayInputStream = new ByteArrayInputStream(xmlByte);
    BpmnModel bpmnModel2 = bpmnXMLConverter.convertToBpmnModel(new InputStreamProvider() {

        @Override
        public InputStream getInputStream() {
            return byteArrayInputStream;
        }
    }, false, false);
    assertThat(bpmnModel1.getLocationMap()).hasSize(10);
    assertThat(bpmnModel2.getLocationMap()).hasSize(10);
    assertThat(bpmnModel1.getFlowLocationMap()).hasSize(7);
    assertThat(bpmnModel2.getFlowLocationMap()).hasSize(7);
}
Also used : InputStreamProvider(org.activiti.bpmn.converter.util.InputStreamProvider) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BpmnAutoLayout(org.activiti.bpmn.BpmnAutoLayout) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) BpmnModel(org.activiti.bpmn.model.BpmnModel) Test(org.junit.jupiter.api.Test)

Aggregations

InputStream (java.io.InputStream)2 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)2 InputStreamProvider (org.activiti.bpmn.converter.util.InputStreamProvider)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 Test (org.junit.jupiter.api.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 BpmnAutoLayout (org.activiti.bpmn.BpmnAutoLayout)1