@Test public void whenUserHasCommaOrQuotes_escapesThem() throws Exception { AsyncTaskAuditEventWriter writer = new AsyncTaskAuditEventWriter(auditFile, false, false, true, false); List<AuditEvent> auditEvents = getSampleAuditEventsWithUser().subList(0, 1); auditEvents.get(0).setUser("User,\"1\""); writer.writeEvents(auditEvents); String expectedAuditContent = FileUtils.readFileToString(auditFile); String expectedData = "event,node,start,end,user\n" + "form start,,1548106927319,,\"User,\"\"1\"\"\"\n"; assertEquals(expectedData, expectedAuditContent); }
@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();  }