### Question:
ImportConverter { public static Import wbFromDMN(final org.kie.dmn.model.api.Import dmn, final Definitions definitions, final PMMLDocumentMetadata pmmlDocument) { final Import result = createWBImport(dmn, definitions, pmmlDocument); final Map<QName, String> additionalAttributes = new HashMap<>(); for (Map.Entry<javax.xml.namespace.QName, String> entry : dmn.getAdditionalAttributes().entrySet()) { additionalAttributes.put(QNamePropertyConverter.wbFromDMN(entry.getKey(), dmn), entry.getValue()); } result.setAdditionalAttributes(additionalAttributes); final String id = dmn.getId(); final String name = dmn.getName(); final String description = dmn.getDescription(); result.setId(new Id(id != null ? id : UUID.randomUUID().toString())); result.setName(new Name(name)); result.setDescription(DescriptionPropertyConverter.wbFromDMN(description)); dmn.getNsContext().forEach((key, value) -> result.getNsContext().put(key, value)); return result; }  static Import wbFromDMN(final org.kie.dmn.model.api.Import dmn,
                                   final Definitions definitions,
                                   final PMMLDocumentMetadata pmmlDocument); static org.kie.dmn.model.api.Import dmnFromWb(final Import wb);  }### Answer:
@Test public void testWbFromDMNWhenGeneric() { final org.kie.dmn.model.api.Import dmn = new TImport(); dmn.setImportType("cheese"); final Definitions definitions = mock(Definitions.class); final PMMLDocumentMetadata pmmlDocument = mock(PMMLDocumentMetadata.class); final org.kie.workbench.common.dmn.api.definition.model.Import anImport = ImportConverter.wbFromDMN(dmn, definitions, pmmlDocument); assertNotNull(anImport); }
@Test public void testWbFromDMNWhenDMNImport() { final org.kie.dmn.model.api.Import dmn = new TImport(); dmn.setImportType(DMNImportTypes.DMN.getDefaultNamespace()); final Definitions definitions = mock(Definitions.class); final PMMLDocumentMetadata pmmlDocument = mock(PMMLDocumentMetadata.class); final String key = "drools"; final String value = "http: dmn.getNsContext().put(key, value); when(definitions.getDrgElement()).thenReturn(asList(mock(DRGElement.class), mock(DRGElement.class))); when(definitions.getItemDefinition()).thenReturn(asList(mock(ItemDefinition.class), mock(ItemDefinition.class), mock(ItemDefinition.class))); final org.kie.workbench.common.dmn.api.definition.model.Import anImport = ImportConverter.wbFromDMN(dmn, definitions, pmmlDocument); final Map<String, String> nsContext = anImport.getNsContext(); assertEquals(1, nsContext.size()); assertEquals(value, nsContext.get(key)); assertTrue(anImport instanceof ImportDMN); final ImportDMN dmnImport = (ImportDMN) anImport; assertEquals(2, dmnImport.getDrgElementsCount()); assertEquals(3, dmnImport.getItemDefinitionsCount()); }
@Test public void testWbFromDMNWhenPMMLImport() { final org.kie.dmn.model.api.Import dmn = new TImport(); dmn.setImportType(DMNImportTypes.PMML.getDefaultNamespace()); final Definitions definitions = mock(Definitions.class); final PMMLDocumentMetadata pmmlDocument = mock(PMMLDocumentMetadata.class); when(pmmlDocument.getModels()).thenReturn(asList(mock(PMMLModelMetadata.class), mock(PMMLModelMetadata.class))); final org.kie.workbench.common.dmn.api.definition.model.Import anImport = ImportConverter.wbFromDMN(dmn, definitions, pmmlDocument); assertTrue(anImport instanceof ImportPMML); final ImportPMML pmmlImport = (ImportPMML) anImport; assertEquals(2, pmmlImport.getModelCount()); }