### Question:
MongoDBManager implements DBManager { protected String constructDbId(Object object) { Gson gson = new Gson(); String json = gson.toJson(object); JsonParser parser = new JsonParser(); JsonObject jsonObj= parser.parse(json).getAsJsonObject(); if(jsonObj.has("id")) { String id = jsonObj.get("id").getAsString(); jsonObj.remove("id"); jsonObj.addProperty(ID_NAME, id); } return jsonObj.toString(); } MongoDBManager(); @Override void storeClientCredentials(ClientCredentials clientCreds); @SuppressWarnings("unchecked") @Override ClientCredentials findClientCredentials(String clientId); @Override void storeAuthCode(AuthCode authCode); @SuppressWarnings("unchecked") @Override AuthCode findAuthCode(String authCode, String redirectUri); @Override void storeAccessToken(AccessToken accessToken); @SuppressWarnings("unchecked") @Override AccessToken findAccessToken(String accessToken); @SuppressWarnings("unchecked") @Override AccessToken findAccessTokenByRefreshToken(String refreshToken, String clientId); @Override void updateAccessTokenValidStatus(String accessToken, boolean valid); @Override void updateAuthCodeValidStatus(String authCode, boolean valid); @Override boolean validClient(String clientId, String clientSecret); @Override @SuppressWarnings("unchecked") boolean storeScope(Scope scope); @Override @SuppressWarnings("unchecked") List<Scope> getAllScopes(); @Override @SuppressWarnings("unchecked") Scope findScope(String scopeName); @Override boolean updateClientApp(String clientId, String scope, String description, Integer status, Map<String, String> applicationDetails); @Override @SuppressWarnings("unchecked") List<ApplicationInfo> getAllApplications(); @Override boolean deleteScope(String scopeName); @Override @SuppressWarnings("unchecked") List<AccessToken> getAccessTokenByUserIdAndClientApp(String userId, String clientId); @Override void removeUserTokens(String userId); @Override void removeAccessToken(String accessToken);  }### Answer:
@Test public void when_constructDbId_return_whole_object_as_json() throws Exception { ClientCredentials clientCreds = new ClientCredentials(); clientCreds.setName("test_client"); clientCreds.setDescr("descr"); String json = dbManager.constructDbId(clientCreds); assertTrue(json.contains("descr")); }
@Test public void when_constructDbId_replace_id_with_undescored_id() throws Exception { ClientCredentials clientCreds = new ClientCredentials(); clientCreds.setName("test_client"); clientCreds.setDescr("descr"); String json = dbManager.constructDbId(clientCreds); assertTrue(json.contains("_id")); }