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);
}
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();
}
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);
}
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());
}
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());
}
Aggregations