Search in sources :

Example 1 with HashMap

use of com.google.gwt.dev.util.collect.HashMap in project drools-wb by kiegroup.

the class BaseEnumSingleSelectUiColumnTest method setupEnums.

@SuppressWarnings("unchecked")
private void setupEnums(final String cellValue, final String... values) {
    final Map<String, String> enums = new HashMap<>();
    for (String value : values) {
        enums.put(value, value);
    }
    doAnswer((InvocationOnMock invocation) -> {
        final Callback<Map<String, String>> callback = (Callback<Map<String, String>>) invocation.getArguments()[3];
        callback.callback(enums);
        return null;
    }).when(presenter).getEnumLookups(anyString(), anyString(), any(DependentEnumsUtilities.Context.class), any(Callback.class));
    when(multiValueFactory.convert(eq(cellValue))).thenReturn(cellValue);
}
Also used : GridBodyCellRenderContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellRenderContext) Callback(org.uberfire.client.callbacks.Callback) HashMap(com.google.gwt.dev.util.collect.HashMap) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Mockito.anyString(org.mockito.Mockito.anyString) HashMap(com.google.gwt.dev.util.collect.HashMap) Map(java.util.Map)

Example 2 with HashMap

use of com.google.gwt.dev.util.collect.HashMap in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testRefreshConditionsWidgetWhenConditionColumnsIsNotEmpty.

@Test
public void testRefreshConditionsWidgetWhenConditionColumnsIsNotEmpty() {
    final ColumnManagementView columnManagementView = mock(ColumnManagementView.class);
    final GuidedDecisionTableAccordionItem item = mock(GuidedDecisionTableAccordionItem.class);
    final Label blankSlate = mock(Label.class);
    final List<CompositeColumn<? extends BaseColumn>> conditions1 = new ArrayList<CompositeColumn<? extends BaseColumn>>() {

        {
            add(compositeColumn1);
        }
    };
    final Map<String, List<BaseColumn>> conditions2 = new HashMap<String, List<BaseColumn>>() {

        {
            put("title", new ArrayList<>());
        }
    };
    doReturn(verticalPanel).when(presenter).getConditionsWidget();
    doReturn(columnManagementView).when(presenter).getConditionsPanel();
    doReturn(blankSlate).when(presenter).blankSlate();
    doReturn(item).when(accordion).getItem(CONDITION);
    doReturn(conditions2).when(presenter).groupByTitle(conditions1);
    presenter.refreshConditionsWidget(conditions1);
    verify(item, never()).setOpen(false);
    verify(verticalPanel, never()).add(blankSlate);
    verify(verticalPanel).add(columnManagementView);
    verify(columnManagementView).renderColumns(conditions2);
}
Also used : HashMap(com.google.gwt.dev.util.collect.HashMap) ColumnManagementView(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.control.ColumnManagementView) Label(com.google.gwt.user.client.ui.Label) ArrayList(java.util.ArrayList) GuidedDecisionTableAccordionItem(org.drools.workbench.screens.guided.dtable.client.editor.page.accordion.GuidedDecisionTableAccordionItem) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) List(java.util.List) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 3 with HashMap

use of com.google.gwt.dev.util.collect.HashMap in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testRefreshActionsWidgetWhenActionColumnsIsNotEmpty.

@Test
public void testRefreshActionsWidgetWhenActionColumnsIsNotEmpty() {
    final ColumnManagementView columnManagementView = mock(ColumnManagementView.class);
    final GuidedDecisionTableAccordionItem item = mock(GuidedDecisionTableAccordionItem.class);
    final Label blankSlate = mock(Label.class);
    final ActionCol52 actionCol52 = mock(ActionCol52.class);
    final List<ActionCol52> actionColumns1 = new ArrayList<ActionCol52>() {

        {
            add(actionCol52);
        }
    };
    final Map<String, List<BaseColumn>> actionColumns2 = new HashMap<String, List<BaseColumn>>() {

        {
            put("title", new ArrayList<>());
        }
    };
    doReturn(verticalPanel).when(presenter).getActionsWidget();
    doReturn(columnManagementView).when(presenter).getActionsPanel();
    doReturn(blankSlate).when(presenter).blankSlate();
    doReturn(item).when(accordion).getItem(ACTION);
    doReturn(actionColumns2).when(presenter).groupByTitle(actionColumns1);
    presenter.refreshActionsWidget(actionColumns1);
    verify(item, never()).setOpen(false);
    verify(verticalPanel, never()).add(blankSlate);
    verify(verticalPanel).add(columnManagementView);
    verify(columnManagementView).renderColumns(actionColumns2);
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) HashMap(com.google.gwt.dev.util.collect.HashMap) ColumnManagementView(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.control.ColumnManagementView) Label(com.google.gwt.user.client.ui.Label) ArrayList(java.util.ArrayList) GuidedDecisionTableAccordionItem(org.drools.workbench.screens.guided.dtable.client.editor.page.accordion.GuidedDecisionTableAccordionItem) List(java.util.List) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

HashMap (com.google.gwt.dev.util.collect.HashMap)3 Label (com.google.gwt.user.client.ui.Label)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)2 GuidedDecisionTableAccordionItem (org.drools.workbench.screens.guided.dtable.client.editor.page.accordion.GuidedDecisionTableAccordionItem)2 ColumnManagementView (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.control.ColumnManagementView)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Map (java.util.Map)1 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)1 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)1 Mockito.anyString (org.mockito.Mockito.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Callback (org.uberfire.client.callbacks.Callback)1 GridBodyCellRenderContext (org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellRenderContext)1