Search in sources :

Example 1 with EnableTestToolsEvent

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();
}
Also used : EnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest) Test(org.junit.Test)

Example 2 with EnableTestToolsEvent

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();
}
Also used : EnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent) AbstractScenarioSimulationTest(org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest) Test(org.junit.Test)

Example 3 with EnableTestToolsEvent

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);
    }
}
Also used : ReloadTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) EnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent)

Example 4 with 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;
}
Also used : ReloadTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent) EnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent) ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent)

Example 5 with EnableTestToolsEvent

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);
}
Also used : FactMapping(org.drools.scenariosimulation.api.model.FactMapping) ScenarioSimulationBuilders(org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationBuilders) HEADER_ROWS_HEIGHT(org.drools.workbench.screens.scenariosimulation.client.TestProperties.HEADER_ROWS_HEIGHT) TEST(org.drools.workbench.screens.scenariosimulation.client.TestProperties.TEST) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) AbstractScesimData(org.drools.scenariosimulation.api.model.AbstractScesimData) ExpressionIdentifier(org.drools.scenariosimulation.api.model.ExpressionIdentifier) FactMappingType(org.drools.scenariosimulation.api.model.FactMappingType) EnableTestToolsEvent(org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Before(org.junit.Before)

Aggregations

EnableTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.events.EnableTestToolsEvent)7 AbstractScenarioSimulationTest (org.drools.workbench.screens.scenariosimulation.client.AbstractScenarioSimulationTest)4 Test (org.junit.Test)4 ReloadTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.events.ReloadTestToolsEvent)2 ScenarioHeaderMetaData (org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)2 AbstractScesimData (org.drools.scenariosimulation.api.model.AbstractScesimData)1 ExpressionIdentifier (org.drools.scenariosimulation.api.model.ExpressionIdentifier)1 FactMapping (org.drools.scenariosimulation.api.model.FactMapping)1 FactMappingType (org.drools.scenariosimulation.api.model.FactMappingType)1 HEADER_ROWS_HEIGHT (org.drools.workbench.screens.scenariosimulation.client.TestProperties.HEADER_ROWS_HEIGHT)1 TEST (org.drools.workbench.screens.scenariosimulation.client.TestProperties.TEST)1 EnableTestToolsCommand (org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.EnableTestToolsCommand)1 ScenarioSimulationBuilders (org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationBuilders)1 ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent (org.drools.workbench.screens.scenariosimulation.client.utils.ScenarioSimulationGridHeaderUtilities.getEnableTestToolsEvent)1 Before (org.junit.Before)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1