Search in sources :

Example 1 with TImport

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);
}
Also used : PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Definitions(org.kie.dmn.model.api.Definitions) TImport(org.kie.dmn.model.v1_2.TImport) Test(org.junit.Test)

Example 2 with TImport

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());
}
Also used : ImportDMN(org.kie.workbench.common.dmn.api.definition.model.ImportDMN) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Definitions(org.kie.dmn.model.api.Definitions) TImport(org.kie.dmn.model.v1_2.TImport) Test(org.junit.Test)

Example 3 with TImport

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());
}
Also used : PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Definitions(org.kie.dmn.model.api.Definitions) TImport(org.kie.dmn.model.v1_2.TImport) ImportPMML(org.kie.workbench.common.dmn.api.definition.model.ImportPMML) Test(org.junit.Test)

Example 4 with TImport

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;
}
Also used : TImport(org.kie.dmn.model.v1_1.TImport) Import(org.kie.dmn.model.api.Import) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) TImport(org.kie.dmn.model.v1_1.TImport)

Example 5 with TImport

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());
}
Also used : TImport(org.kie.dmn.model.v1_2.TImport) Import(org.kie.dmn.model.api.Import) ImportDMN(org.kie.workbench.common.dmn.api.definition.model.ImportDMN) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) TImport(org.kie.dmn.model.v1_2.TImport) Maps(org.kie.soup.commons.util.Maps) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 TImport (org.kie.dmn.model.v1_2.TImport)4 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)4 Definitions (org.kie.dmn.model.api.Definitions)3 Import (org.kie.dmn.model.api.Import)2 ImportDMN (org.kie.workbench.common.dmn.api.definition.model.ImportDMN)2 HashMap (java.util.HashMap)1 QName (javax.xml.namespace.QName)1 TImport (org.kie.dmn.model.v1_1.TImport)1 Maps (org.kie.soup.commons.util.Maps)1 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)1 ImportPMML (org.kie.workbench.common.dmn.api.definition.model.ImportPMML)1