@Test public void test_data_can_be_extracted() throws AdapterException { String data = "{\"access_token\":\"12345MeUdnk6O_-EEp93I1e8rsdlHvBg\",\"expires_in\":86400,\"token_type\":\"Bearer\"}{Cache-Control=[no-store, no-cache, max-age=0, private], Pragma=[no-cache], Content-Length=[1786], Content-Type=[application/json; charset=utf-8], Server=[Microsoft-IIS/8.5], X-AspNet-Version=[4.0.30319], X-Powered-By=[ASP.NET], Date=[Tue, 25 Sep 2018 13:29:26 GMT]}"; CheckmarxOAuthData result = supportToTest.extractFromJson(JSONAdapterSupport.FOR_UNKNOWN_ADAPTER,data); assertNotNull(result); assertEquals("Bearer",result.getTokenType()); assertEquals("12345MeUdnk6O_-EEp93I1e8rsdlHvBg",result.getAccessToken()); assertEquals(86400,result.getExpiresIn()); }
CheckmarxOAuthData extractFromJson(JSONAdapterSupport support, String json) throws AdapterException { CheckmarxOAuthData data = new CheckmarxOAuthData(); Access rootNode = support.fetchRootNode(json); data.accessToken=rootNode.fetch("access_token").asText(); data.tokenType=rootNode.fetch("token_type").asText(); data.expiresIn=rootNode.fetch("expires_in").asLong(); return data; }
CheckmarxOAuthSupport { CheckmarxOAuthData extractFromJson(JSONAdapterSupport support, String json) throws AdapterException { CheckmarxOAuthData data = new CheckmarxOAuthData(); Access rootNode = support.fetchRootNode(json); data.accessToken=rootNode.fetch("access_token").asText(); data.tokenType=rootNode.fetch("token_type").asText(); data.expiresIn=rootNode.fetch("expires_in").asLong(); return data; } }
CheckmarxOAuthSupport { CheckmarxOAuthData extractFromJson(JSONAdapterSupport support, String json) throws AdapterException { CheckmarxOAuthData data = new CheckmarxOAuthData(); Access rootNode = support.fetchRootNode(json); data.accessToken=rootNode.fetch("access_token").asText(); data.tokenType=rootNode.fetch("token_type").asText(); data.expiresIn=rootNode.fetch("expires_in").asLong(); return data; }  }
CheckmarxOAuthSupport { CheckmarxOAuthData extractFromJson(JSONAdapterSupport support, String json) throws AdapterException { CheckmarxOAuthData data = new CheckmarxOAuthData(); Access rootNode = support.fetchRootNode(json); data.accessToken=rootNode.fetch("access_token").asText(); data.tokenType=rootNode.fetch("token_type").asText(); data.expiresIn=rootNode.fetch("expires_in").asLong(); return data; }  void loginAndGetOAuthToken(CheckmarxContext context); }
CheckmarxOAuthSupport { CheckmarxOAuthData extractFromJson(JSONAdapterSupport support, String json) throws AdapterException { CheckmarxOAuthData data = new CheckmarxOAuthData(); Access rootNode = support.fetchRootNode(json); data.accessToken=rootNode.fetch("access_token").asText(); data.tokenType=rootNode.fetch("token_type").asText(); data.expiresIn=rootNode.fetch("expires_in").asLong(); return data; }  void loginAndGetOAuthToken(CheckmarxContext context);  }