@Test public void uploadFileToCloudStorage() { when(mockCloudService.write( WriteRequest.newBuilder().setUserId(“testuser”).setFileType(“plain/text”)...)) .thenReturn(WriteResponse.newBuilder().setUploadId(“uploadId”).build()); CloudUploader cloudUploader = new CloudUploader(mockCloudService); Uri uri = cloudUploader.uploadFile(new File(“/path/to/foo.txt”)); // The uploaded file URI contains the user ID, file type, and upload ID. (Or does it?) assertThat(uri).isEqualTo(new Uri(“/testuser/text/uploadId.txt”));
@Test public void uploadFileToCloudStorage() { CloudUploader cloudUploader = new CloudUploader(cloudService); Uri uri = cloudUploader.uploadFile(”/path/to/foo.txt”); assertThat(cloudService.retrieveFile(uri)).isEqualTo(readContent(“/path/to/foo.txt")); }