use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.
the class ListGridTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
when(parent.getGridWidget()).thenReturn(parentGridWidget);
when(parentGridWidget.getModel()).thenReturn(parentGridData);
when(parentGridData.getColumns()).thenReturn(Collections.singletonList(parentGridColumn));
when(sessionManager.getCurrentSession()).thenReturn(session);
when(session.getGridPanel()).thenReturn(gridPanel);
when(session.getGridLayer()).thenReturn(gridLayer);
when(session.getCellEditorControls()).thenReturn(cellEditorControls);
definition = new ListEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, expressionEditorDefinitionsSupplier, headerEditor, readOnlyProvider);
final Decision decision = new Decision();
decision.setName(new Name(NAME));
hasName = Optional.of(decision);
expression = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, expression);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add((ExpressionEditorDefinition) definition);
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
when(undefinedExpressionEditor.getParentInformation()).thenReturn(parent);
when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(canvasHandler.getGraphExecutionContext()).thenReturn(graphCommandExecutionContext);
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(gridLayer.getVisibleBounds()).thenReturn(new BaseBounds(0, 0, 100, 200));
when(gridLayer.getViewport()).thenReturn(viewport);
when(viewport.getTransform()).thenReturn(transform);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(diagram.getGraph()).thenReturn(graph);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(Mockito.<String>any())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), Mockito.<String>any(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).getTranslation(Mockito.<String>any());
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.
the class RelationColumnTest method setUp.
@Before
public void setUp() throws Exception {
parentUiModel = new BaseGridData();
parentUiModel.appendRow(new BaseGridRow());
parentUiModel.appendRow(new BaseGridRow());
parentUiModel.appendRow(new BaseGridRow());
parentUiModel.appendColumn(mock(ExpressionEditorColumn.class));
final GridCellTuple parent = new GridCellTuple(0, 0, parentGridWidget);
doReturn(parentUiModel).when(parentGridWidget).getModel();
doReturn(widget).when(domElement).getWidget();
doReturn(parent).when(gridWidget).getParentInformation();
doReturn(100.0).when(gridWidget).getWidth();
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.
the class RelationGridTest method setUp.
@Before
@SuppressWarnings("unchecked")
public void setUp() {
when(sessionManager.getCurrentSession()).thenReturn(session);
when(session.getGridPanel()).thenReturn(gridPanel);
when(session.getGridLayer()).thenReturn(gridLayer);
when(session.getCellEditorControls()).thenReturn(cellEditorControls);
tupleWithoutValue = new GridCellTuple(0, 1, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 1, gridWidget, new BaseGridCellValue<>("value"));
definition = new RelationEditorDefinition(definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, editorSelectedEvent, refreshFormPropertiesEvent, domainObjectSelectionEvent, listSelector, translationService, headerEditors, readOnlyProvider);
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
expression = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, expression);
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(parentGridWidget.getModel()).thenReturn(parentGridData);
when(parentGridData.getColumns()).thenReturn(Collections.singletonList(parentGridColumn));
parent = spy(new GridCellTuple(0, 0, parentGridWidget));
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(canvasHandler.getGraphExecutionContext()).thenReturn(graphContext);
when(diagram.getGraph()).thenReturn(graph);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(gridLayer.getDomElementContainer()).thenReturn(gridLayerDomElementContainer);
when(gridLayerDomElementContainer.iterator()).thenReturn(mock(Iterator.class));
when(gridLayer.getVisibleBounds()).thenReturn(new BaseBounds(0, 0, 200, 200));
when(gridLayer.getViewport()).thenReturn(viewport);
when(viewport.getTransform()).thenReturn(transform);
when(headerEditors.get()).thenReturn(headerEditor);
when(gridBodyCellEditContext.getRelativeLocation()).thenReturn(Optional.empty());
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).getTranslation(Mockito.<String>any());
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.
the class RelationUIModelMapperTest method setup.
@Before
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiRelationColumn1);
this.uiModel.appendColumn(uiRelationColumn2);
when(uiRowNumberColumn.getIndex()).thenReturn(0);
when(uiRelationColumn1.getIndex()).thenReturn(1);
when(uiRelationColumn2.getIndex()).thenReturn(2);
this.relation = new Relation();
this.relation.getColumn().add(new InformationItem());
this.relation.getColumn().add(new InformationItem());
final List rowList1 = new List();
rowList1.getExpression().add(HasExpression.wrap(rowList1, new LiteralExpression() {
{
getText().setValue("le(1,0)");
}
}));
rowList1.getExpression().add(HasExpression.wrap(rowList1, new LiteralExpression() {
{
getText().setValue("le(2,0)");
}
}));
final List rowList2 = new List();
rowList2.getExpression().add(HasExpression.wrap(rowList2, new LiteralExpression() {
{
getText().setValue("le(1,1)");
}
}));
rowList2.getExpression().add(HasExpression.wrap(rowList2, new LiteralExpression() {
{
getText().setValue("le(2,1)");
}
}));
this.relation.getRow().add(rowList1);
this.relation.getRow().add(rowList2);
this.mapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector, DEFAULT_HEIGHT);
this.cellValueSupplier = Optional::empty;
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData in project kie-wb-common by kiegroup.
the class AddContextEntryCommandTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.context = new Context();
this.contextEntry = new ContextEntry() {
{
setVariable(new InformationItem() {
{
setName(new Name("variable"));
}
});
}
};
this.defaultResultContextEntry = new ContextEntry();
this.context.getContextEntry().add(defaultResultContextEntry);
this.uiModel = new BaseGridData();
this.uiModelRow = new BaseGridRow();
this.uiDefaultResultModelRow = new BaseGridRow();
this.uiModel.appendRow(uiDefaultResultModelRow);
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
doReturn(uiModel).when(gridWidget).getModel();
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
this.uiModel.setCellValue(0, 2, new ExpressionCellValue(Optional.of(undefinedExpressionEditor)));
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
doReturn(parent).when(undefinedExpressionEditor).getParentInformation();
doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt());
this.uiModelMapper = new ContextUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(context), () -> false, () -> expressionEditorDefinitions, listSelector, 0);
}
Aggregations