@Test public void whenChangeReasonHasCommaOrQuotes_escapesThem() throws Exception { AsyncTaskAuditEventWriter writer = new AsyncTaskAuditEventWriter(auditFile, false, false, false, true); writer.writeEvents(asList( new AuditEvent(1548108900606L, FORM_RESUME, null, null, null, null), new AuditEvent(1548108900606L, CHANGE_REASON, null, null, null, "A \"good\", reason") )); String auditContent = FileUtils.readFileToString(auditFile); String expectedData = "event,node,start,end,change-reason\n" + "form resume,,1548108900606,,\n" + "change reason,,1548108900606,,\"A \"\"good\"\", reason\"\n"; assertEquals(expectedData, auditContent); }
@Override public void writeEvents(List<AuditEvent> auditEvents) { AuditEvent[] auditEventArray = auditEvents.toArray(new AuditEvent[0]); saveTask = new AuditEventSaveTask(file, isLocationEnabled, isTrackingChangesEnabled, isUserRequired, isTrackChangesReasonEnabled).execute(auditEventArray); }
AsyncTaskAuditEventWriter implements AuditEventLogger.AuditEventWriter { @Override public void writeEvents(List<AuditEvent> auditEvents) { AuditEvent[] auditEventArray = auditEvents.toArray(new AuditEvent[0]); saveTask = new AuditEventSaveTask(file, isLocationEnabled, isTrackingChangesEnabled, isUserRequired, isTrackChangesReasonEnabled).execute(auditEventArray); } }
AsyncTaskAuditEventWriter implements AuditEventLogger.AuditEventWriter { @Override public void writeEvents(List<AuditEvent> auditEvents) { AuditEvent[] auditEventArray = auditEvents.toArray(new AuditEvent[0]); saveTask = new AuditEventSaveTask(file, isLocationEnabled, isTrackingChangesEnabled, isUserRequired, isTrackChangesReasonEnabled).execute(auditEventArray); } AsyncTaskAuditEventWriter(@NonNull File file, boolean isLocationEnabled, boolean isTrackingChangesEnabled, boolean isUserRequired, boolean isTrackChangesReasonEnabled); }
AsyncTaskAuditEventWriter implements AuditEventLogger.AuditEventWriter { @Override public void writeEvents(List<AuditEvent> auditEvents) { AuditEvent[] auditEventArray = auditEvents.toArray(new AuditEvent[0]); saveTask = new AuditEventSaveTask(file, isLocationEnabled, isTrackingChangesEnabled, isUserRequired, isTrackChangesReasonEnabled).execute(auditEventArray); } AsyncTaskAuditEventWriter(@NonNull File file, boolean isLocationEnabled, boolean isTrackingChangesEnabled, boolean isUserRequired, boolean isTrackChangesReasonEnabled); @Override void writeEvents(List<AuditEvent> auditEvents); @Override boolean isWriting(); }
AsyncTaskAuditEventWriter implements AuditEventLogger.AuditEventWriter { @Override public void writeEvents(List<AuditEvent> auditEvents) { AuditEvent[] auditEventArray = auditEvents.toArray(new AuditEvent[0]); saveTask = new AuditEventSaveTask(file, isLocationEnabled, isTrackingChangesEnabled, isUserRequired, isTrackChangesReasonEnabled).execute(auditEventArray); } AsyncTaskAuditEventWriter(@NonNull File file, boolean isLocationEnabled, boolean isTrackingChangesEnabled, boolean isUserRequired, boolean isTrackChangesReasonEnabled); @Override void writeEvents(List<AuditEvent> auditEvents); @Override boolean isWriting();  }