use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem 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());
}
use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem in project drools-wb by kiegroup.
the class SettingsPresenterTest method setup.
@Before
public void setup() {
super.setup();
Settings settings = new Settings();
settings.setRuleFlowGroup(RULE_FLOW_GROUP);
settings.setDmoSession(DMO_SESSION);
settings.setDmnFilePath(DMN_FILE_PATH);
settings.setDmnNamespace(DMN_NAMESPACE);
settings.setDmnName(DMN_NAME);
settings.setStateless(STATELESS);
settings.setSkipFromBuild(SKIP_FROM_BUILD);
// spy after initialization to avoid double counting
settingsSpy = spy(settings);
KieAssetsDropdownItem item = new KieAssetsDropdownItem("DMNFile", "", DMN_FILE_PATH, null);
when(settingsScenarioSimulationDropdownMock.getValue()).thenReturn(Optional.of(item));
this.settingsPresenterSpy = spy(new SettingsPresenter(settingsScenarioSimulationDropdownMock, settingsViewMock) {
{
this.settingsScenarioSimulationDropdown = settingsScenarioSimulationDropdownMock;
this.saveCommand = saveCommandMock;
this.eventBus = eventBusMock;
}
});
}
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 kie-wb-common by kiegroup.
the class IncludedModelModalTest method testIncludeDMN.
@Test
public void testIncludeDMN() {
final String path = "path";
final String name = "name";
final String namespace = "namespace";
final int drgElementCount = 2;
final int itemDefinitionCount = 3;
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.DMN.getDefaultNamespace()).put(DRG_ELEMENT_COUNT_METADATA, Integer.toString(drgElementCount)).put(ITEM_DEFINITION_COUNT_METADATA, Integer.toString(itemDefinitionCount)).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 DMNIncludedModelActiveRecord);
final DMNIncludedModelActiveRecord dmnActiveRecord = (DMNIncludedModelActiveRecord) baseActiveRecord;
assertEquals(path, dmnActiveRecord.getPath());
assertEquals(name, dmnActiveRecord.getName());
assertEquals(namespace, dmnActiveRecord.getNamespace());
assertEquals(drgElementCount, (int) dmnActiveRecord.getDrgElementsCount());
assertEquals(itemDefinitionCount, (int) dmnActiveRecord.getDataTypesCount());
}
use of org.kie.workbench.common.widgets.client.assets.dropdown.KieAssetsDropdownItem in project kie-wb-common by kiegroup.
the class DMNAssetsDropdownItemsProviderTest method testWrapDMNItems.
@Test
public void testWrapDMNItems() {
final IncludedModel includedModel1 = makeDMNIncludedModel(1);
final IncludedModel includedModel2 = makeDMNIncludedModel(2);
final IncludedModel includedModel3 = makeDMNIncludedModel(3);
final IncludedModel includedModel4 = makeDMNIncludedModel(4);
final IncludedModel includedModel5 = makeDMNIncludedModel(5);
final Import import1 = mock(Import.class);
final Import import2 = mock(Import.class);
final KieAssetsDropdownItem dropdownItem1 = mock(KieAssetsDropdownItem.class);
final KieAssetsDropdownItem dropdownItem5 = mock(KieAssetsDropdownItem.class);
final List<IncludedModel> t = asList(includedModel1, includedModel2, includedModel3, includedModel4, includedModel5);
when(import1.getNamespace()).thenReturn("://namespace3");
when(import2.getNamespace()).thenReturn("://namespace4");
when(modelsIndex.getIndexedImports()).thenReturn(asList(import1, import2));
when(pageState.getCurrentDiagramNamespace()).thenReturn("://namespace2");
doReturn(dropdownItem1).when(itemsProvider).asKieAsset(includedModel1);
doReturn(dropdownItem5).when(itemsProvider).asKieAsset(includedModel5);
itemsProvider.wrap(actualList -> {
// IncludedModel3 and IncludedModel4 are already imported. IncludedModel2 is the current diagram so only expect 1 and 5.
final List<KieAssetsDropdownItem> expectedList = asList(dropdownItem1, dropdownItem5);
assertEquals(expectedList, actualList);
}).accept(t);
}
Aggregations