Search in sources :

Example 1 with PMMLModelMetadata

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

the class PMMLDocumentMetadataProviderTest method testGetPMMLDocumentModelNames.

@Test
public void testGetPMMLDocumentModelNames() {
    final List<PMMLDocumentMetadata> pmmlDocuments = new ArrayList<>();
    pmmlDocuments.add(new PMMLDocumentMetadata("path", "document", DMNImportTypes.PMML.getDefaultNamespace(), asList(new PMMLModelMetadata("zModel1", Collections.emptySet()), new PMMLModelMetadata("aModel2", Collections.emptySet()))));
    final ServiceCallback<List<PMMLDocumentMetadata>> callback = loadPMMLIncludedDocuments();
    callback.onSuccess(pmmlDocuments);
    final List<String> modelNames = provider.getPMMLDocumentModels("document");
    assertThat(modelNames).containsSequence("aModel2", "zModel1");
    assertThat(provider.getPMMLDocumentModels("unknown")).isEmpty();
}
Also used : PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) PMMLModelMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata) Test(org.junit.Test)

Example 2 with PMMLModelMetadata

use of org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata 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());
}
Also used : Path(org.uberfire.backend.vfs.Path) PMMLIncludedModel(org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel) PMMLParameterMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLParameterMetadata) PMMLModelInfo(org.kie.dmn.core.pmml.PMMLModelInfo) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) PMMLModelMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata) Test(org.junit.Test)

Example 3 with PMMLModelMetadata

use of org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata 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());
}
Also used : Path(org.uberfire.backend.vfs.Path) PMMLParameterMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLParameterMetadata) PMMLModelInfo(org.kie.dmn.core.pmml.PMMLModelInfo) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) PMMLModelMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata) Test(org.junit.Test)

Example 4 with PMMLModelMetadata

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

the class PMMLDocumentMetadataProvider method getPMMLDocumentModelParameterNames.

public List<String> getPMMLDocumentModelParameterNames(final String pmmlDocumentName, final String pmmlDocumentModelName) {
    final List<String> pmmlDocumentModelParameterNames = new ArrayList<>();
    if (pmmlDocuments.containsKey(pmmlDocumentName)) {
        final PMMLDocumentMetadata document = pmmlDocuments.get(pmmlDocumentName);
        document.getModels().stream().filter(model -> Objects.equals(pmmlDocumentModelName, model.getName())).findFirst().map(PMMLModelMetadata::getInputParameters).orElse(Collections.emptySet()).forEach(parameter -> pmmlDocumentModelParameterNames.add(parameter.getName()));
        pmmlDocumentModelParameterNames.sort(Comparator.naturalOrder());
    }
    return pmmlDocumentModelParameterNames;
}
Also used : PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) ArrayList(java.util.ArrayList) PMMLModelMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata)

Example 5 with PMMLModelMetadata

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

the class PMMLDocumentMetadataProviderTest method testGetPMMLDocumentModelParameterNames.

@Test
public void testGetPMMLDocumentModelParameterNames() {
    final List<PMMLDocumentMetadata> pmmlDocuments = new ArrayList<>();
    pmmlDocuments.add(new PMMLDocumentMetadata("path", "document", DMNImportTypes.PMML.getDefaultNamespace(), singletonList(new PMMLModelMetadata("model", new Sets.Builder<PMMLParameterMetadata>().add(new PMMLParameterMetadata("zParameter1")).add(new PMMLParameterMetadata("aParameter2")).build()))));
    final ServiceCallback<List<PMMLDocumentMetadata>> callback = loadPMMLIncludedDocuments();
    callback.onSuccess(pmmlDocuments);
    final List<String> modelNames = provider.getPMMLDocumentModelParameterNames("document", "model");
    assertThat(modelNames).containsSequence("aParameter2", "zParameter1");
    assertThat(provider.getPMMLDocumentModelParameterNames("unknown", "unknown")).isEmpty();
}
Also used : PMMLParameterMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLParameterMetadata) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Sets(org.kie.soup.commons.util.Sets) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) PMMLModelMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata) Test(org.junit.Test)

Aggregations

PMMLModelMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata)7 Test (org.junit.Test)6 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)5 ArrayList (java.util.ArrayList)3 PMMLParameterMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLParameterMetadata)3 Arrays.asList (java.util.Arrays.asList)2 Collections.singletonList (java.util.Collections.singletonList)2 List (java.util.List)2 PMMLModelInfo (org.kie.dmn.core.pmml.PMMLModelInfo)2 Import (org.kie.workbench.common.dmn.api.definition.model.Import)2 ImportPMML (org.kie.workbench.common.dmn.api.definition.model.ImportPMML)2 JSITImport (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITImport)2 Path (org.uberfire.backend.vfs.Path)2 Sets (org.kie.soup.commons.util.Sets)1 PMMLIncludedModel (org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel)1