@Test public void testGetImportDefinitions() { final Metadata metadata = mock(Metadata.class); final Import import1 = mock(Import.class); final Import import2 = mock(Import.class); final Import import3 = mock(Import.class); final List<Import> imports = asList(import1, import2, import3); final Definitions definitions1 = mock(Definitions.class); final Definitions definitions2 = mock(Definitions.class); final Definitions definitions3 = mock(Definitions.class); final List<Definitions> definitions = asList(definitions1, definitions2, definitions3); when(definitions1.getNamespace()).thenReturn(": when(definitions2.getNamespace()).thenReturn(": when(definitions3.getNamespace()).thenReturn(": when(import1.getNamespace()).thenReturn(": when(import2.getNamespace()).thenReturn(": when(import3.getNamespace()).thenReturn(": doReturn(definitions).when(helper).getOtherDMNDiagramsDefinitions(metadata); final Map<Import, Definitions> importDefinitions = helper.getImportDefinitions(metadata, imports); assertEquals(2, importDefinitions.size()); assertEquals(definitions1, importDefinitions.get(import1)); assertEquals(definitions3, importDefinitions.get(import3)); }
@Override public Map<Import, Definitions> getImportDefinitions(final Metadata metadata, final List<Import> imports) { final Map<Import, Definitions> importDefinitions = new HashMap<>(); if (imports.size() > 0) { for (final Definitions definitions : getOtherDMNDiagramsDefinitions(metadata)) { findImportByDefinitions(definitions, imports).ifPresent(anImport -> { importDefinitions.put(anImport, definitions); }); } } return importDefinitions; }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Map<Import, Definitions> getImportDefinitions(final Metadata metadata, final List<Import> imports) { final Map<Import, Definitions> importDefinitions = new HashMap<>(); if (imports.size() > 0) { for (final Definitions definitions : getOtherDMNDiagramsDefinitions(metadata)) { findImportByDefinitions(definitions, imports).ifPresent(anImport -> { importDefinitions.put(anImport, definitions); }); } } return importDefinitions; } }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { @Override public Map<Import, Definitions> getImportDefinitions(final Metadata metadata, final List<Import> imports) { final Map<Import, Definitions> importDefinitions = new HashMap<>(); if (imports.size() > 0) { for (final Definitions definitions : getOtherDMNDiagramsDefinitions(metadata)) { findImportByDefinitions(definitions, imports).ifPresent(anImport -> { importDefinitions.put(anImport, definitions); }); } } return importDefinitions; } 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, Definitions> getImportDefinitions(final Metadata metadata, final List<Import> imports) { final Map<Import, Definitions> importDefinitions = new HashMap<>(); if (imports.size() > 0) { for (final Definitions definitions : getOtherDMNDiagramsDefinitions(metadata)) { findImportByDefinitions(definitions, imports).ifPresent(anImport -> { importDefinitions.put(anImport, definitions); }); } } return importDefinitions; } 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, Definitions> getImportDefinitions(final Metadata metadata, final List<Import> imports) { final Map<Import, Definitions> importDefinitions = new HashMap<>(); if (imports.size() > 0) { for (final Definitions definitions : getOtherDMNDiagramsDefinitions(metadata)) { findImportByDefinitions(definitions, imports).ifPresent(anImport -> { importDefinitions.put(anImport, definitions); }); } } return importDefinitions; } 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; }