Program: 114776
Project: 114776
Buggy source:
@BeforeClass(alwaysRun=true) public void setEnvironment() throws AutomationUtilException, XPathExpressionException, IOException, APIManagerIntegrationTestException, URISyntaxException, ResourceAdminServiceExceptionException {
  super.init(userMode);
  if (TestUserMode.SUPER_TENANT_ADMIN == userMode) {
    String carbonHome=System.getProperty(ServerConstants.CARBON_HOME);
    String apimConfigArtifactLocation=getAMResourceLocation() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str";
    serverConfigurationManager=new ServerConfigurationManager(gatewayContextWrk);
    String apimRepositoryConfigLocation=carbonHome + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ APIM_CONFIG_XML;
    File apimConfSourceFile=new File(apimConfigArtifactLocation);
    File apimConfTargetFile=new File(apimRepositoryConfigLocation);
    serverConfigurationManager.applyConfiguration(apimConfSourceFile,apimConfTargetFile);
  }
  String testArtifactPath=TestConfigurationProvider.getResourceLocation() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ APIMIntegrationConstants.BPMN_PROCESS_ENGINE_WEB_APP_NAME+ "String_Node_Str";
  String gatewayMgtSessionId=createSession(gatewayContextMgt);
  webAppAdminClient=new WebAppAdminClient(gatewayContextMgt.getContextUrls().getBackEndUrl(),gatewayMgtSessionId);
  webAppAdminClient.uploadWarFile(testArtifactPath);
  WebAppDeploymentUtil.isWebApplicationDeployed(gatewayContextMgt.getContextUrls().getBackEndUrl(),gatewayMgtSessionId,APIMIntegrationConstants.BPMN_PROCESS_ENGINE_WEB_APP_NAME);
  String url=getGatewayURLHttp();
  publisherURLHttp=getPublisherURLHttp();
  storeURLHttp=getStoreURLHttp();
  userName=user.getUserName();
  resourceAdminServiceClient=new ResourceAdminServiceClient(gatewayContextMgt.getContextUrls().getBackEndUrl(),createSession(gatewayContextMgt));
  originalWFExtentionsXML=resourceAdminServiceClient.getTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION);
  newWFExtentionsXML=readFile(getAMResourceLocation() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str");
  resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION,newWFExtentionsXML);
  APIStoreRestClient apiStore;
  String backendurl="String_Node_Str";
  String description="String_Node_Str";
  apiPublisher=new APIPublisherRestClient(publisherURLHttp);
  apiStore=new APIStoreRestClient(storeURLHttp);
  apiPublisher.login(userName,userName);
  APIRequest apiRequest=new APIRequest(apiName,apiVersion,new URL(backendurl));
  apiRequest.setDescription(description);
  apiRequest.setVersion(apiVersion);
  apiRequest.setProvider(userName);
  apiPublisher.addAPI(apiRequest);
}

Fixed version (ground truth):
@BeforeClass(alwaysRun=true) public void setEnvironment() throws AutomationUtilException, XPathExpressionException, IOException, APIManagerIntegrationTestException, URISyntaxException, ResourceAdminServiceExceptionException {
  super.init();
  if (TestUserMode.SUPER_TENANT_ADMIN == userMode) {
    String carbonHome=System.getProperty(ServerConstants.CARBON_HOME);
    String apimConfigArtifactLocation=getAMResourceLocation() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str";
    serverConfigurationManager=new ServerConfigurationManager(gatewayContextWrk);
    String apimRepositoryConfigLocation=carbonHome + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ APIM_CONFIG_XML;
    File apimConfSourceFile=new File(apimConfigArtifactLocation);
    File apimConfTargetFile=new File(apimRepositoryConfigLocation);
    serverConfigurationManager.applyConfiguration(apimConfSourceFile,apimConfTargetFile);
  }
  String testArtifactPath=TestConfigurationProvider.getResourceLocation() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ APIMIntegrationConstants.BPMN_PROCESS_ENGINE_WEB_APP_NAME+ "String_Node_Str";
  String gatewayMgtSessionId=createSession(gatewayContextMgt);
  webAppAdminClient=new WebAppAdminClient(gatewayContextMgt.getContextUrls().getBackEndUrl(),gatewayMgtSessionId);
  webAppAdminClient.uploadWarFile(testArtifactPath);
  WebAppDeploymentUtil.isWebApplicationDeployed(gatewayContextMgt.getContextUrls().getBackEndUrl(),gatewayMgtSessionId,APIMIntegrationConstants.BPMN_PROCESS_ENGINE_WEB_APP_NAME);
  String url=getGatewayURLHttp();
  publisherURLHttp=getPublisherURLHttp();
  storeURLHttp=getStoreURLHttp();
  userName=user.getUserName();
  resourceAdminServiceClient=new ResourceAdminServiceClient(gatewayContextMgt.getContextUrls().getBackEndUrl(),createSession(gatewayContextMgt));
  originalWFExtentionsXML=resourceAdminServiceClient.getTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION);
  newWFExtentionsXML=readFile(getAMResourceLocation() + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str");
  resourceAdminServiceClient.updateTextContent(DEFAULT_WF_EXTENTIONS_XML_REG_CONFIG_LOCATION,newWFExtentionsXML);
  APIStoreRestClient apiStore;
  String backendurl="String_Node_Str";
  String description="String_Node_Str";
  apiPublisher=new APIPublisherRestClient(publisherURLHttp);
  apiStore=new APIStoreRestClient(storeURLHttp);
  apiPublisher.login(userName,userName);
  APIRequest apiRequest=new APIRequest(apiName,apiVersion,new URL(backendurl));
  apiRequest.setDescription(description);
  apiRequest.setVersion(apiVersion);
  apiRequest.setProvider(userName);
  apiPublisher.addAPI(apiRequest);
}