@Test public void testGetItemDefinitionsWithNamespace() { final Definitions definitions = mock(Definitions.class); final Import anImport = mock(Import.class); final ItemDefinition itemDefinition1 = new TItemDefinition(); final ItemDefinition itemDefinition2 = new TItemDefinition(); final ItemDefinition itemDefinition3 = new TItemDefinition(); final ItemDefinition itemDefinition4 = new TItemDefinition(); final ItemDefinition itemDefinition5 = new TItemDefinition(); final List<ItemDefinition> itemDefinitions = asList(itemDefinition1, itemDefinition2, itemDefinition3, itemDefinition4, itemDefinition5); itemDefinition1.setName("tUUID"); itemDefinition2.setName("tPerson"); itemDefinition3.setName("id"); itemDefinition4.setName("name"); itemDefinition5.setName("age"); itemDefinition1.setTypeRef(new QName("string")); itemDefinition2.setTypeRef(null); itemDefinition3.setTypeRef(new QName("tUUID")); itemDefinition4.setTypeRef(new QName("string")); itemDefinition5.setTypeRef(new QName("number")); when(anImport.getName()).thenReturn("model"); when(definitions.getItemDefinition()).thenReturn(itemDefinitions); final List<ItemDefinition> actualItemDefinitions = helper.getItemDefinitionsWithNamespace(definitions, anImport); assertEquals(5, actualItemDefinitions.size()); final ItemDefinition actualItemDefinition1 = actualItemDefinitions.get(0); assertEquals("model.tUUID", actualItemDefinition1.getName()); assertEquals("string", actualItemDefinition1.getTypeRef().getLocalPart()); final ItemDefinition actualItemDefinition2 = actualItemDefinitions.get(1); assertEquals("model.tPerson", actualItemDefinition2.getName()); assertNull(actualItemDefinition2.getTypeRef()); final ItemDefinition actualItemDefinition3 = actualItemDefinitions.get(2); assertEquals("model.id", actualItemDefinition3.getName()); assertEquals("model.tUUID", actualItemDefinition3.getTypeRef().getLocalPart()); final ItemDefinition actualItemDefinition4 = actualItemDefinitions.get(3); assertEquals("model.name", actualItemDefinition4.getName()); assertEquals("string", actualItemDefinition4.getTypeRef().getLocalPart()); final ItemDefinition actualItemDefinition5 = actualItemDefinitions.get(4); assertEquals("model.age", actualItemDefinition5.getName()); assertEquals("number", actualItemDefinition5.getTypeRef().getLocalPart()); }
List<ItemDefinition> getItemDefinitionsWithNamespace(final Definitions definitions, final Import anImport) { final List<ItemDefinition> itemDefinitions = definitions.getItemDefinition(); final String prefix = anImport.getName(); return itemDefinitions .stream() .map(itemDefinition -> withNamespace(itemDefinition, prefix)) .collect(Collectors.toList()); }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { List<ItemDefinition> getItemDefinitionsWithNamespace(final Definitions definitions, final Import anImport) { final List<ItemDefinition> itemDefinitions = definitions.getItemDefinition(); final String prefix = anImport.getName(); return itemDefinitions .stream() .map(itemDefinition -> withNamespace(itemDefinition, prefix)) .collect(Collectors.toList()); } }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { List<ItemDefinition> getItemDefinitionsWithNamespace(final Definitions definitions, final Import anImport) { final List<ItemDefinition> itemDefinitions = definitions.getItemDefinition(); final String prefix = anImport.getName(); return itemDefinitions .stream() .map(itemDefinition -> withNamespace(itemDefinition, prefix)) .collect(Collectors.toList()); } 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 { List<ItemDefinition> getItemDefinitionsWithNamespace(final Definitions definitions, final Import anImport) { final List<ItemDefinition> itemDefinitions = definitions.getItemDefinition(); final String prefix = anImport.getName(); return itemDefinitions .stream() .map(itemDefinition -> withNamespace(itemDefinition, prefix)) .collect(Collectors.toList()); } 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 { List<ItemDefinition> getItemDefinitionsWithNamespace(final Definitions definitions, final Import anImport) { final List<ItemDefinition> itemDefinitions = definitions.getItemDefinition(); final String prefix = anImport.getName(); return itemDefinitions .stream() .map(itemDefinition -> withNamespace(itemDefinition, prefix)) .collect(Collectors.toList()); } 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; }