Search in sources :

Example 1 with PMMLParameterMetadata

use of org.kie.workbench.common.dmn.api.editors.included.PMMLParameterMetadata 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 2 with PMMLParameterMetadata

use of org.kie.workbench.common.dmn.api.editors.included.PMMLParameterMetadata 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 3 with PMMLParameterMetadata

use of org.kie.workbench.common.dmn.api.editors.included.PMMLParameterMetadata 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

Test (org.junit.Test)3 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)3 PMMLModelMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLModelMetadata)3 PMMLParameterMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLParameterMetadata)3 PMMLModelInfo (org.kie.dmn.core.pmml.PMMLModelInfo)2 Path (org.uberfire.backend.vfs.Path)2 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Sets (org.kie.soup.commons.util.Sets)1 PMMLIncludedModel (org.kie.workbench.common.dmn.api.editors.included.PMMLIncludedModel)1