Search in sources :

Example 11 with CompositeColumn

use of org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testOnRefreshConditionsPanelEvent.

@Test
public void testOnRefreshConditionsPanelEvent() {
    final RefreshConditionsPanelEvent event = mock(RefreshConditionsPanelEvent.class);
    final GuidedDecisionTableView.Presenter eventPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final List<CompositeColumn<? extends BaseColumn>> columns = new ArrayList<>();
    doReturn(eventPresenter).when(event).getPresenter();
    doReturn(columns).when(event).getColumns();
    doNothing().when(presenter).refreshConditionsWidget(any());
    doNothing().when(presenter).refreshColumnsNoteInfo(any());
    presenter.onRefreshConditionsPanelEvent(event);
    verify(presenter).refreshConditionsWidget(columns);
    verify(presenter).refreshColumnsNoteInfo(eventPresenter);
}
Also used : ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RefreshConditionsPanelEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.RefreshConditionsPanelEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 12 with CompositeColumn

use of org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testRefresh.

@Test
public void testRefresh() {
    final GuidedDecisionTable52 guidedDecisionTable52 = mock(GuidedDecisionTable52.class);
    doReturn(Optional.of(guidedDecisionTable52)).when(presenter).getGuidedDecisionTable52();
    doNothing().when(presenter).refreshAttributeWidget(any());
    doNothing().when(presenter).refreshMetaDataWidget(any());
    doNothing().when(presenter).refreshConditionsWidget(any());
    doNothing().when(presenter).refreshActionsWidget(any());
    final List<AttributeCol52> attributeCol52s = new ArrayList<>();
    final List<MetadataCol52> metadataCol52s = new ArrayList<>();
    final List<CompositeColumn<? extends BaseColumn>> compositeColumns = new ArrayList<>();
    final List<ActionCol52> actionCol52s = new ArrayList<>();
    doReturn(attributeCol52s).when(guidedDecisionTable52).getAttributeCols();
    doReturn(metadataCol52s).when(guidedDecisionTable52).getAttributeCols();
    doReturn(compositeColumns).when(guidedDecisionTable52).getAttributeCols();
    doReturn(actionCol52s).when(guidedDecisionTable52).getAttributeCols();
    presenter.refresh();
    verify(presenter).refreshAttributeWidget(attributeCol52s);
    verify(presenter).refreshMetaDataWidget(metadataCol52s);
    verify(presenter).refreshConditionsWidget(compositeColumns);
    verify(presenter).refreshActionsWidget(actionCol52s);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 13 with CompositeColumn

use of org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn in project drools-wb by kiegroup.

the class ColumnsPagePresenterTest method testGroupByTitle.

@Test
public void testGroupByTitle() {
    final List<CompositeColumn<? extends BaseColumn>> conditions = new ArrayList<CompositeColumn<? extends BaseColumn>>() {

        {
            add(compositeColumn1);
            add(compositeColumn2);
            add(compositeColumn3);
        }
    };
    final String title1 = "title1";
    final String title2 = "title2";
    doReturn(title1).when(compositeColumn1).getHeader();
    doReturn(title2).when(compositeColumn2).getHeader();
    doReturn(title1).when(compositeColumn3).getHeader();
    final Map<String, List<BaseColumn>> columnGroups = presenter.groupByTitle(conditions);
    final List<BaseColumn> actualTitle1List = columnGroups.get(title1);
    final List<BaseColumn> actualTitle2List = columnGroups.get(title2);
    final ArrayList<CompositeColumn<? extends BaseColumn>> expectedTitle1List = new ArrayList<CompositeColumn<? extends BaseColumn>>() {

        {
            add(compositeColumn1);
            add(compositeColumn3);
        }
    };
    final ArrayList<CompositeColumn<? extends BaseColumn>> expectedTitle2List = new ArrayList<CompositeColumn<? extends BaseColumn>>() {

        {
            add(compositeColumn2);
        }
    };
    assertEquals(2, columnGroups.size());
    assertEquals(actualTitle1List, expectedTitle1List);
    assertEquals(actualTitle2List, expectedTitle2List);
}
Also used : ArrayList(java.util.ArrayList) 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 14 with CompositeColumn

use of org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn in project drools-wb by kiegroup.

the class ActionSetFactPluginTest method mockPatterns.

private void mockPatterns() {
    final GuidedDecisionTable52 model = mock(GuidedDecisionTable52.class);
    final List<CompositeColumn<?>> patterns = Collections.singletonList(fakePattern());
    final List<ActionCol52> actions = Arrays.asList(fakeActionCol(), fakeActionCol());
    when(model.getConditions()).thenReturn(patterns);
    when(model.getActionCols()).thenReturn(actions);
    when(presenter.getModel()).thenReturn(model);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)

Example 15 with CompositeColumn

use of org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn in project drools-wb by kiegroup.

the class GridWidgetColumnFactoryImplTest method columnResizingListenerSetup_ActionSetFieldColumn.

@Test
public void columnResizingListenerSetup_ActionSetFieldColumn() {
    final Pattern52 pattern = mock(Pattern52.class);
    final ActionSetFieldCol52 column = new ActionSetFieldCol52();
    column.setFactField("MyField");
    column.setHeader("MyColumn");
    column.setBoundName("$f");
    when(model.getConditions()).thenReturn(new ArrayList<CompositeColumn<? extends BaseColumn>>() {

        {
            add(pattern);
        }
    });
    when(pattern.getFactType()).thenReturn("MyFact");
    when(pattern.getBoundName()).thenReturn("$f");
    when(pattern.isBound()).thenReturn(true);
    when(oracle.getFieldType("MyFact", "MyField")).thenReturn(DataType.TYPE_STRING);
    final GridColumn<?> uiColumn = factory.convertColumn(column, access, gridWidget);
    assertTrue(uiColumn instanceof BaseUiColumn);
    assertEquals((int) uiColumn.getWidth(), column.getWidth());
    uiColumn.setWidth(200.0);
    assertEquals(200, column.getWidth());
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BaseUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Aggregations

CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)22 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)20 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)17 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)12 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)11 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)11 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)11 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)11 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)11 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)11 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)11 List (java.util.List)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)5 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)4 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)4 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)4 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)4 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)3