use of org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_ActionInsert.
@Test
public void getSafeHtml_ActionInsert() {
// hide, insert, value list, default value, field, header
ActionInsertFactCol52 originalColumn = new ActionInsertFactCol52();
originalColumn.setFactField("field1");
originalColumn.setInsertLogical(false);
originalColumn.setValueList("q,w,e");
originalColumn.setHeader("action1");
originalColumn.setHideColumn(false);
originalColumn.setDefaultValue(new DTCellValue52("def1"));
ActionInsertFactCol52 newColumn = new ActionInsertFactCol52();
newColumn.setFactField("field2");
newColumn.setInsertLogical(true);
newColumn.setValueList("a,s,d");
newColumn.setHeader("action2");
newColumn.setHideColumn(true);
newColumn.setDefaultValue(new DTCellValue52("def2"));
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
assertEquals(getActionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
use of org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter_AuditLogTest method updateColumnAddsToLog.
@Test
public void updateColumnAddsToLog() throws VetoException {
dtPresenter.updateColumn(new ActionCol52(), new ActionCol52());
dtPresenter.updateColumn(new AttributeCol52(), new AttributeCol52());
dtPresenter.updateColumn(new ConditionCol52(), new ConditionCol52());
dtPresenter.updateColumn(new MetadataCol52(), new MetadataCol52());
dtPresenter.updateColumn(new Pattern52(), new ConditionCol52(), new Pattern52(), new ConditionCol52());
verify(synchronizer, times(4)).updateColumn(any(BaseColumn.class), any(BaseColumn.class));
verify(synchronizer).updateColumn(any(Pattern52.class), any(ConditionCol52.class), any(Pattern52.class), any(ConditionCol52.class));
verify(model, times(5)).getAuditLog();
assertEquals(5, model.getAuditLog().size());
for (UpdateColumnAuditLogEntry entry : model.getAuditLog().toArray(new UpdateColumnAuditLogEntry[0])) {
assertEquals(diffs, entry.getDiffs());
}
}
use of org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter method doUpdateColumn.
private void doUpdateColumn(final BaseColumn originalColumn, final BaseColumn editedColumn, final VetoableUpdateColumnCommand update, final Command callback) throws VetoException {
if (isReadOnly()) {
return;
}
final List<BaseColumnFieldDiff> diffs = update.execute();
parent.updateLinks();
// Log change to column definition
if (!(diffs == null || diffs.isEmpty())) {
view.getLayer().draw();
model.getAuditLog().add(new UpdateColumnAuditLogEntry(identity.getIdentifier(), originalColumn, editedColumn, diffs));
callback.execute();
}
}
use of org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_Condition.
@Test
public void getSafeHtml_Condition() {
ConditionCol52 originalColumn = new ConditionCol52();
originalColumn.setBinding("bind1");
originalColumn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
originalColumn.setFactField("field1");
originalColumn.setFieldType("FieldType1");
originalColumn.setOperator("==");
originalColumn.setValueList("a,b,c");
originalColumn.setHeader("condition1");
originalColumn.setHideColumn(false);
originalColumn.setDefaultValue(new DTCellValue52("def1"));
ConditionCol52 newColumn = new ConditionCol52();
newColumn.setBinding("bind2");
newColumn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE);
newColumn.setFactField("field2");
newColumn.setFieldType("FieldType2");
newColumn.setOperator("!=");
newColumn.setValueList("x,y,z");
newColumn.setHeader("condition2");
newColumn.setHideColumn(true);
newColumn.setDefaultValue(new DTCellValue52("def2"));
Pattern52 originalPattern = new Pattern52();
originalPattern.setBoundName("patBind1");
originalPattern.setFactType("FactType1");
originalPattern.setEntryPointName("ep1");
Pattern52 newPattern = new Pattern52();
newPattern.setBoundName("patBind2");
newPattern.setFactType("FactType2");
newPattern.setEntryPointName("ep2");
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
diffs.addAll(originalPattern.diff(newPattern));
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
assertEquals(getConditionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
use of org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_BrlAction_DefinitionOnly.
@Test
public void getSafeHtml_BrlAction_DefinitionOnly() {
BRLActionColumn originalColumn = new BRLActionColumn();
originalColumn.setDefinition(Arrays.asList(new ActionRetractFact("fact1")));
originalColumn.setHeader("action");
originalColumn.setHideColumn(false);
BRLActionColumn newColumn = new BRLActionColumn();
newColumn.setDefinition(Arrays.asList(new ActionRetractFact("fact2"), new ActionRetractFact("fact3")));
newColumn.setHeader("action");
newColumn.setHideColumn(false);
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
// Definition diffs are currently not supported, maybe #soon?
// assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(new ArrayList<>()), result.asString());
}
Aggregations