FirebaseChannel { public HttpResponse firebasePut(String path, Object object) throws IOException { GoogleCredentials credential = GoogleCredentials.getApplicationDefault().createScoped(FIREBASE_SCOPES); HttpRequestFactory requestFactory = httpTransport.createRequestFactory(new HttpCredentialsAdapter(credential)); String json = new Gson().toJson(object); GenericUrl url = new GenericUrl(path); return requestFactory .buildPutRequest(url, new ByteArrayContent("application/json", json.getBytes())) .execute(); } private  FirebaseChannel(); static FirebaseChannel getInstance(); void sendFirebaseMessage(String channelKey, Game game); String createFirebaseToken(Game game, String userId); HttpResponse firebasePut(String path, Object object); HttpResponse firebasePatch(String path, Object object); HttpResponse firebasePost(String path, Object object); HttpResponse firebaseGet(String path); HttpResponse firebaseDelete(String path);  }
@Test public void firebasePut() throws Exception { MockHttpTransport mockHttpTransport = spy( new MockHttpTransport() { @Override public LowLevelHttpRequest buildRequest(String method, String url) throws IOException { return new MockLowLevelHttpRequest() { @Override public LowLevelHttpResponse execute() throws IOException { MockLowLevelHttpResponse response = new MockLowLevelHttpResponse(); response.setStatusCode(200); return response; } }; } }); FirebaseChannel.getInstance().httpTransport = mockHttpTransport; Game game = new Game(); firebaseChannel.firebasePut(FIREBASE_DB_URL + "/my/path", game); verify(mockHttpTransport, times(1)).buildRequest("PUT", FIREBASE_DB_URL + "/my/path"); }