use of org.kie.dmn.model.v1_1.TImport in project kie-wb-common by kiegroup.
the class ImportConverterTest method testWbFromDMNWhenGeneric.
@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);
}
use of org.kie.dmn.model.v1_1.TImport in project kie-wb-common by kiegroup.
the class ImportConverterTest method testWbFromDMNWhenDMNImport.
@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://www.drools.org/kie/dmn/1.1";
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());
}
use of org.kie.dmn.model.v1_1.TImport in project kie-wb-common by kiegroup.
the class ImportConverterTest method testWbFromDMNWhenPMMLImport.
@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());
}
use of org.kie.dmn.model.v1_1.TImport in project drools by kiegroup.
the class ImportDMNResolverUtilTest method makeImport.
private Import makeImport(final String namespace, final String name, final String modelName) {
final Import i = new TImport();
i.setNamespace(namespace);
final Map<QName, String> addAttributes = new HashMap<>();
if (name != null) {
addAttributes.put(TImport.NAME_QNAME, name);
}
if (modelName != null) {
addAttributes.put(TImport.MODELNAME_QNAME, modelName);
}
i.setAdditionalAttributes(addAttributes);
return i;
}
use of org.kie.dmn.model.v1_1.TImport in project kie-wb-common by kiegroup.
the class DefinitionsConverterTest method wbFromDMN.
@Test
public void wbFromDMN() {
final Import anImport = new TImport();
anImport.setImportType(DMNImportTypes.DMN.getDefaultNamespace());
final org.kie.dmn.model.api.Definitions definitions = mock(org.kie.dmn.model.api.Definitions.class);
final Map<Import, org.kie.dmn.model.api.Definitions> importDefinitions = new Maps.Builder<Import, org.kie.dmn.model.api.Definitions>().put(anImport, definitions).build();
final Map<Import, PMMLDocumentMetadata> pmmlDocuments = new Maps.Builder<Import, PMMLDocumentMetadata>().build();
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)));
when(apiDefinitions.getImport()).thenReturn(singletonList(anImport));
final Definitions wb = DefinitionsConverter.wbFromDMN(apiDefinitions, importDefinitions, pmmlDocuments);
final String defaultNs = wb.getNsContext().get(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix());
final String namespace = wb.getNamespace().getValue();
final List<org.kie.workbench.common.dmn.api.definition.model.Import> imports = wb.getImport();
assertEquals(defaultNs, namespace);
assertEquals(1, imports.size());
assertTrue(imports.get(0) instanceof ImportDMN);
final ImportDMN importDMN = (ImportDMN) imports.get(0);
assertEquals(2, importDMN.getDrgElementsCount());
assertEquals(3, importDMN.getItemDefinitionsCount());
}
Aggregations