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);
}
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();
}
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();
}
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);
}
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());
}
Aggregations