use of org.drools.workbench.screens.scenariosimulation.client.events.SetPropertyHeaderEvent in project drools-wb by kiegroup.
the class ScenarioSimulationEventHandlerTest method onSetPropertyHeaderCollectionEvent.
@Test
public void onSetPropertyHeaderCollectionEvent() {
SetPropertyHeaderEvent event = new SetPropertyHeaderEvent(GridWidget.SIMULATION, FULL_PACKAGE, CLASS_NAME, MULTIPART_VALUE_ELEMENTS, LIST_CLASS_NAME, FactMappingValueType.NOT_EXPRESSION, IMPORTED_PREFIX);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnProperty(anyList(), any())).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnType(anyString())).thenReturn(false);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, times(1)).show(eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioMainTitle()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioMainQuestion()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioText1()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioTextQuestion()), isNull(), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteValues()), isA(org.uberfire.mvp.Command.class));
//
reset(scenarioSimulationEventHandler, deletePopupPresenterMock, preserveDeletePopupPresenterMock);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnProperty(anyList(), any())).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnType(anyString())).thenReturn(true);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, times(1)).show(eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioMainTitle()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioMainQuestion()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioText1()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioTextQuestion()), isNull(), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteValues()), isA(org.uberfire.mvp.Command.class));
}
use of org.drools.workbench.screens.scenariosimulation.client.events.SetPropertyHeaderEvent in project drools-wb by kiegroup.
the class TestToolsPresenter method onModifyColumn.
@Override
public void onModifyColumn() {
if (editingColumnEnabled) {
if (selectedListGroupItemView != null) {
String className = selectedListGroupItemView.getActualClassName();
getFactModelTreeFromMaps(className).ifPresent(factModelTree -> eventBus.fireEvent(new SetPropertyHeaderEvent(gridWidget, factModelTree.getFullPackage(), factModelTree.getTypeName(), Collections.unmodifiableList(Arrays.asList(className)), factModelTree.getFullTypeName(), FactMappingValueType.EXPRESSION, factModelTree.getImportPrefix())));
} else if (selectedFieldItemView != null) {
String baseClass = selectedFieldItemView.getFullPath().get(0);
List<String> propertyNameElements = new ArrayList<>(selectedFieldItemView.getFullPath());
if (!isSimple(baseClass)) {
propertyNameElements.add(selectedFieldItemView.getFieldName());
}
getFactModelTreeFromMaps(baseClass).ifPresent(factModelTree -> eventBus.fireEvent(new SetPropertyHeaderEvent(gridWidget, factModelTree.getFullPackage(), factModelTree.getTypeName(), Collections.unmodifiableList(propertyNameElements), selectedFieldItemView.getClassName(), FactMappingValueType.NOT_EXPRESSION, factModelTree.getImportPrefix())));
}
}
}
use of org.drools.workbench.screens.scenariosimulation.client.events.SetPropertyHeaderEvent in project drools-wb by kiegroup.
the class ScenarioSimulationEventHandlerTest method onSetPropertyHeaderEvent.
@Test
public void onSetPropertyHeaderEvent() {
SetPropertyHeaderEvent event = new SetPropertyHeaderEvent(GridWidget.SIMULATION, FULL_PACKAGE, CLASS_NAME, MULTIPART_VALUE_ELEMENTS, VALUE_CLASS_NAME, FactMappingValueType.NOT_EXPRESSION, IMPORTED_PREFIX);
when(scenarioGridModelMock.getSelectedColumn()).thenReturn(null);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any());
//
doReturn(gridColumnMock).when(scenarioGridModelMock).getSelectedColumn();
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(true);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, times(1)).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any());
//
reset(scenarioSimulationEventHandler);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(true);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any());
//
reset(scenarioSimulationEventHandler);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(false);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any());
//
reset(scenarioSimulationEventHandler);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(true);
when(scenarioGridModelMock.isSameSelectedColumnProperty(anyList(), any())).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnType(anyString())).thenReturn(true);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, times(1)).commonExecution(isA(SetPropertyHeaderCommand.class), eq(true));
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any());
//
reset(scenarioSimulationEventHandler);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnProperty(anyList(), any())).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnType(anyString())).thenReturn(true);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, times(1)).show(eq(ScenarioSimulationEditorConstants.INSTANCE.preserveDeleteScenarioMainTitle()), eq(ScenarioSimulationEditorConstants.INSTANCE.preserveDeleteScenarioMainQuestion()), eq(ScenarioSimulationEditorConstants.INSTANCE.preserveDeleteScenarioText1()), eq(ScenarioSimulationEditorConstants.INSTANCE.preserveDeleteScenarioTextQuestion()), eq(ScenarioSimulationEditorConstants.INSTANCE.preserveDeleteScenarioTextOption1()), eq(ScenarioSimulationEditorConstants.INSTANCE.preserveDeleteScenarioTextOption2()), eq(ScenarioSimulationEditorConstants.INSTANCE.preserveValues()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteValues()), isA(org.uberfire.mvp.Command.class), isA(org.uberfire.mvp.Command.class));
verify(deletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any());
//
reset(scenarioSimulationEventHandler, preserveDeletePopupPresenterMock);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(true);
when(scenarioGridModelMock.isSameSelectedColumnProperty(anyList(), any())).thenReturn(true);
when(scenarioGridModelMock.isSameSelectedColumnType(anyString())).thenReturn(false);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, times(1)).commonExecution(isA(SetPropertyHeaderCommand.class), eq(true));
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any());
//
reset(scenarioSimulationEventHandler, deletePopupPresenterMock);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnProperty(anyList(), any())).thenReturn(true);
when(scenarioGridModelMock.isSameSelectedColumnType(anyString())).thenReturn(false);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, times(1)).show(eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioMainTitle()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioMainQuestion()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioText1()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioTextQuestion()), isNull(), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteValues()), isA(org.uberfire.mvp.Command.class));
//
reset(scenarioSimulationEventHandler, preserveDeletePopupPresenterMock, deletePopupPresenterMock);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(true);
when(scenarioGridModelMock.isSameSelectedColumnProperty(anyList(), any())).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnType(anyString())).thenReturn(false);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, times(1)).commonExecution(isA(SetPropertyHeaderCommand.class), eq(true));
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any());
//
reset(scenarioSimulationEventHandler);
when(scenarioGridModelMock.isAlreadyAssignedProperty(MULTIPART_VALUE_ELEMENTS)).thenReturn(false);
when(scenarioGridModelMock.isSelectedColumnEmpty()).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnProperty(anyList(), any())).thenReturn(false);
when(scenarioGridModelMock.isSameSelectedColumnType(anyString())).thenReturn(false);
scenarioSimulationEventHandler.onEvent(event);
verify(scenarioSimulationEventHandler, never()).onEvent(isA(ScenarioNotificationEvent.class));
verify(scenarioSimulationEventHandler, never()).commonExecution(isA(SetPropertyHeaderCommand.class), anyBoolean());
verify(preserveDeletePopupPresenterMock, never()).show(anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), anyString(), any(), any());
verify(deletePopupPresenterMock, times(1)).show(eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioMainTitle()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioMainQuestion()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioText1()), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteScenarioTextQuestion()), isNull(), eq(ScenarioSimulationEditorConstants.INSTANCE.deleteValues()), isA(org.uberfire.mvp.Command.class));
}
Aggregations