@Test public void write_withFailureWriting_closesStream() throws IOException { doThrow(new IOException()).when(fileOutputStream).write(response.toByteArray()); protoStorageClient.write(response).subscribe(); verify(fileOutputStream).close(); }
public Completable write(AbstractMessageLite messageLite) { return Completable.fromCallable( () -> { synchronized (this) { try (FileOutputStream output = application.openFileOutput(fileName, MODE_PRIVATE)) { output.write(messageLite.toByteArray()); return messageLite; } } }); }
ProtoStorageClient { public Completable write(AbstractMessageLite messageLite) { return Completable.fromCallable( () -> { synchronized (this) { try (FileOutputStream output = application.openFileOutput(fileName, MODE_PRIVATE)) { output.write(messageLite.toByteArray()); return messageLite; } } }); } }
ProtoStorageClient { public Completable write(AbstractMessageLite messageLite) { return Completable.fromCallable( () -> { synchronized (this) { try (FileOutputStream output = application.openFileOutput(fileName, MODE_PRIVATE)) { output.write(messageLite.toByteArray()); return messageLite; } } }); } ProtoStorageClient(Application application, String fileName); }
ProtoStorageClient { public Completable write(AbstractMessageLite messageLite) { return Completable.fromCallable( () -> { synchronized (this) { try (FileOutputStream output = application.openFileOutput(fileName, MODE_PRIVATE)) { output.write(messageLite.toByteArray()); return messageLite; } } }); } ProtoStorageClient(Application application, String fileName); Completable write(AbstractMessageLite messageLite); Maybe<T> read(Parser<T> parser); }
ProtoStorageClient { public Completable write(AbstractMessageLite messageLite) { return Completable.fromCallable( () -> { synchronized (this) { try (FileOutputStream output = application.openFileOutput(fileName, MODE_PRIVATE)) { output.write(messageLite.toByteArray()); return messageLite; } } }); } ProtoStorageClient(Application application, String fileName); Completable write(AbstractMessageLite messageLite); Maybe<T> read(Parser<T> parser);  }