@Test public void testGetValidatorImportReaderResolver() { final String modelNamespace = "0000-1111-2222-3333"; final String modelName = "model.dmn"; final String locationURI = "file.pmml"; final String pmmlXML = "<pmml/>"; final Path modelPath = mock(Path.class); final URI pmmlURI = URI.create(locationURI); final Path pmmlPath = mock(Path.class); final InputStream inputStream = mock(InputStream.class); when(importsHelper.getDMNModelPath(metadata, modelNamespace, modelName)).thenReturn(modelPath); when(importsHelper.loadPath(pmmlPath)).thenReturn(Optional.of(inputStream)); when(dmnIOHelper.isAsString(inputStream)).thenReturn(pmmlXML); doReturn(pmmlURI).when(domainValidator).getPMMLURI(modelPath, locationURI); doReturn(pmmlPath).when(domainValidator).getPath(pmmlURI); final Reader actualReader = domainValidator.getValidatorImportReaderResolver(metadata).newReader(modelNamespace, modelName, locationURI); final Reader expectedReader = new StringReader(pmmlXML); assertContent(expectedReader, actualReader); }
DMNValidator.ValidatorBuilder.ValidatorImportReaderResolver getValidatorImportReaderResolver(final Metadata metadata) { return (modelNamespace, modelName, locationURI) -> { final Path modelPath = importsHelper.getDMNModelPath(metadata, modelNamespace, modelName); final URI pmmlURI = getPMMLURI(modelPath, locationURI); final String pmmlXML = importsHelper.loadPath(getPath(pmmlURI)).map(dmnIOHelper::isAsString).orElse(""); return getStringReader(pmmlXML); }; }
DMNDomainValidatorImpl implements DMNDomainValidator { DMNValidator.ValidatorBuilder.ValidatorImportReaderResolver getValidatorImportReaderResolver(final Metadata metadata) { return (modelNamespace, modelName, locationURI) -> { final Path modelPath = importsHelper.getDMNModelPath(metadata, modelNamespace, modelName); final URI pmmlURI = getPMMLURI(modelPath, locationURI); final String pmmlXML = importsHelper.loadPath(getPath(pmmlURI)).map(dmnIOHelper::isAsString).orElse(""); return getStringReader(pmmlXML); }; } }
DMNDomainValidatorImpl implements DMNDomainValidator { DMNValidator.ValidatorBuilder.ValidatorImportReaderResolver getValidatorImportReaderResolver(final Metadata metadata) { return (modelNamespace, modelName, locationURI) -> { final Path modelPath = importsHelper.getDMNModelPath(metadata, modelNamespace, modelName); final URI pmmlURI = getPMMLURI(modelPath, locationURI); final String pmmlXML = importsHelper.loadPath(getPath(pmmlURI)).map(dmnIOHelper::isAsString).orElse(""); return getStringReader(pmmlXML); }; } @Inject  DMNDomainValidatorImpl(final DMNMarshallerStandalone dmnMarshaller,
                                  final DMNDiagramUtils dmnDiagramUtils,
                                  final DMNMarshallerImportsHelperStandalone importsHelper,
                                  final DMNIOHelper dmnIOHelper); }
DMNDomainValidatorImpl implements DMNDomainValidator { DMNValidator.ValidatorBuilder.ValidatorImportReaderResolver getValidatorImportReaderResolver(final Metadata metadata) { return (modelNamespace, modelName, locationURI) -> { final Path modelPath = importsHelper.getDMNModelPath(metadata, modelNamespace, modelName); final URI pmmlURI = getPMMLURI(modelPath, locationURI); final String pmmlXML = importsHelper.loadPath(getPath(pmmlURI)).map(dmnIOHelper::isAsString).orElse(""); return getStringReader(pmmlXML); }; } @Inject  DMNDomainValidatorImpl(final DMNMarshallerStandalone dmnMarshaller,
                                  final DMNDiagramUtils dmnDiagramUtils,
                                  final DMNMarshallerImportsHelperStandalone importsHelper,
                                  final DMNIOHelper dmnIOHelper); @PostConstruct void setupValidator(); @Override String getDefinitionSetId(); @Override @SuppressWarnings("unchecked") void validate(final Diagram diagram,
                         final Consumer<Collection<DomainViolation>> resultConsumer); @Override Collection<DomainViolation> validate(final Diagram diagram,
                                                final String diagramXml); }
DMNDomainValidatorImpl implements DMNDomainValidator { DMNValidator.ValidatorBuilder.ValidatorImportReaderResolver getValidatorImportReaderResolver(final Metadata metadata) { return (modelNamespace, modelName, locationURI) -> { final Path modelPath = importsHelper.getDMNModelPath(metadata, modelNamespace, modelName); final URI pmmlURI = getPMMLURI(modelPath, locationURI); final String pmmlXML = importsHelper.loadPath(getPath(pmmlURI)).map(dmnIOHelper::isAsString).orElse(""); return getStringReader(pmmlXML); }; } @Inject  DMNDomainValidatorImpl(final DMNMarshallerStandalone dmnMarshaller,
                                  final DMNDiagramUtils dmnDiagramUtils,
                                  final DMNMarshallerImportsHelperStandalone importsHelper,
                                  final DMNIOHelper dmnIOHelper); @PostConstruct void setupValidator(); @Override String getDefinitionSetId(); @Override @SuppressWarnings("unchecked") void validate(final Diagram diagram,
                         final Consumer<Collection<DomainViolation>> resultConsumer); @Override Collection<DomainViolation> validate(final Diagram diagram,
                                                final String diagramXml);  }