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