Source:
private ErrorsAndDMNModelAsSerialized roundTripUnmarshalMarshalThenUnmarshalDMNexpectingErrors(InputStream dmnXmlInputStream) throws IOException { String xml = null; try (BufferedReader buffer = new BufferedReader(new InputStreamReader(dmnXmlInputStream))) { xml = buffer.lines().collect(Collectors.joining("\n")); } catch (Exception e) { throw new RuntimeException("test utily method roundTripUnmarshalMarshalThenUnmarshalDMN failed to read XML content.", e); } LOG.debug("ORIGINAL xml:\n{}\n", xml); final List<Message> messages0 = kieBuilderMessagesUsingDMNXML(xml); assertTrue("The DMN XML file did NOT resulted in compilation errors and this test method expected errors to be detected. If this was intentional use test method roundTripUnmarshalMarshalThenUnmarshalDMN", messages0.stream().filter(m -> m.getLevel().equals(Message.Level.ERROR)).count() > 0); DMNMarshaller m = new DMNMarshaller(new XMLEncoderDiagramMetadataMarshaller(), applicationFactoryManager); @SuppressWarnings("unchecked") Graph<?, Node<?, ?>> g = m.unmarshall(null, new ReaderInputStream(new StringReader(xml))); DiagramImpl diagram = new DiagramImpl("", null); diagram.setGraph(g); String mString = m.marshall(diagram); LOG.debug("MARSHALLED ROUNTRIP RESULTING xml:\n{}\n", mString); final List<Message> result = kieBuilderMessagesUsingDMNXML(mString); assertTrue("The DMN XML file did NOT resulted in compilation errors and this test method expected errors to be detected. If this was intentional use test method roundTripUnmarshalMarshalThenUnmarshalDMN", messages0.stream().filter(msg -> msg.getLevel().equals(Message.Level.ERROR)).count() > 0); Definitions definitions = DMNMarshallerFactory.newDefaultMarshaller().unmarshal(mString); return new ErrorsAndDMNModelAsSerialized(result, definitions); }

Target:
private ErrorsAndDMNModelAsSerialized roundTripUnmarshalMarshalThenUnmarshalDMNexpectingErrors(InputStream dmnXmlInputStream) throws IOException { String xml = null; try (BufferedReader buffer = new BufferedReader(new InputStreamReader(dmnXmlInputStream))) { xml = buffer.lines().collect(Collectors.joining("\n")); } catch (Exception e) { throw new RuntimeException("test utility method roundTripUnmarshalMarshalThenUnmarshalDMN failed to read XML content.", e); } LOG.debug("ORIGINAL xml:\n{}\n", xml); final List<Message> messages0 = kieBuilderMessagesUsingDMNXML(xml); assertTrue("The DMN XML content did NOT result in compilation errors and this test method expected errors to be detected. If this was intentional use test method roundTripUnmarshalMarshalThenUnmarshalDMN", messages0.stream().filter(m -> m.getLevel().equals(Message.Level.ERROR)).count() > 0); DMNMarshaller m = new DMNMarshaller(new XMLEncoderDiagramMetadataMarshaller(), applicationFactoryManager); @SuppressWarnings("unchecked") Graph<?, Node<?, ?>> g = m.unmarshall(null, new ReaderInputStream(new StringReader(xml))); DiagramImpl diagram = new DiagramImpl("", null); diagram.setGraph(g); String mString = m.marshall(diagram); LOG.debug("MARSHALLED ROUNDTRIP RESULTING xml:\n{}\n", mString); final List<Message> result = kieBuilderMessagesUsingDMNXML(mString); assertTrue("The DMN XML content did NOT result in compilation errors and this test method expected errors to be detected. If this was intentional use test method roundTripUnmarshalMarshalThenUnmarshalDMN", messages0.stream().filter(msg -> msg.getLevel().equals(Message.Level.ERROR)).count() > 0); Definitions definitions = DMNMarshallerFactory.newDefaultMarshaller().unmarshal(mString); return new ErrorsAndDMNModelAsSerialized(result, definitions); }