use of org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class IncludedModelModal method createIncludedModel.
BaseIncludedModelActiveRecord createIncludedModel(final Map<String, String> metaData) {
final String importType = metaData.get(IMPORT_TYPE_METADATA);
if (Objects.equals(DMNImportTypes.DMN, determineImportType(importType))) {
final DMNIncludedModelActiveRecord dmnIncludedModel = new DMNIncludedModelActiveRecord(recordEngine);
dmnIncludedModel.setDrgElementsCount(Integer.valueOf(metaData.get(DRG_ELEMENT_COUNT_METADATA)));
dmnIncludedModel.setDataTypesCount(Integer.valueOf(metaData.get(ITEM_DEFINITION_COUNT_METADATA)));
return dmnIncludedModel;
} else if (Objects.equals(DMNImportTypes.PMML, determineImportType(importType))) {
final PMMLIncludedModelActiveRecord pmmlIncludedModel = new PMMLIncludedModelActiveRecord(recordEngine);
pmmlIncludedModel.setModelCount(Integer.valueOf(metaData.get(PMML_MODEL_COUNT_METADATA)));
return pmmlIncludedModel;
}
return new DefaultIncludedModelActiveRecord(recordEngine);
}
use of org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class PMMLCardComponentTest method testRefreshView.
@Test
public void testRefreshView() {
final PMMLIncludedModelActiveRecord includedModel = mock(PMMLIncludedModelActiveRecord.class);
final String path = "/bla/bla/bla/111111111111111222222222222222333333333333333444444444444444/file.dmn";
final int modelCount = 12;
when(includedModel.getNamespace()).thenReturn(path);
when(includedModel.getModelCount()).thenReturn(modelCount);
doReturn(includedModel).when(card).getIncludedModel();
card.refreshView();
verify(cardView).setPath("...111111222222222222222333333333333333444444444444444/file.dmn");
verify(cardView).setModelCount(modelCount);
}
use of org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class IncludedModelsFactoryTest method testMakeIncludedPMMLModels.
@Test
public void testMakeIncludedPMMLModels() {
final ImportPMML import1 = mock(ImportPMML.class);
final ImportPMML import2 = mock(ImportPMML.class);
final Name nameMock1 = mock(Name.class);
final Name nameMock2 = mock(Name.class);
final List<Import> imports = asList(import1, import2);
final String name1 = "name1";
final String name2 = "name2";
final String path1 = "path1";
final String path2 = "path2";
final String uuid1 = "123";
final String uuid2 = "456";
final String[] uuids = { uuid1, uuid2 };
final String uri1 = "/src/main/kie/dmn/1";
final String uri2 = "/src/main/kie/dmn/2";
final Integer modelCount1 = 2;
final Integer modelCount2 = 8;
when(nameMock1.getValue()).thenReturn(name1);
when(nameMock2.getValue()).thenReturn(name2);
when(import1.getName()).thenReturn(nameMock1);
when(import2.getName()).thenReturn(nameMock2);
when(import1.getNamespace()).thenReturn(path1);
when(import2.getNamespace()).thenReturn(path2);
when(import1.getImportType()).thenReturn(DMNImportTypes.PMML.getDefaultNamespace());
when(import2.getImportType()).thenReturn(DMNImportTypes.PMML.getDefaultNamespace());
when(import1.getLocationURI()).thenReturn(new LocationURI(uri1));
when(import2.getLocationURI()).thenReturn(new LocationURI(uri2));
when(import1.getModelCount()).thenReturn(modelCount1);
when(import2.getModelCount()).thenReturn(modelCount2);
doAnswer(new Answer() {
private int count = 0;
public Object answer(InvocationOnMock invocation) {
return uuids[count++];
}
}).when(factory).uuidWrapper();
final List<BaseIncludedModelActiveRecord> includedModels = factory.makeIncludedModels(imports);
final BaseIncludedModelActiveRecord includedModel1 = includedModels.get(0);
final BaseIncludedModelActiveRecord includedModel2 = includedModels.get(1);
verify(includedModelsIndex).clear();
verify(includedModelsIndex).index(includedModel1, import1);
verify(includedModelsIndex).index(includedModel2, import2);
assertEquals(2, includedModels.size());
assertEquals(uuid1, includedModel1.getUUID());
assertEquals(uuid2, includedModel2.getUUID());
assertEquals(name1, includedModel1.getName());
assertEquals(name2, includedModel2.getName());
assertEquals(path1, includedModel1.getNamespace());
assertEquals(path2, includedModel2.getNamespace());
assertEquals(uri1, includedModel1.getPath());
assertEquals(uri2, includedModel2.getPath());
assertTrue(includedModel1 instanceof PMMLIncludedModelActiveRecord);
assertTrue(includedModel2 instanceof PMMLIncludedModelActiveRecord);
assertEquals(modelCount1, ((PMMLIncludedModelActiveRecord) includedModel1).getModelCount());
assertEquals(modelCount2, ((PMMLIncludedModelActiveRecord) includedModel2).getModelCount());
assertEquals(recordEngine, includedModel1.getRecordEngine());
assertEquals(recordEngine, includedModel2.getRecordEngine());
}
use of org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class ImportFactoryTest method testMakePMMLImport.
@Test
public void testMakePMMLImport() {
final PMMLIncludedModelActiveRecord record = new PMMLIncludedModelActiveRecord(null);
final String expectedImportType = DMNImportTypes.PMML.getDefaultNamespace();
final String expectedNameValue = "name";
final String path = "/src/main/kie/pmml";
final Name expectedName = new Name(expectedNameValue);
final LocationURI expectedLocationURI = new LocationURI(path);
final int expectedModelCount = 2;
record.setPath(path);
record.setName(expectedNameValue);
record.setNamespace(expectedNameValue);
record.setImportType(DMNImportTypes.PMML.getDefaultNamespace());
record.setModelCount(expectedModelCount);
final Import actualImport = factory.makeImport(record);
assertTrue(actualImport instanceof ImportPMML);
final ImportPMML pmmlImport = (ImportPMML) actualImport;
assertEquals(expectedImportType, actualImport.getImportType());
assertEquals(expectedName, actualImport.getName());
assertEquals(expectedLocationURI, actualImport.getLocationURI());
assertEquals(expectedNameValue, actualImport.getNamespace());
assertEquals(expectedImportType, actualImport.getImportType());
assertEquals(expectedModelCount, pmmlImport.getModelCount());
}
use of org.kie.workbench.common.dmn.client.editors.included.PMMLIncludedModelActiveRecord in project kie-wb-common by kiegroup.
the class IncludedModelModalTest method testIncludePMML.
@Test
public void testIncludePMML() {
final String path = "path";
final String name = "name";
final String namespace = "namespace";
final int modelCount = 2;
final KieAssetsDropdownItem dropdownItem = mock(KieAssetsDropdownItem.class);
when(view.getModelNameInput()).thenReturn(name);
when(dropdown.getValue()).thenReturn(Optional.of(dropdownItem));
when(dropdownItem.getValue()).thenReturn(namespace);
when(dropdownItem.getMetaData()).thenReturn(new Maps.Builder<String, String>().put(PATH_METADATA, path).put(IMPORT_TYPE_METADATA, DMNImportTypes.PMML.getDefaultNamespace()).put(PMML_MODEL_COUNT_METADATA, Integer.toString(modelCount)).build());
doNothing().when(modal).hide();
modal.include();
verify(modal).createIncludedModel(dropdownItem);
verify(grid).refresh();
verify(modal).hide();
verify(refreshDecisionComponentsEvent).fire(any(RefreshDecisionComponents.class));
verify(modal).refreshDataTypesList(includedModelActiveRecordArgumentCaptor.capture());
final BaseIncludedModelActiveRecord baseActiveRecord = includedModelActiveRecordArgumentCaptor.getValue();
assertTrue(baseActiveRecord instanceof PMMLIncludedModelActiveRecord);
final PMMLIncludedModelActiveRecord pmmlActiveRecord = (PMMLIncludedModelActiveRecord) baseActiveRecord;
assertEquals(path, pmmlActiveRecord.getPath());
assertEquals(name, pmmlActiveRecord.getName());
assertEquals(namespace, pmmlActiveRecord.getNamespace());
assertEquals(modelCount, (int) pmmlActiveRecord.getModelCount());
}
Aggregations