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