private ApiClient createUserApiClient() { ApiClient apiClient = new ApiClient(); apiClient.setBasePath(finapiConnectionUrl); return apiClient; }
private ApiClient createApiClient() { ApiClient apiClient = new ApiClient(); apiClient.setBasePath(finapiConnectionUrl); apiClient.setAccessToken(clientToken != null ? clientToken.getAccessToken() : null); return apiClient; }
@Test(expected = ApiException.class) public void refreshTokenTestFailsIfRefreshTokenIsInvalid() throws ApiException { DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret); String refreshToken = "1232131"; api.refreshAccessToken(refreshToken); }
@Test(expected = ApiException.class) public void authorizeTestFailsIfCodeIsNull() throws ApiException { DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret); String code = null; api.authorize(code, redirectUri); }
@Test(expected = ApiException.class) public void authorizeTestFailsIfCodeIsInvalid() throws ApiException { DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret); String code = "12321321"; api.authorize(code, redirectUri); }
@Test(expected = ApiException.class) public void getAuthUrlTestFailsIfRedirectUriIsNull() throws ApiException { String redirectUri = null; DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret); api.getAuthUrl(redirectUri, Configuration.AuthUrls.MLA); StringBuilder sb = new StringBuilder(); sb.append(Configuration.AuthUrls.MLA.getValue()); sb.append("/authorization?response_type=code&client_id="); sb.append(clientId); sb.append("&redirect_uri="); try { sb.append(URLEncoder.encode(redirectUri, "UTF-8")); } catch (UnsupportedEncodingException e) { sb.append(redirectUri); } }
/** * Returns auth Url */ @Test public void getAuthUrlTest() throws ApiException { DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret); String response = api.getAuthUrl(redirectUri, Configuration.AuthUrls.MLA); StringBuilder sb = new StringBuilder(); sb.append(Configuration.AuthUrls.MLA.getValue()); sb.append("/authorization?response_type=code&client_id="); sb.append(clientId); sb.append("&redirect_uri="); try { sb.append(URLEncoder.encode(redirectUri, "UTF-8")); } catch (UnsupportedEncodingException e) { sb.append(redirectUri); } assertNotNull(response); assertEquals(sb.toString(), response); }
/** * Returns access token. * * @throws ApiException if the Api call fails */ @Test public void authorizeTest() throws ApiException { DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret); String code = ""; AccessToken response = api.authorize(code, redirectUri); assertNotNull(response); assertNotNull(response.getAccess_token()); assertEquals("bearer", response.getToken_type()); }
/** * Returns refresh token * * @throws ApiException if the Api call fails */ @Test public void refreshTokenTest() throws ApiException { DefaultApi api = new DefaultApi(new ApiClient(), clientId, clientSecret); String refreshToken = ""; RefreshToken response = api.refreshAccessToken(refreshToken); assertNotNull(response); assertNotNull(response.getAccess_token()); assertEquals("bearer", response.getToken_type()); }