Program: 114817
Project: 114817
Buggy source:
@Test(groups={"String_Node_Str"},description="String_Node_Str") public void testRefreshTokenAPITestCase() throws Exception {
  String apiName="String_Node_Str";
  String apiContext="String_Node_Str";
  String tags="String_Node_Str";
  String description="String_Node_Str";
  String apiVersion="String_Node_Str";
  apiPublisher.login(publisherContext.getContextTenant().getContextUser().getUserName(),publisherContext.getContextTenant().getContextUser().getPassword());
  APIRequest apiRequest=new APIRequest(apiName,apiContext,new URL(backEndEndpointUrl));
  apiRequest.setTags(tags);
  apiRequest.setDescription(description);
  apiRequest.setVersion(apiVersion);
  apiRequest.setSandbox(backEndEndpointUrl);
  apiRequest.setProvider(user.getUserName());
  apiPublisher.addAPI(apiRequest);
  APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(apiName,user.getUserName(),APILifeCycleState.PUBLISHED);
  apiPublisher.changeAPILifeCycleStatus(updateRequest);
  apiStore.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  apiStore.addApplication(APPLICATION_NAME,APIMIntegrationConstants.APPLICATION_TIER.LARGE,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(apiName,storeContext.getContextTenant().getContextUser().getUserName());
  subscriptionRequest.setTier(APIMIntegrationConstants.API_TIER.GOLD);
  subscriptionRequest.setApplicationName(APPLICATION_NAME);
  apiStore.subscribe(subscriptionRequest);
  APPKeyRequestGenerator generateAppKeyRequest=new APPKeyRequestGenerator(APPLICATION_NAME);
  String responseString=apiStore.generateApplicationKey(generateAppKeyRequest).getData();
  JSONObject response=new JSONObject(responseString);
  String consumerKey=response.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").getString("String_Node_Str");
  String consumerSecret=response.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").getString("String_Node_Str");
  URL tokenEndpointURL=new URL(getGatewayURLNhttp() + "String_Node_Str");
  String subsAccessTokenPayload=APIMTestCaseUtils.getPayloadForPasswordGrant(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  JSONObject subsAccessTokenGenerationResponse=new JSONObject(apiStore.generateUserAccessKey(consumerKey,consumerSecret,subsAccessTokenPayload,tokenEndpointURL).getData());
  String subsRefreshToken=subsAccessTokenGenerationResponse.getString("String_Node_Str");
  assertFalse(StringUtils.isEmpty(subsRefreshToken),"String_Node_Str");
  String requestBody=APIMTestCaseUtils.getPayloadForPasswordGrant(user.getUserName(),user.getPassword());
  JSONObject accessTokenGenerationResponse=new JSONObject(apiStore.generateUserAccessKey(consumerKey,consumerSecret,requestBody,tokenEndpointURL).getData());
  String userAccessToken=accessTokenGenerationResponse.getString("String_Node_Str");
  String refreshToken=accessTokenGenerationResponse.getString("String_Node_Str");
  Map<String,String> requestHeaders=new HashMap<String,String>();
  requestHeaders.put("String_Node_Str","String_Node_Str" + userAccessToken);
  requestHeaders.put("String_Node_Str","String_Node_Str");
  String apiUrl=getAPIInvocationURLHttp("String_Node_Str");
  HttpResponse httpResponse=HttpRequestUtil.doGet(apiUrl,requestHeaders);
  Thread.sleep(5000);
  httpResponse=HttpRequestUtil.doGet(apiUrl,requestHeaders);
  assertEquals(httpResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  String getAccessTokenFromRefreshTokenRequestBody="String_Node_Str" + refreshToken + "String_Node_Str";
  accessTokenGenerationResponse=new JSONObject(apiStore.generateUserAccessKey(consumerKey,consumerSecret,getAccessTokenFromRefreshTokenRequestBody,tokenEndpointURL).getData());
  userAccessToken=accessTokenGenerationResponse.getString("String_Node_Str");
  requestHeaders=new HashMap<String,String>();
  requestHeaders.put("String_Node_Str","String_Node_Str" + userAccessToken);
  requestHeaders.put("String_Node_Str","String_Node_Str");
  httpResponse=HttpRequestUtil.doGet(apiUrl,requestHeaders);
  assertEquals(httpResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str"},description="String_Node_Str") public void testRefreshTokenAPITestCase() throws Exception {
  String apiName="String_Node_Str";
  String apiContext="String_Node_Str";
  String tags="String_Node_Str";
  String description="String_Node_Str";
  String apiVersion="String_Node_Str";
  apiPublisher.login(publisherContext.getContextTenant().getContextUser().getUserName(),publisherContext.getContextTenant().getContextUser().getPassword());
  APIRequest apiRequest=new APIRequest(apiName,apiContext,new URL(backEndEndpointUrl));
  apiRequest.setTags(tags);
  apiRequest.setDescription(description);
  apiRequest.setVersion(apiVersion);
  apiRequest.setSandbox(backEndEndpointUrl);
  apiRequest.setProvider(user.getUserName());
  apiPublisher.addAPI(apiRequest);
  APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(apiName,user.getUserName(),APILifeCycleState.PUBLISHED);
  apiPublisher.changeAPILifeCycleStatus(updateRequest);
  apiStore.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  apiStore.addApplication(APPLICATION_NAME,APIMIntegrationConstants.APPLICATION_TIER.LARGE,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(apiName,storeContext.getContextTenant().getContextUser().getUserName());
  subscriptionRequest.setTier(APIMIntegrationConstants.API_TIER.GOLD);
  subscriptionRequest.setApplicationName(APPLICATION_NAME);
  apiStore.subscribe(subscriptionRequest);
  APPKeyRequestGenerator generateAppKeyRequest=new APPKeyRequestGenerator(APPLICATION_NAME);
  String responseString=apiStore.generateApplicationKey(generateAppKeyRequest).getData();
  JSONObject response=new JSONObject(responseString);
  String consumerKey=response.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").getString("String_Node_Str");
  String consumerSecret=response.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").getString("String_Node_Str");
  URL tokenEndpointURL=new URL(getGatewayURLNhttp() + "String_Node_Str" + user.getUserDomain());
  String subsAccessTokenPayload=APIMTestCaseUtils.getPayloadForPasswordGrant(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  JSONObject subsAccessTokenGenerationResponse=new JSONObject(apiStore.generateUserAccessKey(consumerKey,consumerSecret,subsAccessTokenPayload,tokenEndpointURL).getData());
  String subsRefreshToken=subsAccessTokenGenerationResponse.getString("String_Node_Str");
  assertFalse(StringUtils.isEmpty(subsRefreshToken),"String_Node_Str");
  String requestBody=APIMTestCaseUtils.getPayloadForPasswordGrant(user.getUserName(),user.getPassword());
  JSONObject accessTokenGenerationResponse=new JSONObject(apiStore.generateUserAccessKey(consumerKey,consumerSecret,requestBody,tokenEndpointURL).getData());
  String userAccessToken=accessTokenGenerationResponse.getString("String_Node_Str");
  String refreshToken=accessTokenGenerationResponse.getString("String_Node_Str");
  Map<String,String> requestHeaders=new HashMap<String,String>();
  requestHeaders.put("String_Node_Str","String_Node_Str" + userAccessToken);
  requestHeaders.put("String_Node_Str","String_Node_Str");
  String apiUrl=getAPIInvocationURLHttp("String_Node_Str");
  HttpResponse httpResponse=HttpRequestUtil.doGet(apiUrl,requestHeaders);
  Thread.sleep(5000);
  httpResponse=HttpRequestUtil.doGet(apiUrl,requestHeaders);
  assertEquals(httpResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  String getAccessTokenFromRefreshTokenRequestBody="String_Node_Str" + refreshToken + "String_Node_Str";
  accessTokenGenerationResponse=new JSONObject(apiStore.generateUserAccessKey(consumerKey,consumerSecret,getAccessTokenFromRefreshTokenRequestBody,tokenEndpointURL).getData());
  userAccessToken=accessTokenGenerationResponse.getString("String_Node_Str");
  requestHeaders=new HashMap<String,String>();
  requestHeaders.put("String_Node_Str","String_Node_Str" + userAccessToken);
  requestHeaders.put("String_Node_Str","String_Node_Str");
  httpResponse=HttpRequestUtil.doGet(apiUrl,requestHeaders);
  assertEquals(httpResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
  assertTrue(httpResponse.getData().contains("String_Node_Str"),"String_Node_Str");
}