Program: 114925
Project: 114925
Buggy source:
@BeforeClass(alwaysRun=true) public void setEnvironment() throws Exception {
  String fileFormat="String_Node_Str";
  super.init(userMode);
  log.info("String_Node_Str" + userMode);
  String path=TestConfigurationProvider.getResourceLocation() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator;
  String sourcePath=path + webApp + fileFormat;
  String sessionId=createSession(gatewayContextWrk);
  WebAppAdminClient webAppAdminClient=new WebAppAdminClient(gatewayContextWrk.getContextUrls().getBackEndUrl(),sessionId);
  webAppAdminClient.uploadWarFile(sourcePath);
  boolean isWebAppDeployed=WebAppDeploymentUtil.isWebApplicationDeployed(gatewayContextWrk.getContextUrls().getBackEndUrl(),sessionId,webApp);
  assertTrue(isWebAppDeployed,"String_Node_Str");
  String publisherURLHttp=publisherUrls.getWebAppURLHttp();
  String storeURLHttp=storeUrls.getWebAppURLHttp();
  apiPublisher=new APIPublisherRestClient(publisherURLHttp);
  apiStore=new APIStoreRestClient(storeURLHttp);
  apiPublisher.login(publisherContext.getContextTenant().getContextUser().getUserName(),publisherContext.getContextTenant().getContextUser().getPassword());
  apiStore.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  String uri="String_Node_Str";
  List<APIResourceBean> resourceBeanList=new ArrayList<APIResourceBean>();
  resourceBeanList.add(new APIResourceBean("String_Node_Str","String_Node_Str",tier,uri));
  String endpoint="String_Node_Str";
  String endpointUrl=gatewayUrlsWrk.getWebAppURLHttp() + webApp + endpoint;
  providerName=publisherContext.getContextTenant().getContextUser().getUserName();
  int count=1;
  for (int apiCount=0; apiCount < numberOfApis; apiCount++) {
    String tempApiName=apiName + count;
    String tempApiContext=apiContext + count;
    APICreationRequestBean apiCreationRequestBean=new APICreationRequestBean(tempApiName,tempApiContext,version,providerName,new URL(endpointUrl));
    apiCreationRequestBean.setEndpointType(endPointType);
    apiCreationRequestBean.setTier(tier);
    apiCreationRequestBean.setTags(tags);
    apiCreationRequestBean.setResourceBeanList(resourceBeanList);
    apiCreationRequestBean.setDescription(description);
    apiCreationRequestBean.setVisibility(visibility);
    HttpResponse apiCreateResponse=apiPublisher.addAPI(apiCreationRequestBean);
    assertEquals(apiCreateResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
    JSONObject createApiJsonObject=new JSONObject(apiCreateResponse.getData());
    assertEquals(createApiJsonObject.getBoolean("String_Node_Str"),false,"String_Node_Str");
    HttpResponse verifyApiResponse=apiPublisher.getApi(tempApiName,providerName,version);
    JSONObject verifyApiJsonObject=new JSONObject(verifyApiResponse.getData());
    assertFalse(verifyApiJsonObject.getBoolean("String_Node_Str"),"String_Node_Str");
    apiNameList.add(tempApiName);
    apiContextList.add(tempApiContext);
    APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(tempApiName,providerName,APILifeCycleState.PUBLISHED);
    HttpResponse statusUpdateResponse=apiPublisher.changeAPILifeCycleStatus(updateRequest);
    assertEquals(statusUpdateResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
    JSONObject statusUpdateJsonObject=new JSONObject(statusUpdateResponse.getData());
    assertFalse(statusUpdateJsonObject.getBoolean("String_Node_Str"),"String_Node_Str");
    count++;
  }
  if (gatewayContextWrk.getContextTenant().getDomain().equals(FrameworkConstants.SUPER_TENANT_DOMAIN_NAME)) {
    gatewayUrl=gatewayUrlsWrk.getWebAppURLNhttp();
  }
 else {
    gatewayUrl=gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str" + gatewayContextWrk.getContextTenant().getDomain()+ "String_Node_Str";
  }
  providerName=storeContext.getContextTenant().getContextUser().getUserName();
  HttpResponse createAppResponse=apiStore.addApplication(applicationName,tier,"String_Node_Str","String_Node_Str");
  assertEquals(createAppResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  JSONObject createAppJsonObject=new JSONObject(createAppResponse.getData());
  assertFalse(createAppJsonObject.getBoolean("String_Node_Str"),"String_Node_Str" + applicationName);
  for (int apiCount=0; apiCount < numberOfApis - 2; apiCount++) {
    accessUrl=gatewayUrl + apiContextList.get(apiCount) + "String_Node_Str"+ version+ "String_Node_Str";
    SubscriptionRequest apiSubscriptionRequest=new SubscriptionRequest(apiNameList.get(apiCount),version,providerName,applicationName,tier);
    HttpResponse subscriptionResponse=apiStore.subscribe(apiSubscriptionRequest);
    assertEquals(subscriptionResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
    JSONObject subscriptionResponseJsonObject=new JSONObject(subscriptionResponse.getData());
    assertFalse(subscriptionResponseJsonObject.getBoolean("String_Node_Str"),"String_Node_Str");
  }
  HttpResponse createNewAppResponse=apiStore.addApplication(newApplicationName,tier,"String_Node_Str","String_Node_Str");
  assertEquals(createAppResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  JSONObject createNewAppJsonObject=new JSONObject(createNewAppResponse.getData());
  assertFalse(createAppJsonObject.getBoolean("String_Node_Str"),"String_Node_Str" + applicationName);
  providerName=storeContext.getContextTenant().getContextUser().getUserName();
  for (int apiCount=numberOfApis - 2; apiCount < numberOfApis; apiCount++) {
    accessUrl=gatewayUrl + apiContextList.get(apiCount) + "String_Node_Str"+ version+ "String_Node_Str";
    SubscriptionRequest apiSubscriptionRequestDefaultApp=new SubscriptionRequest(apiNameList.get(apiCount),version,providerName,newApplicationName,tier);
    HttpResponse subscriptionResponseDefaultApp=apiStore.subscribe(apiSubscriptionRequestDefaultApp);
    assertEquals(subscriptionResponseDefaultApp.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
    JSONObject subscriptionResponseJsonObject=new JSONObject(subscriptionResponseDefaultApp.getData());
    assertFalse(subscriptionResponseJsonObject.getBoolean("String_Node_Str"),"String_Node_Str");
  }
}

Fixed version (ground truth):
@BeforeClass(alwaysRun=true) public void setEnvironment() throws Exception {
  String fileFormat="String_Node_Str";
  super.init(userMode);
  log.info("String_Node_Str" + userMode);
  String path=TestConfigurationProvider.getResourceLocation() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator;
  String sourcePath=path + webApp + fileFormat;
  String sessionId=createSession(gatewayContextWrk);
  WebAppAdminClient webAppAdminClient=new WebAppAdminClient(gatewayContextWrk.getContextUrls().getBackEndUrl(),sessionId);
  webAppAdminClient.uploadWarFile(sourcePath);
  boolean isWebAppDeployed=WebAppDeploymentUtil.isWebApplicationDeployed(gatewayContextWrk.getContextUrls().getBackEndUrl(),sessionId,webApp);
  assertTrue(isWebAppDeployed,"String_Node_Str");
  String publisherURLHttp=publisherUrls.getWebAppURLHttp();
  String storeURLHttp=storeUrls.getWebAppURLHttp();
  apiPublisher=new APIPublisherRestClient(publisherURLHttp);
  apiStore=new APIStoreRestClient(storeURLHttp);
  apiPublisher.login(publisherContext.getContextTenant().getContextUser().getUserName(),publisherContext.getContextTenant().getContextUser().getPassword());
  apiStore.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  String uri="String_Node_Str";
  List<APIResourceBean> resourceBeanList=new ArrayList<APIResourceBean>();
  resourceBeanList.add(new APIResourceBean("String_Node_Str","String_Node_Str",tier,uri));
  String endpoint="String_Node_Str";
  String endpointUrl=gatewayUrlsWrk.getWebAppURLHttp() + webApp + endpoint;
  providerName=publisherContext.getContextTenant().getContextUser().getUserName();
  int count=1;
  for (int apiCount=0; apiCount < numberOfApis; apiCount++) {
    String tempApiName=apiName + count;
    String tempApiContext=apiContext + count;
    APICreationRequestBean apiCreationRequestBean=new APICreationRequestBean(tempApiName,tempApiContext,version,providerName,new URL(endpointUrl));
    apiCreationRequestBean.setEndpointType(endPointType);
    apiCreationRequestBean.setTiersCollection(tier);
    apiCreationRequestBean.setTags(tags);
    apiCreationRequestBean.setResourceBeanList(resourceBeanList);
    apiCreationRequestBean.setDescription(description);
    apiCreationRequestBean.setVisibility(visibility);
    HttpResponse apiCreateResponse=apiPublisher.addAPI(apiCreationRequestBean);
    assertEquals(apiCreateResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
    JSONObject createApiJsonObject=new JSONObject(apiCreateResponse.getData());
    assertEquals(createApiJsonObject.getBoolean("String_Node_Str"),false,"String_Node_Str");
    HttpResponse verifyApiResponse=apiPublisher.getApi(tempApiName,providerName,version);
    JSONObject verifyApiJsonObject=new JSONObject(verifyApiResponse.getData());
    assertFalse(verifyApiJsonObject.getBoolean("String_Node_Str"),"String_Node_Str");
    apiNameList.add(tempApiName);
    apiContextList.add(tempApiContext);
    APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(tempApiName,providerName,APILifeCycleState.PUBLISHED);
    HttpResponse statusUpdateResponse=apiPublisher.changeAPILifeCycleStatus(updateRequest);
    assertEquals(statusUpdateResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
    JSONObject statusUpdateJsonObject=new JSONObject(statusUpdateResponse.getData());
    assertFalse(statusUpdateJsonObject.getBoolean("String_Node_Str"),"String_Node_Str");
    count++;
  }
  if (gatewayContextWrk.getContextTenant().getDomain().equals(FrameworkConstants.SUPER_TENANT_DOMAIN_NAME)) {
    gatewayUrl=gatewayUrlsWrk.getWebAppURLNhttp();
  }
 else {
    gatewayUrl=gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str" + gatewayContextWrk.getContextTenant().getDomain()+ "String_Node_Str";
  }
  providerName=storeContext.getContextTenant().getContextUser().getUserName();
  HttpResponse createAppResponse=apiStore.addApplication(applicationName,tier,"String_Node_Str","String_Node_Str");
  assertEquals(createAppResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  JSONObject createAppJsonObject=new JSONObject(createAppResponse.getData());
  assertFalse(createAppJsonObject.getBoolean("String_Node_Str"),"String_Node_Str" + applicationName);
  for (int apiCount=0; apiCount < numberOfApis - 2; apiCount++) {
    accessUrl=gatewayUrl + apiContextList.get(apiCount) + "String_Node_Str"+ version+ "String_Node_Str";
    SubscriptionRequest apiSubscriptionRequest=new SubscriptionRequest(apiNameList.get(apiCount),version,providerName,applicationName,tier);
    HttpResponse subscriptionResponse=apiStore.subscribe(apiSubscriptionRequest);
    assertEquals(subscriptionResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
    JSONObject subscriptionResponseJsonObject=new JSONObject(subscriptionResponse.getData());
    assertFalse(subscriptionResponseJsonObject.getBoolean("String_Node_Str"),"String_Node_Str");
  }
  HttpResponse createNewAppResponse=apiStore.addApplication(newApplicationName,tier,"String_Node_Str","String_Node_Str");
  assertEquals(createAppResponse.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
  JSONObject createNewAppJsonObject=new JSONObject(createNewAppResponse.getData());
  assertFalse(createAppJsonObject.getBoolean("String_Node_Str"),"String_Node_Str" + applicationName);
  providerName=storeContext.getContextTenant().getContextUser().getUserName();
  for (int apiCount=numberOfApis - 2; apiCount < numberOfApis; apiCount++) {
    accessUrl=gatewayUrl + apiContextList.get(apiCount) + "String_Node_Str"+ version+ "String_Node_Str";
    SubscriptionRequest apiSubscriptionRequestDefaultApp=new SubscriptionRequest(apiNameList.get(apiCount),version,providerName,newApplicationName,tier);
    HttpResponse subscriptionResponseDefaultApp=apiStore.subscribe(apiSubscriptionRequestDefaultApp);
    assertEquals(subscriptionResponseDefaultApp.getResponseCode(),Response.Status.OK.getStatusCode(),"String_Node_Str");
    JSONObject subscriptionResponseJsonObject=new JSONObject(subscriptionResponseDefaultApp.getData());
    assertFalse(subscriptionResponseJsonObject.getBoolean("String_Node_Str"),"String_Node_Str");
  }
}