@Test public void testMigrate() throws Exception { ObjectWriter writer = mapper.writerFor(OAuthMigrationResponse.class); OAuthMigrationResponse expectedOAuthMigrationResponse = new OAuthMigrationResponse(); expectedOAuthMigrationResponse.setAccessToken("eyJlbmMiOiJBMTI4Q0JDLUhTMjU2IiwiYWxnIjoiZGlyIn0..2T42Mngmoyk44UniOVFSgw.Hl3mqFm4Mq92Ux1m2UTIT0lKgNIF1QpM-NpedlZpxTKsZrI5EJ-amu8K24aM1GP0s3Ul3_ryyZiKnncs407v6c-2Z8mjwDJlYH_2iHs_MgF7epcmuZE8pjr_0ICx2ciYxDO1xA0IFwAT5db2D4ZRzkCNbpijXn6nuh0HJKLQyB4J53rVNLn-0yymQ1Jua9n9ZwmQ36uB1b1lSVTc16eE286h1fMKHcI6k9kGvv93kiWbPasntyRwy7ADj0ZX-Ct-syzoSrTuvChICKIgXc3N7zYfDZi_HM9viFNSOSnJ3-B_ysaZCbdIb8jgrCENwY3Pplp10hvpNIP3JCNl6GZktiuYW-o4shtkMQaWg-0OgnWdCI94Q52Ux32uun9ds8RpGWVTN3Ln9kzVg5lnNrNS9Ll6qm7yGLAmhZH9STgvL0eBPGXKLdg3Nku6cXGB26L8gN69S-r5k99d9xPuTy3H-qq8p2ebId9ys8nVlXshryFz48lBq0Tza5YZ3xqcyNoCs-GgEzZ2yS-v9mpK53BMh6ikggeAdPR4fBx7LTD1xL4I3ED8RrrzkC1mxdrTYoA6xNzTEt979PgSbVlCRj64F9Uft5GQ6ktdV0trWdPiSaLFb7EtjXzqYmduIdN_tEx2x8paefXRsp3X078klbDWb6kLTgamLlh_veOF7e3WXC9NQgIvFfQHfCIPDjooiaYcObolm0soE0j8yO0IoMZOEg.Z-nc_cRHkEA4V2qZJ_HnTg"); expectedOAuthMigrationResponse.setRefreshToken("AB11581303147XhI4cHvxvcnBo14kMgYIknAB6aRSVs2DO7Bv0"); expectedOAuthMigrationResponse.setExpiresIn(3600L); expectedOAuthMigrationResponse.setTokenType("bearer"); expectedOAuthMigrationResponse.setRealmId("123147196581394"); expectedOAuthMigrationResponse.setXRefreshTokenExpiresIn(8726400L); Response mockResponse = new Response( IOUtils.toInputStream(writer.writeValueAsString(expectedOAuthMigrationResponse), StandardCharsets.UTF_8), 200, intuit_tid); mockedHttpRequestClient.setMockResponse(mockResponse); OAuthMigrationResponse actualOAuthMigrationResponse = oAuth2MigrationClient.migrate(); assertEquals(expectedOAuthMigrationResponse.getAccessToken(), actualOAuthMigrationResponse.getAccessToken()); assertEquals(expectedOAuthMigrationResponse.getRefreshToken(), actualOAuthMigrationResponse.getRefreshToken()); assertEquals(expectedOAuthMigrationResponse.getExpiresIn(), actualOAuthMigrationResponse.getExpiresIn()); assertEquals(expectedOAuthMigrationResponse.getTokenType(), actualOAuthMigrationResponse.getTokenType()); assertEquals(expectedOAuthMigrationResponse.getRealmId(), actualOAuthMigrationResponse.getRealmId()); assertEquals(expectedOAuthMigrationResponse.getXRefreshTokenExpiresIn(), actualOAuthMigrationResponse.getXRefreshTokenExpiresIn()); }
public OAuthMigrationResponse migrate() throws ConnectionException { logger.debug("Enter OAuthMigrationClient::migrate"); try { HttpRequestClient client = new HttpRequestClient(oAuthMigrationRequest.getOauth2config().getProxyConfig()); String requestjson = new JSONObject().put("scope", getScopeValue(oAuthMigrationRequest.getScope())) .put("redirect_uri", getRedirectUrl() ) .put("client_id", oAuthMigrationRequest.getOauth2config().getClientId()) .put("client_secret",oAuthMigrationRequest.getOauth2config().getClientSecret()) .toString(); Request request = new Request.RequestBuilder(MethodType.GET, getMigrationAPIUrl(oAuthMigrationRequest.getEnvironment())) .requiresAuthentication(true) .postJson(requestjson) .build(); Response response = client.makeJsonRequest(request, oAuthMigrationRequest); logger.debug("Response Code : " + response.getStatusCode()); if (response.getStatusCode() == 200) { ObjectReader reader = mapper.readerFor(OAuthMigrationResponse.class); OAuthMigrationResponse oAuthMigrationResponse = reader.readValue(response.getContent()); oAuthMigrationResponse.setIntuit_tid(response.getIntuit_tid()); return oAuthMigrationResponse; } else { logger.debug("failed calling migrate API"); throw new ConnectionException("failed calling migrate API", response.getStatusCode() + ""); } } catch (Exception ex) { logger.error("Exception while calling migrate", ex); throw new ConnectionException(ex.getMessage(), ex); } }
OAuthMigrationClient { public OAuthMigrationResponse migrate() throws ConnectionException { logger.debug("Enter OAuthMigrationClient::migrate"); try { HttpRequestClient client = new HttpRequestClient(oAuthMigrationRequest.getOauth2config().getProxyConfig()); String requestjson = new JSONObject().put("scope", getScopeValue(oAuthMigrationRequest.getScope())) .put("redirect_uri", getRedirectUrl() ) .put("client_id", oAuthMigrationRequest.getOauth2config().getClientId()) .put("client_secret",oAuthMigrationRequest.getOauth2config().getClientSecret()) .toString(); Request request = new Request.RequestBuilder(MethodType.GET, getMigrationAPIUrl(oAuthMigrationRequest.getEnvironment())) .requiresAuthentication(true) .postJson(requestjson) .build(); Response response = client.makeJsonRequest(request, oAuthMigrationRequest); logger.debug("Response Code : " + response.getStatusCode()); if (response.getStatusCode() == 200) { ObjectReader reader = mapper.readerFor(OAuthMigrationResponse.class); OAuthMigrationResponse oAuthMigrationResponse = reader.readValue(response.getContent()); oAuthMigrationResponse.setIntuit_tid(response.getIntuit_tid()); return oAuthMigrationResponse; } else { logger.debug("failed calling migrate API"); throw new ConnectionException("failed calling migrate API", response.getStatusCode() + ""); } } catch (Exception ex) { logger.error("Exception while calling migrate", ex); throw new ConnectionException(ex.getMessage(), ex); } } }
OAuthMigrationClient { public OAuthMigrationResponse migrate() throws ConnectionException { logger.debug("Enter OAuthMigrationClient::migrate"); try { HttpRequestClient client = new HttpRequestClient(oAuthMigrationRequest.getOauth2config().getProxyConfig()); String requestjson = new JSONObject().put("scope", getScopeValue(oAuthMigrationRequest.getScope())) .put("redirect_uri", getRedirectUrl() ) .put("client_id", oAuthMigrationRequest.getOauth2config().getClientId()) .put("client_secret",oAuthMigrationRequest.getOauth2config().getClientSecret()) .toString(); Request request = new Request.RequestBuilder(MethodType.GET, getMigrationAPIUrl(oAuthMigrationRequest.getEnvironment())) .requiresAuthentication(true) .postJson(requestjson) .build(); Response response = client.makeJsonRequest(request, oAuthMigrationRequest); logger.debug("Response Code : " + response.getStatusCode()); if (response.getStatusCode() == 200) { ObjectReader reader = mapper.readerFor(OAuthMigrationResponse.class); OAuthMigrationResponse oAuthMigrationResponse = reader.readValue(response.getContent()); oAuthMigrationResponse.setIntuit_tid(response.getIntuit_tid()); return oAuthMigrationResponse; } else { logger.debug("failed calling migrate API"); throw new ConnectionException("failed calling migrate API", response.getStatusCode() + ""); } } catch (Exception ex) { logger.error("Exception while calling migrate", ex); throw new ConnectionException(ex.getMessage(), ex); } } OAuthMigrationClient(OAuthMigrationRequest request); protected  OAuthMigrationClient(); }
OAuthMigrationClient { public OAuthMigrationResponse migrate() throws ConnectionException { logger.debug("Enter OAuthMigrationClient::migrate"); try { HttpRequestClient client = new HttpRequestClient(oAuthMigrationRequest.getOauth2config().getProxyConfig()); String requestjson = new JSONObject().put("scope", getScopeValue(oAuthMigrationRequest.getScope())) .put("redirect_uri", getRedirectUrl() ) .put("client_id", oAuthMigrationRequest.getOauth2config().getClientId()) .put("client_secret",oAuthMigrationRequest.getOauth2config().getClientSecret()) .toString(); Request request = new Request.RequestBuilder(MethodType.GET, getMigrationAPIUrl(oAuthMigrationRequest.getEnvironment())) .requiresAuthentication(true) .postJson(requestjson) .build(); Response response = client.makeJsonRequest(request, oAuthMigrationRequest); logger.debug("Response Code : " + response.getStatusCode()); if (response.getStatusCode() == 200) { ObjectReader reader = mapper.readerFor(OAuthMigrationResponse.class); OAuthMigrationResponse oAuthMigrationResponse = reader.readValue(response.getContent()); oAuthMigrationResponse.setIntuit_tid(response.getIntuit_tid()); return oAuthMigrationResponse; } else { logger.debug("failed calling migrate API"); throw new ConnectionException("failed calling migrate API", response.getStatusCode() + ""); } } catch (Exception ex) { logger.error("Exception while calling migrate", ex); throw new ConnectionException(ex.getMessage(), ex); } } OAuthMigrationClient(OAuthMigrationRequest request); protected  OAuthMigrationClient(); OAuthMigrationResponse migrate(); String getScopeValue(Scope scope); String getRedirectUrl(); }
OAuthMigrationClient { public OAuthMigrationResponse migrate() throws ConnectionException { logger.debug("Enter OAuthMigrationClient::migrate"); try { HttpRequestClient client = new HttpRequestClient(oAuthMigrationRequest.getOauth2config().getProxyConfig()); String requestjson = new JSONObject().put("scope", getScopeValue(oAuthMigrationRequest.getScope())) .put("redirect_uri", getRedirectUrl() ) .put("client_id", oAuthMigrationRequest.getOauth2config().getClientId()) .put("client_secret",oAuthMigrationRequest.getOauth2config().getClientSecret()) .toString(); Request request = new Request.RequestBuilder(MethodType.GET, getMigrationAPIUrl(oAuthMigrationRequest.getEnvironment())) .requiresAuthentication(true) .postJson(requestjson) .build(); Response response = client.makeJsonRequest(request, oAuthMigrationRequest); logger.debug("Response Code : " + response.getStatusCode()); if (response.getStatusCode() == 200) { ObjectReader reader = mapper.readerFor(OAuthMigrationResponse.class); OAuthMigrationResponse oAuthMigrationResponse = reader.readValue(response.getContent()); oAuthMigrationResponse.setIntuit_tid(response.getIntuit_tid()); return oAuthMigrationResponse; } else { logger.debug("failed calling migrate API"); throw new ConnectionException("failed calling migrate API", response.getStatusCode() + ""); } } catch (Exception ex) { logger.error("Exception while calling migrate", ex); throw new ConnectionException(ex.getMessage(), ex); } } OAuthMigrationClient(OAuthMigrationRequest request); protected  OAuthMigrationClient(); OAuthMigrationResponse migrate(); String getScopeValue(Scope scope); String getRedirectUrl();  }