use of org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata 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.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata in project kie-wb-common by kiegroup.
the class PMMLIncludedDocumentFactoryTest method testGetDocumentByPathWithKnownPathWithIncludedModel.
@Test
public void testGetDocumentByPathWithKnownPathWithIncludedModel() {
final Path path = mock(Path.class);
final PMMLInfo<PMMLModelInfo> pmmlInfo = makePMMLInfo();
final PMMLIncludedModel includedModel = makePMMLIncludedModel();
when(path.toURI()).thenReturn(URI);
doReturn(pmmlInfo).when(factory).loadPMMLInfo(path);
final PMMLDocumentMetadata document = factory.getDocumentByPath(path, includedModel);
assertThat(document).isNotNull();
assertThat(document.getPath()).isEqualTo(URI);
assertThat(document.getImportType()).isEqualTo(NAMESPACE);
assertThat(document.getName()).isEqualTo(DOCUMENT_NAME);
assertThat(document.getModels()).hasSize(1);
final PMMLModelMetadata model = document.getModels().get(0);
assertThat(model.getName()).isEqualTo(MODEL_NAME);
assertThat(model.getInputParameters()).hasSize(INPUT_FIELDS_COUNT);
assertThat(model.getInputParameters()).usingElementComparator(comparing(PMMLParameterMetadata::getName, naturalOrder())).containsExactlyInAnyOrder(expectedPMMLParameterMetadata());
}
use of org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata in project kie-wb-common by kiegroup.
the class PMMLIncludedDocumentFactoryTest method testGetDocumentByPathWithUnknownPath.
@Test
public void testGetDocumentByPathWithUnknownPath() {
final Path path = mock(Path.class);
when(path.toURI()).thenReturn(URI);
when(ioService.newInputStream(any())).thenThrow(new NoSuchFileException());
final PMMLDocumentMetadata document = factory.getDocumentByPath(path);
assertThat(document).isNotNull();
assertThat(document.getPath()).isEqualTo(URI);
assertThat(document.getImportType()).isEqualTo(NAMESPACE);
assertThat(document.getModels()).isEmpty();
}
use of org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata in project kie-wb-common by kiegroup.
the class PMMLIncludedDocumentFactoryTest method testGetDocumentByPathWithKnownPath.
@Test
public void testGetDocumentByPathWithKnownPath() {
final Path path = mock(Path.class);
final PMMLInfo<PMMLModelInfo> pmmlInfo = makePMMLInfo();
when(path.toURI()).thenReturn(URI);
doReturn(pmmlInfo).when(factory).loadPMMLInfo(path);
final PMMLDocumentMetadata document = factory.getDocumentByPath(path);
assertThat(document).isNotNull();
assertThat(document.getPath()).isEqualTo(URI);
assertThat(document.getImportType()).isEqualTo(NAMESPACE);
assertThat(document.getModels()).hasSize(1);
final PMMLModelMetadata model = document.getModels().get(0);
assertThat(model.getName()).isEqualTo(MODEL_NAME);
assertThat(model.getInputParameters()).hasSize(INPUT_FIELDS_COUNT);
assertThat(model.getInputParameters()).usingElementComparator(comparing(PMMLParameterMetadata::getName, naturalOrder())).containsExactlyInAnyOrder(expectedPMMLParameterMetadata());
}
use of org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata in project kie-wb-common by kiegroup.
the class IncludedModelFactoryTest method testCreatePMML.
@Test
public void testCreatePMML() throws Exception {
final PMMLDocumentMetadata pmmlDocument = mock(PMMLDocumentMetadata.class);
final Package aPackage = mock(Package.class);
final String packageName = "com.kie.pmml";
final String fileName = "file.pmml";
final String uri = "/src/main/java/com/kie/pmml/file.pmml";
final Integer expectedModelsCount = 2;
when(aPackage.getPackageName()).thenReturn(packageName);
when(includedModelPath.getFileName()).thenReturn(fileName);
when(moduleService.resolvePackage(includedModelPath)).thenReturn(aPackage);
when(importTypesHelper.isDMN(includedModelPath)).thenReturn(false);
when(importTypesHelper.isPMML(includedModelPath)).thenReturn(true);
when(pathsHelper.getRelativeURI(dmnModelPath, includedModelPath)).thenReturn(uri);
when(pmmlDocumentFactory.getDocumentByPath(includedModelPath)).thenReturn(pmmlDocument);
when(pmmlDocument.getModels()).thenReturn(asList(mock(PMMLModelMetadata.class), mock(PMMLModelMetadata.class)));
final IncludedModel includedModel = factory.create(dmnModelPath, includedModelPath);
assertTrue(includedModel instanceof PMMLIncludedModel);
final PMMLIncludedModel pmmlIncludedModel = (PMMLIncludedModel) includedModel;
assertEquals(packageName, includedModel.getModelPackage());
assertEquals(fileName, includedModel.getModelName());
assertEquals(uri, includedModel.getPath());
assertEquals(expectedModelsCount, pmmlIncludedModel.getModelCount());
}
Aggregations