use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData 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);
}
use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilitiesTest method testIsHeaderEditableInstanceAndPropertyAssignedAndPropertySelected.
@Test
public void testIsHeaderEditableInstanceAndPropertyAssignedAndPropertySelected() {
when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
when(scenarioGridColumnOne.isPropertyAssigned()).thenReturn(true);
final ScenarioHeaderMetaData metaDataMock = (ScenarioHeaderMetaData) scenarioGridColumnOne.getHeaderMetaData().get(0);
when(metaDataMock.isPropertyHeader()).thenReturn(true);
final boolean result = ScenarioSimulationGridHeaderUtilities.isEditableHeader(scenarioGridColumnOne, 0);
assertThat(result).as("Instance and Property Assigned and Property selected").isTrue();
}
use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilitiesTest method mockGridColumn.
private ScenarioGridColumn mockGridColumn(final double width, final List<GridColumn.HeaderMetaData> headerMetaData, final String columnTitle, final String COLUMN_GROUP) {
final ScenarioGridColumn uiColumn = mock(ScenarioGridColumn.class);
doReturn(headerMetaData).when(uiColumn).getHeaderMetaData();
doReturn(width).when(uiColumn).getWidth();
final ScenarioHeaderMetaData informationHeader = mock(ScenarioHeaderMetaData.class);
when(informationHeader.getColumnGroup()).thenReturn(COLUMN_GROUP);
when(informationHeader.getTitle()).thenReturn(columnTitle);
when(uiColumn.getInformationHeaderMetaData()).thenReturn(informationHeader);
when(uiColumn.isEditableHeaders()).thenReturn(true);
return uiColumn;
}
use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilitiesTest method testIsHeaderEditableInstanceAndPropertyAssignedButNotSelected.
@Test
public void testIsHeaderEditableInstanceAndPropertyAssignedButNotSelected() {
when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
when(scenarioGridColumnOne.isPropertyAssigned()).thenReturn(true);
final ScenarioHeaderMetaData metaDataMock = (ScenarioHeaderMetaData) scenarioGridColumnOne.getHeaderMetaData().get(0);
when(metaDataMock.isPropertyHeader()).thenReturn(false);
when(metaDataMock.isInstanceHeader()).thenReturn(false);
final boolean result = ScenarioSimulationGridHeaderUtilities.isEditableHeader(scenarioGridColumnOne, 0);
assertThat(result).as("Instance and Property Assigned but not selected").isFalse();
}
use of org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilitiesTest method testIsHeaderEditableInstanceAssignedAndSelected.
@Test
public void testIsHeaderEditableInstanceAssignedAndSelected() {
when(scenarioGridColumnOne.isInstanceAssigned()).thenReturn(true);
final ScenarioHeaderMetaData metaDataMock = (ScenarioHeaderMetaData) scenarioGridColumnOne.getHeaderMetaData().get(0);
when(metaDataMock.isInstanceHeader()).thenReturn(true);
final boolean result = ScenarioSimulationGridHeaderUtilities.isEditableHeader(scenarioGridColumnOne, 0);
assertThat(result).as("Instance Assigned and selected").isTrue();
}
Aggregations