@Test public void testGetDrgElementsWithNamespace() { final Definitions definitions = mock(Definitions.class); final Import anImport = mock(Import.class); final TDecision drgElement1 = new TDecision(); final TInputData drgElement2 = new TInputData(); final TDecisionService drgElement3 = new TDecisionService(); final InformationItem informationItem1 = new TInformationItem(); final InformationItem informationItem2 = new TInformationItem(); final InformationItem informationItem3 = new TInformationItem(); final List<DRGElement> drgElements = asList(drgElement1, drgElement2, drgElement3); final String namespace = "http: final String builtInTypeNumber = BuiltInType.NUMBER.getName(); when(anImport.getName()).thenReturn("model"); when(anImport.getNamespace()).thenReturn(namespace); informationItem1.setTypeRef(new QName(XMLConstants.NULL_NS_URI, "tUUID", XMLConstants.DEFAULT_NS_PREFIX)); informationItem2.setTypeRef(new QName(XMLConstants.NULL_NS_URI, "tAge", XMLConstants.DEFAULT_NS_PREFIX)); informationItem3.setTypeRef(new QName(XMLConstants.NULL_NS_URI, builtInTypeNumber, XMLConstants.DEFAULT_NS_PREFIX)); drgElement1.setId("0000-1111"); drgElement2.setId("2222-3333"); drgElement3.setId("4444-5555"); drgElement1.setName("Decision"); drgElement2.setName("Input Data"); drgElement3.setName("Decision Service"); drgElement1.setVariable(informationItem1); drgElement2.setVariable(informationItem2); drgElement3.setVariable(informationItem3); when(definitions.getDrgElement()).thenReturn(drgElements); final List<DRGElement> elements = helper.getDrgElementsWithNamespace(definitions, anImport); assertEquals(3, elements.size()); final TDecision element1 = (TDecision) elements.get(0); assertEquals("0000-1111", element1.getId()); assertEquals("model.Decision", element1.getName()); assertEquals("model.tUUID", element1.getVariable().getTypeRef().getLocalPart()); assertEquals(namespace, getNamespace(element1)); final TInputData element2 = (TInputData) elements.get(1); assertEquals("2222-3333", element2.getId()); assertEquals("model.Input Data", element2.getName()); assertEquals("model.tAge", element2.getVariable().getTypeRef().getLocalPart()); assertEquals(namespace, getNamespace(element2)); final TDecisionService element3 = (TDecisionService) elements.get(2); assertEquals("4444-5555", element3.getId()); assertEquals("model.Decision Service", element3.getName()); assertEquals(builtInTypeNumber, element3.getVariable().getTypeRef().getLocalPart()); assertEquals(namespace, getNamespace(element3)); }
List<DRGElement> getDrgElementsWithNamespace(final Definitions definitions, final Import anImport) { return definitions .getDrgElement() .stream() .map(drgElement -> drgElementWithNamespace(drgElement, anImport)) .collect(Collectors.toList()); }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { List<DRGElement> getDrgElementsWithNamespace(final Definitions definitions, final Import anImport) { return definitions .getDrgElement() .stream() .map(drgElement -> drgElementWithNamespace(drgElement, anImport)) .collect(Collectors.toList()); } }
DMNMarshallerImportsHelperStandaloneImpl implements DMNMarshallerImportsHelperStandalone { List<DRGElement> getDrgElementsWithNamespace(final Definitions definitions, final Import anImport) { return definitions .getDrgElement() .stream() .map(drgElement -> drgElementWithNamespace(drgElement, anImport)) .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<DRGElement> getDrgElementsWithNamespace(final Definitions definitions, final Import anImport) { return definitions .getDrgElement() .stream() .map(drgElement -> drgElementWithNamespace(drgElement, anImport)) .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<DRGElement> getDrgElementsWithNamespace(final Definitions definitions, final Import anImport) { return definitions .getDrgElement() .stream() .map(drgElement -> drgElementWithNamespace(drgElement, anImport)) .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; }