AuditLogEntryCellHelper { public SafeHtml getSafeHtml( final AuditLogEntry event ) { if ( event instanceof UpdateColumnAuditLogEntry ) { return getSafeHtml( (UpdateColumnAuditLogEntry) event ); } else if ( event instanceof InsertColumnAuditLogEntry ) { return getSafeHtml( (InsertColumnAuditLogEntry) event ); } else if ( event instanceof DeleteColumnAuditLogEntry ) { return getSafeHtml( (DeleteColumnAuditLogEntry) event ); } else if ( event instanceof InsertRowAuditLogEntry ) { return getSafeHtml( (InsertRowAuditLogEntry) event ); } else if ( event instanceof DeleteRowAuditLogEntry ) { return getSafeHtml( (DeleteRowAuditLogEntry) event ); } throw new IllegalArgumentException( "Unrecognised AuditLogEntry type." ); } AuditLogEntryCellHelper( final DateTimeFormat format );  AuditLogEntryCellHelper( final DateTimeFormat format,
                                    final String labelClass,
                                    final String valueClass ); static String getEventTypeDisplayText( final String eventType ); SafeHtml getSafeHtml( final AuditLogEntry event );  }
@Test public void getSafeHtml_Metadata() { MetadataCol52 originalColumn = new MetadataCol52(); originalColumn.setHideColumn(true); originalColumn.setDefaultValue(new DTCellValue52("def1")); originalColumn.setMetadata("meta"); originalColumn.setHeader("meta"); MetadataCol52 newColumn = new MetadataCol52(); newColumn.setHideColumn(false); newColumn.setDefaultValue(new DTCellValue52("def2")); 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()); }
@Test public void getSafeHtml_Attribute() { AttributeCol52 originalColumn = new AttributeCol52(); originalColumn.setReverseOrder(false); originalColumn.setUseRowNumber(false); originalColumn.setHideColumn(false); originalColumn.setDefaultValue(new DTCellValue52("def1")); originalColumn.setAttribute(Attribute.SALIENCE.getAttributeName()); originalColumn.setHeader(Attribute.SALIENCE.getAttributeName()); AttributeCol52 newColumn = new AttributeCol52(); newColumn.setReverseOrder(true); newColumn.setUseRowNumber(true); newColumn.setHideColumn(true); newColumn.setDefaultValue(new DTCellValue52("def2")); newColumn.setAttribute(Attribute.SALIENCE.getAttributeName()); newColumn.setHeader(Attribute.SALIENCE.getAttributeName()); List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn); SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs)); assertEquals(getAttributeHeaderRepre(newColumn.getAttribute()) + getDiffRepre(diffs), result.asString()); }
@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()); }
@Test public void getSafeHtml_ActionInsert() { 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()); }
@Test public void getSafeHtml_ActionSetField() { ActionSetFieldCol52 originalColumn = new ActionSetFieldCol52(); originalColumn.setBoundName("bind1"); originalColumn.setFactField("field1"); originalColumn.setUpdate(false); originalColumn.setValueList("q,w,e"); originalColumn.setHeader("action1"); originalColumn.setHideColumn(false); originalColumn.setDefaultValue(new DTCellValue52("def1")); ActionSetFieldCol52 newColumn = new ActionSetFieldCol52(); newColumn.setBoundName("bind2"); newColumn.setFactField("field2"); newColumn.setUpdate(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()); }
@Test public void getSafeHtml_ActionRetract() { ActionRetractFactCol52 originalColumn = new ActionRetractFactCol52(); originalColumn.setHeader("action1"); originalColumn.setHideColumn(false); originalColumn.setDefaultValue(new DTCellValue52("def1")); ActionRetractFactCol52 newColumn = new ActionRetractFactCol52(); 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(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString()); }
@Test public void getSafeHtml_ActionWorkItemExecute_Simple() { ActionWorkItemCol52 originalColumn = new ActionWorkItemCol52(); originalColumn.setHeader("action1"); originalColumn.setHideColumn(false); ActionWorkItemCol52 newColumn = new ActionWorkItemCol52(); newColumn.setHeader("action2"); newColumn.setHideColumn(true); PortableStringParameterDefinition param1 = new PortableStringParameterDefinition(); param1.setName("param1"); param1.setValue("value1"); PortableWorkDefinition def1 = new PortableWorkDefinition(); def1.setName("def1name"); def1.addParameter(param1); PortableStringParameterDefinition param3 = new PortableStringParameterDefinition(); param3.setName("param3"); param3.setValue("value3"); PortableWorkDefinition def2 = new PortableWorkDefinition(); def2.setName("def2name"); def2.addParameter(param3); originalColumn.setWorkItemDefinition(def1); newColumn.setWorkItemDefinition(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()); }
@Test public void getSafeHtml_ActionWorkItemExecute_Complex() { ActionWorkItemCol52 originalColumn = new ActionWorkItemCol52(); originalColumn.setHeader("action1"); originalColumn.setHideColumn(false); ActionWorkItemCol52 newColumn = new ActionWorkItemCol52(); newColumn.setHeader("action2"); newColumn.setHideColumn(true); PortableStringParameterDefinition param1 = new PortableStringParameterDefinition(); param1.setName("param1"); param1.setValue("value1"); PortableStringParameterDefinition param2 = new PortableStringParameterDefinition(); param2.setName("param2"); param2.setValue("value2"); PortableWorkDefinition def1 = new PortableWorkDefinition(); def1.setName("def1name"); def1.addParameter(param1); def1.addParameter(param2); PortableStringParameterDefinition param3 = new PortableStringParameterDefinition(); param3.setName("param3"); param3.setValue("value3"); PortableStringParameterDefinition param4 = new PortableStringParameterDefinition(); param4.setName("param1"); param4.setValue("value1"); PortableStringParameterDefinition param5 = new PortableStringParameterDefinition(); param5.setName("param5"); param5.setBinding("binding5"); PortableStringParameterDefinition param6 = new PortableStringParameterDefinition(); param6.setName("param2"); param6.setValue("value6"); PortableWorkDefinition def2 = new PortableWorkDefinition(); def2.setName("def2name"); def2.addParameter(param3); def2.addParameter(param4); def2.addParameter(param5); def2.addParameter(param6); originalColumn.setWorkItemDefinition(def1); newColumn.setWorkItemDefinition(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()); }
@Test public void getSafeHtml_ActionWorkItemInsert() { ActionWorkItemInsertFactCol52 originalColumn = new ActionWorkItemInsertFactCol52(); originalColumn.setParameterClassName("ParamClass1"); originalColumn.setWorkItemName("WI1"); originalColumn.setWorkItemResultParameterName("param1"); originalColumn.setBoundName("b1"); originalColumn.setFactField("field1"); originalColumn.setInsertLogical(false); originalColumn.setHeader("action1"); originalColumn.setHideColumn(false); ActionWorkItemInsertFactCol52 newColumn = new ActionWorkItemInsertFactCol52(); newColumn.setParameterClassName("ParamClass2"); newColumn.setWorkItemName("WI2"); newColumn.setWorkItemResultParameterName("param2"); newColumn.setBoundName("b2"); newColumn.setFactField("field2"); newColumn.setInsertLogical(true); newColumn.setHeader("action2"); newColumn.setHideColumn(true); 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()); }
@Test public void getSafeHtml_ActionWorkItemSetField() { ActionWorkItemSetFieldCol52 originalColumn = new ActionWorkItemSetFieldCol52(); originalColumn.setParameterClassName("ParamClass1"); originalColumn.setWorkItemName("WI1"); originalColumn.setWorkItemResultParameterName("param1"); originalColumn.setBoundName("bind1"); originalColumn.setFactField("field1"); originalColumn.setUpdate(false); originalColumn.setHeader("action1"); originalColumn.setHideColumn(false); ActionWorkItemSetFieldCol52 newColumn = new ActionWorkItemSetFieldCol52(); newColumn.setParameterClassName("ParamClass2"); newColumn.setWorkItemName("WI2"); newColumn.setWorkItemResultParameterName("param2"); newColumn.setBoundName("bind2"); newColumn.setFactField("field2"); newColumn.setUpdate(true); newColumn.setHeader("action2"); newColumn.setHideColumn(true); 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()); }
@Test public void getSafeHtml_BrlCondition() { BRLConditionColumn originalColumn = new BRLConditionColumn(); originalColumn.setHeader("condition1"); originalColumn.setHideColumn(false); BRLConditionColumn newColumn = new BRLConditionColumn(); newColumn.setHeader("condition2"); newColumn.setHideColumn(true); 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()); }
@Test public void getSafeHtml_BrlCondition_DefinitionOnly() { BRLConditionColumn originalColumn = new BRLConditionColumn(); originalColumn.setDefinition(Arrays.asList(new FactPattern("FactType1"))); originalColumn.setHeader("condition"); originalColumn.setHideColumn(false); BRLConditionColumn newColumn = new BRLConditionColumn(); originalColumn.setDefinition(Arrays.asList(new FactPattern("FactType2"), new FactPattern("FactType3"))); newColumn.setHeader("condition"); newColumn.setHideColumn(false); List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn); SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs)); assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(new ArrayList<>()), result.asString()); }
@Test public void getSafeHtml_BrlAction() { BRLActionColumn originalColumn = new BRLActionColumn(); originalColumn.setHeader("action1"); originalColumn.setHideColumn(false); BRLActionColumn newColumn = new BRLActionColumn(); newColumn.setHeader("action2"); newColumn.setHideColumn(true); 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()); }
@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)); assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(new ArrayList<>()), result.asString()); }