Program: 114815
Project: 114815
Buggy source:
@Test(groups={"String_Node_Str"},description="String_Node_Str") public void testSetScopeToResourceTestCase() throws Exception {
  userManagementClient1=new UserManagementClient(keyManagerContext.getContextUrls().getBackEndUrl(),keyManagerContext.getContextTenant().getContextUser().getUserName(),keyManagerContext.getContextTenant().getContextUser().getPassword());
  userManagementClient1.addRole(SUBSCRIBER_ROLE,new String[]{},new String[]{"String_Node_Str","String_Node_Str"});
  String userJohn;
  String gatewayUrl;
  if (keyManagerContext.getContextTenant().getDomain().equals("String_Node_Str")) {
    gatewayUrl=gatewayUrlsWrk.getWebAppURLNhttp();
    userJohn=USER_JOHN;
  }
 else {
    gatewayUrl=gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str" + keyManagerContext.getContextTenant().getDomain()+ "String_Node_Str";
    userJohn=USER_JOHN + "String_Node_Str" + keyManagerContext.getContextTenant().getDomain();
  }
  userManagementClient1.addUser(USER_JOHN,"String_Node_Str",new String[]{SUBSCRIBER_ROLE},USER_JOHN);
  String apiContext="String_Node_Str";
  String tags="String_Node_Str";
  String url=getGatewayURLNhttp() + "String_Node_Str";
  String description="String_Node_Str";
  apiPublisher.login(user.getUserName(),user.getPassword());
  APIRequest apiRequest=new APIRequest(API_NAME,apiContext,new URL(url));
  apiRequest.setTags(tags);
  apiRequest.setDescription(description);
  apiRequest.setVersion(API_VERSION);
  apiRequest.setProvider(user.getUserName());
  apiPublisher.addAPI(apiRequest);
  APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(API_NAME,user.getUserName(),APILifeCycleState.PUBLISHED);
  apiPublisher.changeAPILifeCycleStatus(updateRequest);
  String modifiedResource="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  apiPublisher.updateResourceOfAPI(user.getUserName(),API_NAME,API_VERSION,modifiedResource);
  apiStore.login(user.getUserName(),user.getPassword());
  apiStore.addApplication(APP_NAME,APIMIntegrationConstants.APPLICATION_TIER.UNLIMITED,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(API_NAME,user.getUserName());
  subscriptionRequest.setApplicationName(APP_NAME);
  apiStore.subscribe(subscriptionRequest);
  APPKeyRequestGenerator generateAppKeyRequest=new APPKeyRequestGenerator(APP_NAME);
  String responseString=apiStore.generateApplicationKey(generateAppKeyRequest).getData();
  JSONObject jsonResponse=new JSONObject(responseString);
  String consumerKey=jsonResponse.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").getString("String_Node_Str");
  String consumerSecret=jsonResponse.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").getString("String_Node_Str");
  URL tokenEndpointURL=new URL(gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str");
  String accessToken;
  Map<String,String> requestHeaders;
  HttpResponse response;
  URL endPointURL;
  String requestBody;
  JSONObject accessTokenGenerationResponse;
  requestBody="String_Node_Str" + user.getUserName() + "String_Node_Str"+ user.getPassword()+ "String_Node_Str";
  waitForAPIDeploymentSync(user.getUserName(),API_NAME,API_VERSION,APIMIntegrationConstants.IS_API_EXISTS);
  response=apiStore.generateUserAccessKey(consumerKey,consumerSecret,requestBody,tokenEndpointURL);
  accessTokenGenerationResponse=new JSONObject(response.getData());
  accessToken=accessTokenGenerationResponse.getString("String_Node_Str");
  requestHeaders=new HashMap<String,String>();
  requestHeaders.put("String_Node_Str","String_Node_Str" + accessToken);
  Thread.sleep(5000);
  response=HttpRequestUtil.doGet(gatewayUrl + "String_Node_Str",requestHeaders);
  assertEquals(response.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  endPointURL=new URL(gatewayUrl + "String_Node_Str");
  response=HttpRequestUtil.doPost(endPointURL,"String_Node_Str",requestHeaders);
  assertEquals(response.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  requestBody="String_Node_Str" + userJohn + "String_Node_Str";
  accessTokenGenerationResponse=new JSONObject(apiStore.generateUserAccessKey(consumerKey,consumerSecret,requestBody,tokenEndpointURL).getData());
  accessToken=accessTokenGenerationResponse.getString("String_Node_Str");
  requestHeaders=new HashMap<String,String>();
  requestHeaders.put("String_Node_Str","String_Node_Str" + accessToken);
  response=HttpRequestUtil.doGet(gatewayUrl + "String_Node_Str",requestHeaders);
  assertEquals(response.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  try {
    endPointURL=new URL(gatewayUrl + "String_Node_Str");
    response=HttpRequestUtil.doPost(endPointURL,"String_Node_Str",requestHeaders);
    assertTrue(response.getResponseCode() != Response.Status.OK.getStatusCode(),"String_Node_Str");
  }
 catch (  Exception e) {
    log.error("String_Node_Str");
    assertTrue(true,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Test(groups={"String_Node_Str"},description="String_Node_Str") public void testSetScopeToResourceTestCase() throws Exception {
  userManagementClient1=new UserManagementClient(keyManagerContext.getContextUrls().getBackEndUrl(),keyManagerContext.getContextTenant().getContextUser().getUserName(),keyManagerContext.getContextTenant().getContextUser().getPassword());
  userManagementClient1.addRole(SUBSCRIBER_ROLE,new String[]{},new String[]{"String_Node_Str","String_Node_Str"});
  String userJohn;
  String gatewayUrl;
  if (keyManagerContext.getContextTenant().getDomain().equals("String_Node_Str")) {
    gatewayUrl=gatewayUrlsWrk.getWebAppURLNhttp();
    userJohn=USER_JOHN;
  }
 else {
    gatewayUrl=gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str" + keyManagerContext.getContextTenant().getDomain()+ "String_Node_Str";
    userJohn=USER_JOHN + "String_Node_Str" + keyManagerContext.getContextTenant().getDomain();
  }
  userManagementClient1.addUser(USER_JOHN,"String_Node_Str",new String[]{SUBSCRIBER_ROLE},USER_JOHN);
  String apiContext="String_Node_Str";
  String tags="String_Node_Str";
  String url=getGatewayURLNhttp() + "String_Node_Str";
  String description="String_Node_Str";
  apiPublisher.login(user.getUserName(),user.getPassword());
  APIRequest apiRequest=new APIRequest(API_NAME,apiContext,new URL(url));
  apiRequest.setTags(tags);
  apiRequest.setDescription(description);
  apiRequest.setVersion(API_VERSION);
  apiRequest.setProvider(user.getUserName());
  apiPublisher.addAPI(apiRequest);
  APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(API_NAME,user.getUserName(),APILifeCycleState.PUBLISHED);
  apiPublisher.changeAPILifeCycleStatus(updateRequest);
  String modifiedResource="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  apiPublisher.updateResourceOfAPI(user.getUserName(),API_NAME,API_VERSION,modifiedResource);
  apiStore.login(user.getUserName(),user.getPassword());
  apiStore.addApplication(APP_NAME,APIMIntegrationConstants.APPLICATION_TIER.UNLIMITED,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(API_NAME,user.getUserName());
  subscriptionRequest.setApplicationName(APP_NAME);
  apiStore.subscribe(subscriptionRequest);
  APPKeyRequestGenerator generateAppKeyRequest=new APPKeyRequestGenerator(APP_NAME);
  String responseString=apiStore.generateApplicationKey(generateAppKeyRequest).getData();
  JSONObject jsonResponse=new JSONObject(responseString);
  String consumerKey=jsonResponse.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").getString("String_Node_Str");
  String consumerSecret=jsonResponse.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").getString("String_Node_Str");
  URL tokenEndpointURL=new URL(gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str" + user.getUserDomain());
  String accessToken;
  Map<String,String> requestHeaders;
  HttpResponse response;
  URL endPointURL;
  String requestBody;
  JSONObject accessTokenGenerationResponse;
  requestBody="String_Node_Str" + user.getUserName() + "String_Node_Str"+ user.getPassword()+ "String_Node_Str";
  waitForAPIDeploymentSync(user.getUserName(),API_NAME,API_VERSION,APIMIntegrationConstants.IS_API_EXISTS);
  response=apiStore.generateUserAccessKey(consumerKey,consumerSecret,requestBody,tokenEndpointURL);
  accessTokenGenerationResponse=new JSONObject(response.getData());
  accessToken=accessTokenGenerationResponse.getString("String_Node_Str");
  requestHeaders=new HashMap<String,String>();
  requestHeaders.put("String_Node_Str","String_Node_Str" + accessToken);
  Thread.sleep(5000);
  response=HttpRequestUtil.doGet(gatewayUrl + "String_Node_Str",requestHeaders);
  assertEquals(response.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  endPointURL=new URL(gatewayUrl + "String_Node_Str");
  response=HttpRequestUtil.doPost(endPointURL,"String_Node_Str",requestHeaders);
  assertEquals(response.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  requestBody="String_Node_Str" + userJohn + "String_Node_Str";
  accessTokenGenerationResponse=new JSONObject(apiStore.generateUserAccessKey(consumerKey,consumerSecret,requestBody,tokenEndpointURL).getData());
  accessToken=accessTokenGenerationResponse.getString("String_Node_Str");
  requestHeaders=new HashMap<String,String>();
  requestHeaders.put("String_Node_Str","String_Node_Str" + accessToken);
  response=HttpRequestUtil.doGet(gatewayUrl + "String_Node_Str",requestHeaders);
  assertEquals(response.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  try {
    endPointURL=new URL(gatewayUrl + "String_Node_Str");
    response=HttpRequestUtil.doPost(endPointURL,"String_Node_Str",requestHeaders);
    assertTrue(response.getResponseCode() != Response.Status.OK.getStatusCode(),"String_Node_Str");
  }
 catch (  Exception e) {
    log.error("String_Node_Str");
    assertTrue(true,"String_Node_Str");
  }
}