Search in sources :

Example 6 with PMMLIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel in project kie-wb-common by kiegroup.

the class PMMLIncludedDocumentsFilterTest method testGetDocumentFromImportsWithImportsFileIsImported.

@Test
public void testGetDocumentFromImportsWithImportsFileIsImported() {
    includedModels.add(new PMMLIncludedModel(NAME, PACKAGE, IMPORT_PATH, DMNImportTypes.DMN.getDefaultNamespace(), MODEL_COUNT));
    when(pathsHelper.getRelativeURI(dmnModelPath, includedModelPath)).thenReturn(IMPORT_PATH);
    assertThat(filter.getDocumentFromImports(dmnModelPath, includedModelPath, includedModels)).isEqualTo(pmmlDocumentMetadata);
}
Also used : PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) Test(org.junit.Test)

Example 7 with PMMLIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel in project kie-wb-common by kiegroup.

the class PMMLIncludedDocumentsFilterTest method testGetDocumentFromImportsWithImportsFileIsNotImported.

@Test
public void testGetDocumentFromImportsWithImportsFileIsNotImported() {
    includedModels.add(new PMMLIncludedModel(NAME, PACKAGE, IMPORT_PATH, DMNImportTypes.DMN.getDefaultNamespace(), MODEL_COUNT));
    when(pathsHelper.getRelativeURI(dmnModelPath, includedModelPath)).thenReturn("includedModelPath");
    assertThat(filter.getDocumentFromImports(dmnModelPath, includedModelPath, includedModels)).isNull();
}
Also used : PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) Test(org.junit.Test)

Example 8 with PMMLIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel in project kie-wb-common by kiegroup.

the class PMMLIncludedDocumentFactoryTest method testGetDocumentByPathWithUnknownPathWithIncludedModel.

@Test
public void testGetDocumentByPathWithUnknownPathWithIncludedModel() {
    final Path path = mock(Path.class);
    final PMMLIncludedModel includedModel = makePMMLIncludedModel();
    when(path.toURI()).thenReturn(URI);
    when(ioService.newInputStream(any())).thenThrow(new NoSuchFileException());
    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()).isEmpty();
}
Also used : Path(org.uberfire.backend.vfs.Path) PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) NoSuchFileException(org.uberfire.java.nio.file.NoSuchFileException) Test(org.junit.Test)

Example 9 with PMMLIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel in project kie-wb-common by kiegroup.

the class DMNIncludedModelsServiceImplTest method testLoadPMMLDocumentsFromImports.

@Test
public void testLoadPMMLDocumentsFromImports() {
    final WorkspaceProject workspaceProject = mock(WorkspaceProject.class);
    final PMMLIncludedModel includedModel1 = mock(PMMLIncludedModel.class);
    final PMMLIncludedModel includedModel2 = mock(PMMLIncludedModel.class);
    final PMMLIncludedModel includedModel3 = mock(PMMLIncludedModel.class);
    final Path path1 = mock(Path.class);
    final Path path2 = mock(Path.class);
    final Path path3 = mock(Path.class);
    final PMMLDocumentMetadata pmmlDocument1 = mock(PMMLDocumentMetadata.class);
    final PMMLDocumentMetadata pmmlDocument2 = mock(PMMLDocumentMetadata.class);
    final PMMLDocumentMetadata pmmlDocument3 = mock(PMMLDocumentMetadata.class);
    final List<PMMLIncludedModel> includedModels = asList(includedModel1, includedModel2, includedModel3);
    final List<Path> paths = asList(path1, path2, path3);
    when(pathsHelper.getPMMLModelsPaths(workspaceProject)).thenReturn(paths);
    when(includedDocumentsFilter.getDocumentFromImports(dmnModelPath, path1, includedModels)).thenReturn(pmmlDocument1);
    when(includedDocumentsFilter.getDocumentFromImports(dmnModelPath, path2, includedModels)).thenReturn(pmmlDocument2);
    when(includedDocumentsFilter.getDocumentFromImports(dmnModelPath, path3, includedModels)).thenReturn(pmmlDocument3);
    final List<PMMLDocumentMetadata> actualPMMLDocuments = service.loadPMMLDocumentsFromImports(dmnModelPath, workspaceProject, includedModels);
    final List<PMMLDocumentMetadata> expectedPMMLDocuments = asList(pmmlDocument1, pmmlDocument2, pmmlDocument3);
    assertEquals(expectedPMMLDocuments, actualPMMLDocuments);
}
Also used : PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) Path(org.uberfire.backend.vfs.Path) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Test(org.junit.Test)

Example 10 with PMMLIncludedModel

use of org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel in project kie-wb-common by kiegroup.

the class DMNMarshallerImportsClientHelperTest method loadModelsPMMLFile.

@Test
public void loadModelsPMMLFile() {
    final PMMLDocumentMetadata pmmlDocumentMetadata = new PMMLDocumentMetadata(PMML_PATH, PMML_FILE, PMML.getDefaultNamespace(), Collections.emptyList());
    when(dmnImportsContentService.getModelsURIs()).thenReturn(promises.resolve(new String[] { PMML_PATH }));
    when(dmnImportsContentService.loadFile(PMML_PATH)).thenReturn(promises.resolve(PMML_CONTENT));
    when(dmnImportsContentService.loadFile(PMML_PATH)).thenReturn(promises.resolve(PMML_CONTENT));
    doReturn(promises.resolve(pmmlDocumentMetadata)).when(dmnImportsContentService).getPMMLDocumentMetadata(PMML_PATH);
    importsHelper.loadModels(includedModelServiceCallback);
    verify(includedModelServiceCallback).onSuccess(modelsCapture.capture());
    assertEquals(1, modelsCapture.getValue().size());
    assertEquals(PMML_FILE, modelsCapture.getValue().get(0).getPath());
    assertEquals(PMML_FILE, modelsCapture.getValue().get(0).getModelName());
    assertEquals(PMML.getDefaultNamespace(), modelsCapture.getValue().get(0).getImportType());
    assertEquals(0, ((PMMLIncludedModel) modelsCapture.getValue().get(0)).getModelCount().intValue());
}
Also used : PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Test(org.junit.Test)

Aggregations

PMMLIncludedModel (org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel)13 Test (org.junit.Test)11 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)8 Path (org.uberfire.backend.vfs.Path)4 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)2 DMNIncludedModel (org.kie.workbench.common.dmn.api.editors.included.DMNIncludedModel)2 IncludedModel (org.kie.workbench.common.dmn.api.editors.included.IncludedModel)2 ServiceCallback (org.kie.workbench.common.stunner.core.client.service.ServiceCallback)2 Promise (elemental2.promise.Promise)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Level (java.util.logging.Level)1