Search in sources :

Example 16 with MetadataCol52

use of org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52 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 17 with MetadataCol52

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

the class ColumnsPagePresenterTest method testHideMetadataClickHandlerWhenVetoExceptionIsRaised.

@Test
public void testHideMetadataClickHandlerWhenVetoExceptionIsRaised() throws Exception {
    final MetadataCol52 clone = mock(MetadataCol52.class);
    final CheckBox checkBox = mock(CheckBox.class);
    final ClickEvent clickEvent = mock(ClickEvent.class);
    final GuidedDecisionTableView.Presenter activeDecisionTable = mock(GuidedDecisionTableView.Presenter.class);
    doReturn(Optional.of(activeDecisionTable)).when(modeller).getActiveDecisionTable();
    doReturn(clone).when(metadataColumn).cloneColumn();
    doThrow(ModelSynchronizer.VetoException.class).when(activeDecisionTable).updateColumn(metadataColumn, clone);
    doNothing().when(presenter).showGenericVetoMessage();
    final ClickHandler clickHandler = presenter.hideMetadataClickHandler(modeller, checkBox, metadataColumn);
    clickHandler.onClick(clickEvent);
    verify(clone).setHideColumn(checkBox.getValue());
    verify(presenter).showGenericVetoMessage();
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CheckBox(org.gwtbootstrap3.client.ui.CheckBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) Test(org.junit.Test)

Example 18 with MetadataCol52

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

the class ColumnsPagePresenterTest method testRefreshMetaDataWidgetWhenModellerIsNotNullAndMetaDataColumnsIsEmpty.

@Test
public void testRefreshMetaDataWidgetWhenModellerIsNotNullAndMetaDataColumnsIsEmpty() {
    final List<MetadataCol52> metaDataColumns = new ArrayList<>();
    final Label blankSlate = mock(Label.class);
    doReturn(verticalPanel).when(presenter).getMetaDataWidget();
    doReturn(blankSlate).when(presenter).blankSlate();
    presenter.refreshMetaDataWidget(metaDataColumns);
    verify(verticalPanel).clear();
    verify(verticalPanel).add(blankSlate);
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) ArrayList(java.util.ArrayList) Label(com.google.gwt.user.client.ui.Label) Test(org.junit.Test)

Example 19 with MetadataCol52

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

the class NewGuidedDecisionTableHandlerTest method testResolvedHitPolicy.

@Test
public void testResolvedHitPolicy() throws Exception {
    final Package pkg = mock(Package.class);
    final Path resourcesPath = PathFactory.newPath("resources", "default://project/src/main/resources");
    when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath);
    when(options.isUsingWizard()).thenReturn(false);
    when(options.getHitPolicy()).thenReturn(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT);
    handler.create(pkg, "fileName", newResourcePresenter);
    final ArgumentCaptor<GuidedDecisionTable52> dtableArgumentCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class);
    verify(service, times(1)).create(eq(resourcesPath), eq("fileName." + resourceType.getSuffix()), dtableArgumentCaptor.capture(), any(String.class));
    final GuidedDecisionTable52 model = dtableArgumentCaptor.getValue();
    assertEquals(1, model.getMetadataCols().size());
    final MetadataCol52 metadataCol52 = model.getMetadataCols().get(0);
    assertEquals(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT_METADATA_NAME, metadataCol52.getMetadata());
}
Also used : Path(org.uberfire.backend.vfs.Path) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Package(org.guvnor.common.services.project.model.Package) Test(org.junit.Test)

Example 20 with MetadataCol52

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

the class AuditLogEntryCellHelperTest method getSafeHtml_Metadata.

@Test
public void getSafeHtml_Metadata() {
    MetadataCol52 originalColumn = new MetadataCol52();
    originalColumn.setHideColumn(true);
    originalColumn.setDefaultValue(new DTCellValue52("def1"));
    // header & metadata of a metadata column cannot be updated in the ui
    originalColumn.setMetadata("meta");
    originalColumn.setHeader("meta");
    MetadataCol52 newColumn = new MetadataCol52();
    newColumn.setHideColumn(false);
    newColumn.setDefaultValue(new DTCellValue52("def2"));
    // header & metadata of a metadata column cannot be updated in the ui
    newColumn.setMetadata("meta");
    newColumn.setHeader("meta");
    List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
    SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
    assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) UpdateColumnAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Aggregations

MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)67 Test (org.junit.Test)52 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)18 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)12 ArrayList (java.util.ArrayList)11 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)10 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)10 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)9 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)9 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)8 DecisionTableSelectionsChangedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectionsChangedEvent)8 DecisionTableSelectedEvent (org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.DecisionTableSelectedEvent)7 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)6 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)6 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)5 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)5 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)4 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)4 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)4 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)4