Program: 114824
Project: 114824
Buggy source:
private void addAndSubscribeToAPI(String apiName,String apiVersion,String apiContext,String description,String endpointURL,String tags,String providerName,User subscriber) throws APIManagerIntegrationTestException, MalformedURLException, XPathExpressionException {
  APIPublisherRestClient apiPublisher=new APIPublisherRestClient(publisherURLHttp);
  apiPublisher.login(user.getUserName(),user.getPassword());
  APIRequest apiRequest=new APIRequest(apiName,apiContext,new URL(endpointURL));
  apiRequest.setTags(tags);
  apiRequest.setDescription(description);
  apiRequest.setVersion(apiVersion);
  apiRequest.setVisibility("String_Node_Str");
  apiRequest.setProvider(providerName);
  apiPublisher.addAPI(apiRequest);
  APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(apiName,providerName,APILifeCycleState.PUBLISHED);
  apiPublisher.changeAPILifeCycleStatus(updateRequest);
  waitForAPIDeploymentSync(providerName,apiName,apiVersion,APIMIntegrationConstants.IS_API_EXISTS);
  APIStoreRestClient apiStoreRestClient=new APIStoreRestClient(storeURLHttp);
  apiStoreRestClient.login(subscriber.getUserName(),subscriber.getPassword());
  apiStoreRestClient.addApplication(applicationName,APIMIntegrationConstants.APPLICATION_TIER.LARGE,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(apiName,user.getUserName());
  subscriptionRequest.setApplicationName(applicationName);
  apiStoreRestClient.subscribe(subscriptionRequest);
}

Fixed version (ground truth):
private void addAndSubscribeToAPI(String apiName,String apiVersion,String apiContext,String description,String tags,String providerName,User subscriber) throws APIManagerIntegrationTestException, MalformedURLException, XPathExpressionException {
  String gatewaySessionCookie=createSession(gatewayContextMgt);
  loadSynapseConfigurationFromClasspath("String_Node_Str" + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str",gatewayContextMgt,gatewaySessionCookie);
  String endpointURL=getSuperTenantAPIInvocationURLHttp("String_Node_Str","String_Node_Str");
  APIPublisherRestClient apiPublisher=new APIPublisherRestClient(publisherURLHttp);
  apiPublisher.login(user.getUserName(),user.getPassword());
  APIRequest apiRequest=new APIRequest(apiName,apiContext,new URL(endpointURL));
  apiRequest.setTags(tags);
  apiRequest.setDescription(description);
  apiRequest.setVersion(apiVersion);
  apiRequest.setVisibility("String_Node_Str");
  apiRequest.setProvider(providerName);
  apiPublisher.addAPI(apiRequest);
  APILifeCycleStateRequest updateRequest=new APILifeCycleStateRequest(apiName,providerName,APILifeCycleState.PUBLISHED);
  apiPublisher.changeAPILifeCycleStatus(updateRequest);
  waitForAPIDeploymentSync(providerName,apiName,apiVersion,APIMIntegrationConstants.IS_API_EXISTS);
  APIStoreRestClient apiStoreRestClient=new APIStoreRestClient(storeURLHttp);
  apiStoreRestClient.login(subscriber.getUserName(),subscriber.getPassword());
  apiStoreRestClient.addApplication(applicationName,APIMIntegrationConstants.APPLICATION_TIER.LARGE,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(apiName,user.getUserName());
  subscriptionRequest.setApplicationName(applicationName);
  apiStoreRestClient.subscribe(subscriptionRequest);
}