use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem in project kie-wb-common by kiegroup.
the class DMNAssetsDropdownItemsProviderTest method testAsKieAssetForPMMLIncludedModel.
@Test
public void testAsKieAssetForPMMLIncludedModel() {
final PMMLIncludedModel model = makePMMLIncludedModel(1, 2);
final KieAssetsDropdownItem dropdownItem = itemsProvider.asKieAsset(model);
assertEquals(model.getModelName(), dropdownItem.getText());
assertEquals(model.getModelPackage(), dropdownItem.getSubText());
assertEquals(model.getPath(), dropdownItem.getMetaData().get(PATH_METADATA));
assertEquals(model.getImportType(), dropdownItem.getMetaData().get(IMPORT_TYPE_METADATA));
assertEquals(model.getModelCount().toString(), dropdownItem.getMetaData().get(PMML_MODEL_COUNT_METADATA));
}
use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem in project kie-wb-common by kiegroup.
the class DMNAssetsDropdownItemsProviderTest method testWrapPMMLItems.
@Test
public void testWrapPMMLItems() {
final IncludedModel includedModel1 = makePMMLIncludedModel(1);
final IncludedModel includedModel2 = makePMMLIncludedModel(2);
final IncludedModel includedModel3 = makePMMLIncludedModel(3);
final IncludedModel includedModel4 = makePMMLIncludedModel(4);
final IncludedModel includedModel5 = makePMMLIncludedModel(5);
final Import import1 = mock(Import.class);
final Import import2 = mock(Import.class);
final LocationURI import1URI = new LocationURI("/src/main/kie3");
final LocationURI import2URI = new LocationURI("/src/main/kie4");
final KieAssetsDropdownItem dropdownItem1 = mock(KieAssetsDropdownItem.class);
final KieAssetsDropdownItem dropdownItem2 = mock(KieAssetsDropdownItem.class);
final KieAssetsDropdownItem dropdownItem5 = mock(KieAssetsDropdownItem.class);
final List<IncludedModel> t = asList(includedModel1, includedModel2, includedModel3, includedModel4, includedModel5);
when(import1.getLocationURI()).thenReturn(import1URI);
when(import2.getLocationURI()).thenReturn(import2URI);
when(modelsIndex.getIndexedImports()).thenReturn(asList(import1, import2));
doReturn(dropdownItem1).when(itemsProvider).asKieAsset(includedModel1);
doReturn(dropdownItem2).when(itemsProvider).asKieAsset(includedModel2);
doReturn(dropdownItem5).when(itemsProvider).asKieAsset(includedModel5);
itemsProvider.wrap(actualList -> {
// IncludedModel3 and IncludedModel4 are already imported so only expect 1, 2 and 5.
final List<KieAssetsDropdownItem> expectedList = asList(dropdownItem1, dropdownItem2, dropdownItem5);
assertEquals(expectedList, actualList);
}).accept(t);
}
use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem in project kie-wb-common by kiegroup.
the class IncludedModelModalTest method doTestCreateIncludedModel.
@SuppressWarnings("unchecked")
private void doTestCreateIncludedModel(final String name, final String expectedName) {
final String value = "://namespace";
final String path = "/src/path/file";
final String anPackage = "path.file.com";
final Integer expectedDrgElementsCount = 2;
final Integer expectedDataTypesCount = 3;
final Map<String, String> metaData = new Maps.Builder<String, String>().put(PATH_METADATA, path).put(IMPORT_TYPE_METADATA, DMNImportTypes.DMN.getDefaultNamespace()).put(DRG_ELEMENT_COUNT_METADATA, expectedDrgElementsCount.toString()).put(ITEM_DEFINITION_COUNT_METADATA, expectedDataTypesCount.toString()).build();
when(view.getModelNameInput()).thenReturn(name);
final BaseIncludedModelActiveRecord includedModel = modal.createIncludedModel(new KieAssetsDropdownItem(name, anPackage, value, metaData));
assertTrue(includedModel instanceof DMNIncludedModelActiveRecord);
final DMNIncludedModelActiveRecord dmnIncludedModel = (DMNIncludedModelActiveRecord) includedModel;
assertEquals(expectedName, dmnIncludedModel.getName());
assertEquals(value, dmnIncludedModel.getNamespace());
assertEquals(path, dmnIncludedModel.getPath());
assertEquals(expectedDrgElementsCount, dmnIncludedModel.getDrgElementsCount());
assertEquals(expectedDataTypesCount, dmnIncludedModel.getDataTypesCount());
}
use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem in project drools-wb by kiegroup.
the class SettingsPresenterTest method validateDmnPath_Invalid.
@Test
public void validateDmnPath_Invalid() {
KieAssetsDropdownItem item = new KieAssetsDropdownItem("DMNFile", "", "", null);
when(settingsScenarioSimulationDropdownMock.getValue()).thenReturn(Optional.of(item));
settingsPresenterSpy.validateSimulation();
verify(settingsScenarioSimulationDropdownMock, times(1)).getValue();
verify(dmnFilePathErrorLabelStyleMock, times(1)).setDisplay(eq(Style.Display.INLINE));
verify(dmnFilePathErrorLabelMock, times(1)).setInnerText(eq(ScenarioSimulationEditorConstants.INSTANCE.chooseValidDMNAsset()));
verify(settingsPresenterSpy, never()).syncDmnFilePath();
verify(eventBusMock, never()).fireEvent(isA(ValidateSimulationEvent.class));
}
use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem in project drools-wb by kiegroup.
the class SettingsPresenterTest method syncDmnFilePathChangedValue.
@Test
public void syncDmnFilePathChangedValue() {
KieAssetsDropdownItem item = new KieAssetsDropdownItem("DMNFile", "", DMN_FILE_PATH + "2", null);
when(settingsScenarioSimulationDropdownMock.getValue()).thenReturn(Optional.of(item));
settingsPresenterSpy.syncDmnFilePath();
verify(eventBusMock, times(1)).fireEvent(updateSettingsDataEventArgumentCaptor.capture());
assertTrue(updateSettingsDataEventArgumentCaptor.getValue().getSettingsValueChanged().test(settingsSpy));
updateSettingsDataEventArgumentCaptor.getValue().getSettingsChangeToApply().accept(settingsSpy);
verify(settingsSpy, times(1)).setDmnFilePath(eq(DMN_FILE_PATH + "2"));
assertEquals(DMN_FILE_PATH + "2", settingsSpy.getDmnFilePath());
}
Aggregations