@Test public void testGetPMMLDocuments() { final Path dmnModelPath = mock(Path.class); final Metadata metadata = mock(Metadata.class); final PMMLDocumentMetadata pmmlDocument = mock(PMMLDocumentMetadata.class); final Import import1 = mock(Import.class); final List<Import> imports = singletonList(import1); final Path path1 = mock(Path.class); final Path path2 = mock(Path.class); final List<Path> paths = asList(path1, path2); when(metadata.getPath()).thenReturn(dmnModelPath); when(import1.getLocationURI()).thenReturn("document1.pmml"); when(pathsHelper.getRelativeURI(dmnModelPath, path1)).thenReturn("document1.pmml"); when(pathsHelper.getRelativeURI(dmnModelPath, path2)).thenReturn("document2.pmml"); when(pmmlDocumentFactory.getDocumentByPath(path1)).thenReturn(pmmlDocument); doReturn(paths).when(helper).getPMMLDocumentPaths(metadata); final Map<Import, PMMLDocumentMetadata> importDefinitions = helper.getPMMLDocuments(metadata, imports); assertEquals(1, importDefinitions.size()); assertEquals(pmmlDocument, importDefinitions.get(import1)); }
@Override public Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata, final List<Import> imports) { final Map<Import, PMMLDocumentMetadata> pmmlDocuments = new HashMap<>(); if (imports.size() > 0) { for (final Path pmmlDocumentPath : getPMMLDocumentPaths(metadata)) { findImportByPMMLDocument(metadata.getPath(), pmmlDocumentPath, imports).ifPresent(anImport -> { pmmlDocuments.put(anImport, pmmlDocumentFactory.getDocumentByPath(pmmlDocumentPath)); }); } } return pmmlDocuments; }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata, final List<Import> imports) { final Map<Import, PMMLDocumentMetadata> pmmlDocuments = new HashMap<>(); if (imports.size() > 0) { for (final Path pmmlDocumentPath : getPMMLDocumentPaths(metadata)) { findImportByPMMLDocument(metadata.getPath(), pmmlDocumentPath, imports).ifPresent(anImport -> { pmmlDocuments.put(anImport, pmmlDocumentFactory.getDocumentByPath(pmmlDocumentPath)); }); } } return pmmlDocuments; } }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata, final List<Import> imports) { final Map<Import, PMMLDocumentMetadata> pmmlDocuments = new HashMap<>(); if (imports.size() > 0) { for (final Path pmmlDocumentPath : getPMMLDocumentPaths(metadata)) { findImportByPMMLDocument(metadata.getPath(), pmmlDocumentPath, imports).ifPresent(anImport -> { pmmlDocuments.put(anImport, pmmlDocumentFactory.getDocumentByPath(pmmlDocumentPath)); }); } } return pmmlDocuments; } DMNMarshallerImportsHelperStandaloneImpl(); @Inject  DMNMarshallerImportsHelperStandaloneImpl(final DMNPathsHelper pathsHelper,
                                                    final WorkspaceProjectService projectService,
                                                    final DMNMarshaller marshaller,
                                                    final DMNIOHelper dmnIOHelper,
                                                    final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                                    final @Named("ioStrategy") IOService ioService); }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata, final List<Import> imports) { final Map<Import, PMMLDocumentMetadata> pmmlDocuments = new HashMap<>(); if (imports.size() > 0) { for (final Path pmmlDocumentPath : getPMMLDocumentPaths(metadata)) { findImportByPMMLDocument(metadata.getPath(), pmmlDocumentPath, imports).ifPresent(anImport -> { pmmlDocuments.put(anImport, pmmlDocumentFactory.getDocumentByPath(pmmlDocumentPath)); }); } } return pmmlDocuments; } DMNMarshallerImportsHelperStandaloneImpl(); @Inject  DMNMarshallerImportsHelperStandaloneImpl(final DMNPathsHelper pathsHelper,
                                                    final WorkspaceProjectService projectService,
                                                    final DMNMarshaller marshaller,
                                                    final DMNIOHelper dmnIOHelper,
                                                    final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                                    final @Named("ioStrategy") IOService ioService); @Override Map<Import, Definitions> getImportDefinitions(final Metadata metadata,
                                                         final List<Import> imports); @Override Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata,
                                                              final List<Import> imports); @Override Map<Import, String> getImportXML(final Metadata metadata,
                                            final List<Import> imports); @Override Path getDMNModelPath(final Metadata metadata,
                                final String modelNamespace,
                                final String modelName); @Override List<DRGElement> getImportedDRGElements(final Map<Import, Definitions> importDefinitions); @Override List<ItemDefinition> getImportedItemDefinitions(final Map<Import, Definitions> importDefinitions); @Override List<ItemDefinition> getImportedItemDefinitionsByNamespace(final WorkspaceProject workspaceProject,
                                                                      final String modelName,
                                                                      final String namespace); @Override Optional<InputStream> loadPath(final Path path); }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata, final List<Import> imports) { final Map<Import, PMMLDocumentMetadata> pmmlDocuments = new HashMap<>(); if (imports.size() > 0) { for (final Path pmmlDocumentPath : getPMMLDocumentPaths(metadata)) { findImportByPMMLDocument(metadata.getPath(), pmmlDocumentPath, imports).ifPresent(anImport -> { pmmlDocuments.put(anImport, pmmlDocumentFactory.getDocumentByPath(pmmlDocumentPath)); }); } } return pmmlDocuments; } DMNMarshallerImportsHelperStandaloneImpl(); @Inject  DMNMarshallerImportsHelperStandaloneImpl(final DMNPathsHelper pathsHelper,
                                                    final WorkspaceProjectService projectService,
                                                    final DMNMarshaller marshaller,
                                                    final DMNIOHelper dmnIOHelper,
                                                    final PMMLIncludedDocumentFactory pmmlDocumentFactory,
                                                    final @Named("ioStrategy") IOService ioService); @Override Map<Import, Definitions> getImportDefinitions(final Metadata metadata,
                                                         final List<Import> imports); @Override Map<Import, PMMLDocumentMetadata> getPMMLDocuments(final Metadata metadata,
                                                              final List<Import> imports); @Override Map<Import, String> getImportXML(final Metadata metadata,
                                            final List<Import> imports); @Override Path getDMNModelPath(final Metadata metadata,
                                final String modelNamespace,
                                final String modelName); @Override List<DRGElement> getImportedDRGElements(final Map<Import, Definitions> importDefinitions); @Override List<ItemDefinition> getImportedItemDefinitions(final Map<Import, Definitions> importDefinitions); @Override List<ItemDefinition> getImportedItemDefinitionsByNamespace(final WorkspaceProject workspaceProject,
                                                                      final String modelName,
                                                                      final String namespace); @Override Optional<InputStream> loadPath(final Path path); static final QName NAMESPACE; }