Program: 114926
Project: 114926
Buggy source:
@Test(groups={"String_Node_Str"},description="String_Node_Str") public void testSetScopeToResourceTestCase() throws Exception {
  userManagementClient=new UserManagementClient(keyManagerContext.getContextUrls().getBackEndUrl(),keyManagerContext.getContextTenant().getContextUser().getUserName(),keyManagerContext.getContextTenant().getContextUser().getPassword());
  userManagementClient.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();
  }
  userManagementClient.addUser(USER_JOHN,"String_Node_Str",new String[]{SUBSCRIBER_ROLE},USER_JOHN);
  String apiContext="String_Node_Str";
  String tags="String_Node_Str";
  String url="String_Node_Str";
  String description="String_Node_Str";
  apiPublisher.login(publisherContext.getContextTenant().getContextUser().getUserName(),publisherContext.getContextTenant().getContextUser().getPassword());
  APIRequest apiRequest=new APIRequest(API_NAME,apiContext,new URL(url));
  apiRequest.setTags(tags);
  apiRequest.setDescription(description);
  apiRequest.setVersion(API_VERSION);
  apiRequest.setProvider(apiProvider);
  apiPublisher.addAPI(apiRequest);
  APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(API_NAME,apiProvider,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(apiProvider,API_NAME,API_VERSION,modifiedResource);
  apiStore.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  apiStore.addApplication(APP_NAME,"String_Node_Str","String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(API_NAME,apiProvider);
  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" + storeContext.getContextTenant().getContextUser().getUserName() + "String_Node_Str"+ storeContext.getContextTenant().getContextUser().getPassword()+ "String_Node_Str";
  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);
  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 {
  userManagementClient=new UserManagementClient(keyManagerContext.getContextUrls().getBackEndUrl(),keyManagerContext.getContextTenant().getContextUser().getUserName(),keyManagerContext.getContextTenant().getContextUser().getPassword());
  userManagementClient.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();
  }
  userManagementClient.addUser(USER_JOHN,"String_Node_Str",new String[]{SUBSCRIBER_ROLE},USER_JOHN);
  String apiContext="String_Node_Str";
  String tags="String_Node_Str";
  String url="String_Node_Str";
  String description="String_Node_Str";
  apiPublisher.login(publisherContext.getContextTenant().getContextUser().getUserName(),publisherContext.getContextTenant().getContextUser().getPassword());
  APIRequest apiRequest=new APIRequest(API_NAME,apiContext,new URL(url));
  apiRequest.setTags(tags);
  apiRequest.setDescription(description);
  apiRequest.setVersion(API_VERSION);
  apiRequest.setProvider(apiProvider);
  apiPublisher.addAPI(apiRequest);
  APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(API_NAME,apiProvider,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(apiProvider,API_NAME,API_VERSION,modifiedResource);
  apiStore.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  apiStore.addApplication(APP_NAME,"String_Node_Str","String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(API_NAME,apiProvider);
  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" + storeContext.getContextTenant().getContextUser().getUserName() + "String_Node_Str"+ storeContext.getContextTenant().getContextUser().getPassword()+ "String_Node_Str";
  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);
  response=HttpRequestUtil.doGet(gatewayUrl + "String_Node_Str",requestHeaders);
  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");
  }
}