@Test public void deleteGoogleStorageFileTest() throws IOException { CloseableHttpResponse response = EasyMock.createNiceMock(CloseableHttpResponse.class); StatusLine status = EasyMock.createNiceMock(StatusLine.class); EasyMock.expect(response.getStatusLine()).andReturn(status).anyTimes(); EasyMock.expect(status.getStatusCode()).andReturn(HttpStatus.SC_NO_CONTENT).anyTimes(); EasyMock.replay(response, status); Capture<HttpDelete> capturedDel = Capture.newInstance(); EasyMock.expect(httpClient.execute(EasyMock.capture(capturedDel))).andReturn(response).anyTimes(); EasyMock.replay(httpClient); service.deleteGoogleStorageFile(httpClient, bucket, fileName, token); Assert.assertEquals("https: capturedDel.getValue().getURI().toString()); }
public void deleteGoogleStorageFile(CloseableHttpClient httpClient, String bucket, String objectName, String accessToken) throws IOException { CloseableHttpResponse response = null; try { HttpDelete httpdelete = new HttpDelete(GOOGLE_STORAGE_MEDIA + String.format("%s/o/%s", bucket, objectName)); logger.debug("Url to delete media file from Google Cloud Storage : {}", httpdelete.getURI().toString()); httpdelete.addHeader("Authorization", "Bearer " + accessToken); response = httpClient.execute(httpdelete); int code = response.getStatusLine().getStatusCode(); switch (code) { case HttpStatus.SC_NO_CONTENT: logger.info("Media file: {} deleted from Google storage", objectName); break; default: logger.warn("Unable to delete meida file: {} from Google Storage", objectName); break; } } catch (Exception e) { logger.warn("Unable to delete meida file: {} from Google Storage", objectName, e); } finally { try { httpClient.close(); if (response != null) { response.close(); } } catch (IOException e) { } } }
GoogleSpeechTranscriptionServiceStorage { public void deleteGoogleStorageFile(CloseableHttpClient httpClient, String bucket, String objectName, String accessToken) throws IOException { CloseableHttpResponse response = null; try { HttpDelete httpdelete = new HttpDelete(GOOGLE_STORAGE_MEDIA + String.format("%s/o/%s", bucket, objectName)); logger.debug("Url to delete media file from Google Cloud Storage : {}", httpdelete.getURI().toString()); httpdelete.addHeader("Authorization", "Bearer " + accessToken); response = httpClient.execute(httpdelete); int code = response.getStatusLine().getStatusCode(); switch (code) { case HttpStatus.SC_NO_CONTENT: logger.info("Media file: {} deleted from Google storage", objectName); break; default: logger.warn("Unable to delete meida file: {} from Google Storage", objectName); break; } } catch (Exception e) { logger.warn("Unable to delete meida file: {} from Google Storage", objectName, e); } finally { try { httpClient.close(); if (response != null) { response.close(); } } catch (IOException e) { } } } }
GoogleSpeechTranscriptionServiceStorage { public void deleteGoogleStorageFile(CloseableHttpClient httpClient, String bucket, String objectName, String accessToken) throws IOException { CloseableHttpResponse response = null; try { HttpDelete httpdelete = new HttpDelete(GOOGLE_STORAGE_MEDIA + String.format("%s/o/%s", bucket, objectName)); logger.debug("Url to delete media file from Google Cloud Storage : {}", httpdelete.getURI().toString()); httpdelete.addHeader("Authorization", "Bearer " + accessToken); response = httpClient.execute(httpdelete); int code = response.getStatusLine().getStatusCode(); switch (code) { case HttpStatus.SC_NO_CONTENT: logger.info("Media file: {} deleted from Google storage", objectName); break; default: logger.warn("Unable to delete meida file: {} from Google Storage", objectName); break; } } catch (Exception e) { logger.warn("Unable to delete meida file: {} from Google Storage", objectName, e); } finally { try { httpClient.close(); if (response != null) { response.close(); } } catch (IOException e) { } } }  }
GoogleSpeechTranscriptionServiceStorage { public void deleteGoogleStorageFile(CloseableHttpClient httpClient, String bucket, String objectName, String accessToken) throws IOException { CloseableHttpResponse response = null; try { HttpDelete httpdelete = new HttpDelete(GOOGLE_STORAGE_MEDIA + String.format("%s/o/%s", bucket, objectName)); logger.debug("Url to delete media file from Google Cloud Storage : {}", httpdelete.getURI().toString()); httpdelete.addHeader("Authorization", "Bearer " + accessToken); response = httpClient.execute(httpdelete); int code = response.getStatusLine().getStatusCode(); switch (code) { case HttpStatus.SC_NO_CONTENT: logger.info("Media file: {} deleted from Google storage", objectName); break; default: logger.warn("Unable to delete meida file: {} from Google Storage", objectName); break; } } catch (Exception e) { logger.warn("Unable to delete meida file: {} from Google Storage", objectName, e); } finally { try { httpClient.close(); if (response != null) { response.close(); } } catch (IOException e) { } } }  int startUpload(CloseableHttpClient httpClient, String bucket, String mpId,
          String fileExtension, File file, String byteSize, String contentType, String accessToken); void deleteGoogleStorageFile(CloseableHttpClient httpClient, String bucket, String objectName, String accessToken); }
GoogleSpeechTranscriptionServiceStorage { public void deleteGoogleStorageFile(CloseableHttpClient httpClient, String bucket, String objectName, String accessToken) throws IOException { CloseableHttpResponse response = null; try { HttpDelete httpdelete = new HttpDelete(GOOGLE_STORAGE_MEDIA + String.format("%s/o/%s", bucket, objectName)); logger.debug("Url to delete media file from Google Cloud Storage : {}", httpdelete.getURI().toString()); httpdelete.addHeader("Authorization", "Bearer " + accessToken); response = httpClient.execute(httpdelete); int code = response.getStatusLine().getStatusCode(); switch (code) { case HttpStatus.SC_NO_CONTENT: logger.info("Media file: {} deleted from Google storage", objectName); break; default: logger.warn("Unable to delete meida file: {} from Google Storage", objectName); break; } } catch (Exception e) { logger.warn("Unable to delete meida file: {} from Google Storage", objectName, e); } finally { try { httpClient.close(); if (response != null) { response.close(); } } catch (IOException e) { } } }  int startUpload(CloseableHttpClient httpClient, String bucket, String mpId,
          String fileExtension, File file, String byteSize, String contentType, String accessToken); void deleteGoogleStorageFile(CloseableHttpClient httpClient, String bucket, String objectName, String accessToken);  }