@Test public void eventStoreLoadReturnsZeroArrayIfNoDataIsSaved() throws IOException { events = store.load(); assertEquals(0, events.length); }
public LoggableEvent[] load() throws IOException { StringWriter writer = new StringWriter(); Reader reader = configFile.getReader(); LoggableEvent[] result = new LoggableEvent[0]; if (reader == null) { return result; } try { IOUtils.copy(reader, writer); result = getGson().fromJson(writer.toString(), LoggableEvent[].class); if (result == null) { return new LoggableEvent[0]; } } finally { writer.close(); reader.close(); } return result; }
EventStore { public LoggableEvent[] load() throws IOException { StringWriter writer = new StringWriter(); Reader reader = configFile.getReader(); LoggableEvent[] result = new LoggableEvent[0]; if (reader == null) { return result; } try { IOUtils.copy(reader, writer); result = getGson().fromJson(writer.toString(), LoggableEvent[].class); if (result == null) { return new LoggableEvent[0]; } } finally { writer.close(); reader.close(); } return result; } }
EventStore { public LoggableEvent[] load() throws IOException { StringWriter writer = new StringWriter(); Reader reader = configFile.getReader(); LoggableEvent[] result = new LoggableEvent[0]; if (reader == null) { return result; } try { IOUtils.copy(reader, writer); result = getGson().fromJson(writer.toString(), LoggableEvent[].class); if (result == null) { return new LoggableEvent[0]; } } finally { writer.close(); reader.close(); } return result; } EventStore(FileIO configFile); }
EventStore { public LoggableEvent[] load() throws IOException { StringWriter writer = new StringWriter(); Reader reader = configFile.getReader(); LoggableEvent[] result = new LoggableEvent[0]; if (reader == null) { return result; } try { IOUtils.copy(reader, writer); result = getGson().fromJson(writer.toString(), LoggableEvent[].class); if (result == null) { return new LoggableEvent[0]; } } finally { writer.close(); reader.close(); } return result; } EventStore(FileIO configFile); void save(LoggableEvent[] events); LoggableEvent[] load(); void clear(); }
EventStore { public LoggableEvent[] load() throws IOException { StringWriter writer = new StringWriter(); Reader reader = configFile.getReader(); LoggableEvent[] result = new LoggableEvent[0]; if (reader == null) { return result; } try { IOUtils.copy(reader, writer); result = getGson().fromJson(writer.toString(), LoggableEvent[].class); if (result == null) { return new LoggableEvent[0]; } } finally { writer.close(); reader.close(); } return result; } EventStore(FileIO configFile); void save(LoggableEvent[] events); LoggableEvent[] load(); void clear();  }