Search in sources :

Example 11 with PMMLIncludedModel

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

the class DMNMarshallerImportsClientHelperTest method getPMMLDocumentsMetadataFromFiles.

@Test
public void getPMMLDocumentsMetadataFromFiles() {
    final PMMLDocumentMetadata documentMetadata = new PMMLDocumentMetadata(PMML_FILE, PMML.getDefaultNamespace(), Collections.emptyList());
    final List<PMMLIncludedModel> includedModels = Arrays.asList(new PMMLIncludedModel(PMML_MODEL_NAME, "", PMML_FILE, PMML.getDefaultNamespace(), 0));
    when(dmnImportsContentService.getModelsPMMLFilesURIs()).thenReturn(promises.resolve(new String[] { PMML_PATH }));
    when(dmnImportsContentService.loadFile(PMML_PATH)).thenReturn(promises.resolve(PMML_CONTENT));
    doReturn(promises.resolve(documentMetadata)).when(dmnImportsContentService).getPMMLDocumentMetadata(PMML_PATH);
    importsHelper.getPMMLDocumentsMetadataFromFiles(includedModels, pmmlMetadataServiceCallback);
    verify(pmmlMetadataServiceCallback, times(1)).onSuccess(pmmlDocumentMetadataArgumentCaptor.capture());
    assertEquals(1, pmmlDocumentMetadataArgumentCaptor.getValue().size());
    assertEquals(PMML_FILE, pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getPath());
    assertEquals(PMML_MODEL_NAME, pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getName());
    assertEquals(PMML.getDefaultNamespace(), pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getImportType());
    assertTrue(pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getModels().isEmpty());
}
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)

Example 12 with PMMLIncludedModel

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

the class DMNAssetsDropdownItemsProviderTest method testAsKieAssetForPMMLIncludedModel.

@Test
public void testAsKieAssetForPMMLIncludedModel() {
    final PMMLIncludedModel model = makePMMLIncludedModel(1, 2);
    final KieAssetsDropdownItem dropdownItem = itemsProvider.asKieAsset(model);
    assertEquals(model.getModelName(), dropdownItem.getText());
    assertEquals(model.getModelPackage(), dropdownItem.getSubText());
    assertEquals(model.getPath(), dropdownItem.getMetaData().get(PATH_METADATA));
    assertEquals(model.getImportType(), dropdownItem.getMetaData().get(IMPORT_TYPE_METADATA));
    assertEquals(model.getModelCount().toString(), dropdownItem.getMetaData().get(PMML_MODEL_COUNT_METADATA));
}
Also used : PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) KieAssetsDropdownItem(org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem) Test(org.junit.Test)

Example 13 with PMMLIncludedModel

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

the class DMNClientServicesProxyImplTest method testLoadPMMLDocumentsFromImports.

@Test
@SuppressWarnings("unchecked")
public void testLoadPMMLDocumentsFromImports() {
    final Optional<WorkspaceProject> optionalWorkspaceProject = Optional.of(workspaceProject);
    final PMMLIncludedModel includedModel1 = mock(PMMLIncludedModel.class);
    final PMMLIncludedModel includedModel2 = mock(PMMLIncludedModel.class);
    final List<PMMLIncludedModel> imports = asList(includedModel1, includedModel2);
    when(projectContext.getActiveWorkspaceProject()).thenReturn(optionalWorkspaceProject);
    clientServicesProxy.loadPMMLDocumentsFromImports(dmnModelPath, imports, serviceCallback);
    verify(includedModelsService).loadPMMLDocumentsFromImports(dmnModelPath, workspaceProject, imports);
}
Also used : PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) 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