use of org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilitiesTest method testEnableTestToolsEventInstanceAssigned.
@Test
public void testEnableTestToolsEventInstanceAssigned() {
when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
final EnableTestToolsEvent event = ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent(scenarioGridMock, scenarioGridColumnOne, clickedScenarioHeaderMetadataMock, UI_COLUMN_INDEX, COLUMN_GROUP);
assertThat(event.getFilterTerm()).isEqualTo(COLUMN_ONE_TITLE);
assertThat(event.isNotEqualsSearch()).isFalse();
}
use of org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilitiesTest method testEnableTestToolsEventPropertyHeaderPropertyNotAssigned.
@Test
public void testEnableTestToolsEventPropertyHeaderPropertyNotAssigned() {
when(clickedScenarioHeaderMetadataMock.getMetadataType()).thenReturn(ScenarioHeaderMetaData.MetadataType.PROPERTY);
when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
final EnableTestToolsEvent event = ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent(scenarioGridMock, scenarioGridColumnOne, clickedScenarioHeaderMetadataMock, UI_COLUMN_INDEX, COLUMN_GROUP);
assertThat(event.getFilterTerm()).isEqualTo(COLUMN_ONE_TITLE);
assertThat(event.getPropertyNameElements()).isNull();
assertThat(event.isNotEqualsSearch()).isFalse();
}
use of org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioGrid method signalTestToolsHeaderCellSelected.
protected void signalTestToolsHeaderCellSelected(final ScenarioGridColumn scenarioGridColumn, final GridData.SelectedCell selectedHeaderCell, final int uiColumnIndex) {
final ScenarioHeaderMetaData scenarioHeaderMetaData = getColumnScenarioHeaderMetaData(scenarioGridColumn, selectedHeaderCell.getRowIndex());
if (scenarioGridColumn.isInstanceAssigned() && scenarioHeaderMetaData.getMetadataType().equals(ScenarioHeaderMetaData.MetadataType.INSTANCE)) {
eventBus.fireEvent(new ReloadTestToolsEvent(true, true));
} else {
String group = ScenarioSimulationUtils.getOriginalColumnGroup(scenarioHeaderMetaData.getColumnGroup());
final EnableTestToolsEvent enableTestToolsEvent = getEnableTestToolsEvent(this, scenarioGridColumn, scenarioHeaderMetaData, uiColumnIndex, group);
eventBus.fireEvent(enableTestToolsEvent);
}
}
use of org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioSimulationMainGridPanelClickHandler method manageGivenExpectHeaderCoordinates.
/**
* This method manage the click happened on an <i>GIVEN</i> or <i>EXPECT</i> header, starting editing it if not already did.
* @param clickedScenarioHeaderMetadata
* @param scenarioGridColumn
* @param group
* @param uiColumnIndex
* @return
*/
@Override
protected boolean manageGivenExpectHeaderCoordinates(ScenarioHeaderMetaData clickedScenarioHeaderMetadata, ScenarioGridColumn scenarioGridColumn, String group, Integer uiColumnIndex) {
scenarioGrid.setSelectedColumn(uiColumnIndex);
if (scenarioGridColumn.isInstanceAssigned() && clickedScenarioHeaderMetadata.getMetadataType().equals(ScenarioHeaderMetaData.MetadataType.INSTANCE)) {
eventBus.fireEvent(new ReloadTestToolsEvent(true, true));
} else {
EnableTestToolsEvent toFire = getEnableTestToolsEvent(scenarioGrid, scenarioGridColumn, clickedScenarioHeaderMetadata, uiColumnIndex, group);
eventBus.fireEvent(toFire);
}
return true;
}
use of org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent in project drools-wb by kiegroup.
the class ScenarioGridTest method setup.
@Before
public void setup() {
simulation = getSimulation();
when(scenarioGridColumnMock.getPropertyHeaderMetaData()).thenReturn(propertyHeaderMetadataMock);
when(scenarioGridModelMock.getAbstractScesimModel()).thenReturn(Optional.of(simulation));
when(scenarioGridModelMock.getGridWidget()).thenReturn(GridWidget.SIMULATION);
when(scenarioGridModelMock.getScenarioExpressionCellTextAreaSingletonDOMElementFactory()).thenReturn(expressionCellTextAreaSingletonDOMElementFactoryMock);
when(scenarioGridModelMock.getCollectionEditorSingletonDOMElementFactory()).thenReturn(collectionEditorSingletonDOMElementFactory);
factIdentifierGiven = FactIdentifier.create("GIVEN", "GIVEN");
factIdentifierInteger = FactIdentifier.create("Integer", "java.lang.Integer");
factMappingDescription = new FactMapping(EXPRESSION_ALIAS_DESCRIPTION, FactIdentifier.DESCRIPTION, ExpressionIdentifier.DESCRIPTION);
factMappingGiven = new FactMapping(EXPRESSION_ALIAS_GIVEN, factIdentifierGiven, new ExpressionIdentifier("GIVEN", FactMappingType.GIVEN));
factMappingInteger = new FactMapping(EXPRESSION_ALIAS_INTEGER, factIdentifierInteger, new ExpressionIdentifier("GIVEN", FactMappingType.GIVEN));
scenarioGridSpy = spy(new ScenarioGrid(scenarioGridModelMock, scenarioGridLayerMock, scenarioGridRendererMock, scenarioContextMenuRegistryMock) {
@Override
protected <T extends AbstractScesimData> void appendRow(int rowIndex, T scesimData) {
// do nothing
}
@Override
protected ScenarioSimulationBuilders.HeaderBuilder getHeaderBuilderLocal(String instanceTitle, String propertyTitle, String columnId, String columnGroup, FactMappingType factMappingType) {
return headerBuilderMock;
}
@Override
protected ScenarioGridColumn getScenarioGridColumnLocal(ScenarioSimulationBuilders.HeaderBuilder headerBuilder, String placeHolder) {
return scenarioGridColumnMock;
}
@Override
protected BaseGridRendererHelper getBaseGridRendererHelper() {
return rendererHelperMock;
}
@Override
public Viewport getViewport() {
return viewportMock;
}
@Override
protected ScenarioHeaderMetaData getColumnScenarioHeaderMetaData(final ScenarioGridColumn scenarioGridColumn, final int rowIndex) {
return propertyHeaderMetadataMock;
}
@Override
protected EnableTestToolsEvent getEnableTestToolsEvent(final ScenarioGrid scenarioGrid, final ScenarioGridColumn scenarioGridColumn, final ScenarioHeaderMetaData scenarioHeaderMetaData, int uiColumnIndex, String group) {
return new EnableTestToolsEvent();
}
@Override
public Layer getLayer() {
return scenarioGridLayerMock;
}
});
when(rendererHelperMock.getRenderingInformation()).thenReturn(renderingInformationMock);
when(renderingInformationMock.getHeaderRowsHeight()).thenReturn(HEADER_ROWS_HEIGHT);
when(renderingInformationMock.getFloatingBlockInformation()).thenReturn(floatingBlockInformationMock);
when(propertyHeaderMetadataMock.getColumnGroup()).thenReturn(GRID_COLUMN_GROUP);
scenarioGridSpy.setEventBus(eventBusMock);
}
Aggregations