Skip to content

Commit

Permalink
Make sure change reason actually gets written to logs
Browse files Browse the repository at this point in the history
I think we really need to rework the AuditEvent so it doesn't need to
care about the AuditConfig. This means moving the serialization to another class.
I didn't want to get to deep into writing tests until this has been done as I'm worried
it'll be harder to change.
  • Loading branch information
seadowg committed Dec 4, 2019
1 parent 06d1d76 commit ae65dd6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void logEvent(AuditEvent.AuditEventType eventType, FormIndex formIndex,
questionAnswer,
user,
changeReason,
false);
true);

if (isDuplicatedIntervalEvent(newAuditEvent)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public void savingForm() {
updateRequiresReasonToContinue();
}

public void setReason(String reason) {
this.reason = reason;
public void editingForm() {
editingForm = true;
}

public String getReason() {
return reason;
public void setReason(String reason) {
this.reason = reason;
}

public void saveReason(Long currentTime) {
Expand All @@ -41,6 +41,10 @@ public void saveReason(Long currentTime) {
}
}

public String getReason() {
return reason;
}

private void updateRequiresReasonToContinue() {
requiresReasonToContinue.setValue(
editingForm
Expand All @@ -49,8 +53,4 @@ private void updateRequiresReasonToContinue() {
&& auditEventLogger.isChangesMade()
);
}

public void editingForm() {
editingForm = true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public AuditEventLogger getAuditEventLogger() {
AuditConfig auditConfig = getSubmissionMetadata().auditConfig;

if (auditConfig != null) {
setAuditEventLogger(new AuditEventLogger(auditConfig, new AsyncTaskAuditEventWriter(new File(instanceFile.getParentFile().getPath() + File.separator + AUDIT_FILE_NAME), auditConfig.isLocationEnabled(), auditConfig.isTrackingChangesEnabled(), auditConfig.isIdentifyUserEnabled(), false), this));
setAuditEventLogger(new AuditEventLogger(auditConfig, new AsyncTaskAuditEventWriter(new File(instanceFile.getParentFile().getPath() + File.separator + AUDIT_FILE_NAME), auditConfig.isLocationEnabled(), auditConfig.isTrackingChangesEnabled(), auditConfig.isIdentifyUserEnabled(), auditConfig.isTrackChangesReasonEnabled()), this));
} else {
setAuditEventLogger(new AuditEventLogger(null, null, this));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void withUserSet_addsUserToEvents() {

@Test
public void logEvent_WithChangeReason_addsChangeReasonToEvent() {
AuditEventLogger auditEventLogger = new AuditEventLogger(new AuditConfig(null, null, null, false, false, false), testWriter, formController);
AuditEventLogger auditEventLogger = new AuditEventLogger(new AuditConfig(null, null, null, false, false, true), testWriter, formController);

auditEventLogger.logEvent(CHANGE_REASON, null, false, null, 123L, "Blah");
auditEventLogger.exitView(); // Triggers event writing
Expand Down

0 comments on commit ae65dd6

Please sign in to comment.