Source:
public void developSampleAPI(JSONObject swaggerJson, String apiDeveloperUsername, String backendEndPoint, boolean publish, String storeVisibility) throws Exception { try { if (log.isDebugEnabled()) { log.debug("Creating api with below swagger definition : \n" + swaggerJson.toString()); } String apiName = swaggerJson.getJSONObject("info").get("title").toString(); String apiContext = swaggerJson.get("basePath").toString(); String apiVersion = swaggerJson.getJSONObject("info").get("version").toString(); APIRequest apiRequest = new APIRequest(apiName, apiContext, apiVersion); apiRequest.setVisibility(storeVisibility); apiRequest.setSwagger(URLEncoder.encode(swaggerJson.toString(), "UTF-8")); HttpResponse serviceResponse = designAPI(apiRequest); scenarioTestBase.verifyResponse(serviceResponse); assertTrue(serviceResponse.getData().contains(apiName), apiName + " is not visible in publisher"); APIImplementationBean apiImplementationBean = new APIImplementationBean(apiName, apiVersion, apiDeveloperUsername, new URL(backendEndPoint)); apiImplementationBean.setSwagger(URLEncoder.encode(swaggerJson.toString(), "UTF-8")); HttpResponse implementApiResponse = implementAPI(apiImplementationBean); scenarioTestBase.verifyResponse(implementApiResponse); HttpResponse getSwaggerResponse = getSwagger(apiName, apiVersion, apiDeveloperUsername); APIManageBean apiManageBean = new APIManageBean(apiName, apiVersion, apiDeveloperUsername, "https", "disabled", "resource_level", "Production and Sandbox", getSwaggerResponse.getData(), "Unlimited,Gold,Bronze"); HttpResponse apiManageResponse = manageAPI(apiManageBean); scenarioTestBase.verifyResponse(apiManageResponse); if (publish) { org.wso2.am.integration.test.utils.bean.APILifeCycleStateRequest updateLifeCycle = new org.wso2.am.integration.test.utils.bean.APILifeCycleStateRequest(apiName, apiDeveloperUsername, APILifeCycleState.PUBLISHED); HttpResponse apiPublishResponse = changeAPILifeCycleStatus(updateLifeCycle); scenarioTestBase.verifyResponse(apiPublishResponse); } } catch (MalformedURLException e) { throw new MalformedURLException("Error in creating URL from the backendpoint: " + backendEndPoint); } }

Target:
public void developSampleAPI(JSONObject swaggerJson, String apiDeveloperUsername, String backendEndPoint, boolean publish, String storeVisibility) throws Exception { try { if (log.isDebugEnabled()) { log.debug("Creating api with below swagger definition : \n" + swaggerJson.toString()); } String apiName = swaggerJson.getJSONObject("info").get("title").toString(); String apiContext = swaggerJson.get("basePath").toString(); String apiVersion = swaggerJson.getJSONObject("info").get("version").toString(); APIRequest apiRequest = new APIRequest(apiName, apiContext, apiVersion); apiRequest.setVisibility(storeVisibility); apiRequest.setSwagger(URLEncoder.encode(swaggerJson.toString(), "UTF-8")); HttpResponse serviceResponse = designAPI(apiRequest); scenarioTestBase.verifyResponse(serviceResponse); assertTrue(serviceResponse.getData().contains(apiName), apiName + " is not visible in publisher"); APIImplementationBean apiImplementationBean = new APIImplementationBean(apiName, apiVersion, apiDeveloperUsername, new URL(backendEndPoint)); apiImplementationBean.setSwagger(URLEncoder.encode(swaggerJson.toString(), "UTF-8")); HttpResponse implementApiResponse = implementAPI(apiImplementationBean); scenarioTestBase.verifyResponse(implementApiResponse); HttpResponse getSwaggerResponse = getSwagger(apiName, apiVersion, apiDeveloperUsername); APIManageBean apiManageBean = new APIManageBean(apiName, apiVersion, apiDeveloperUsername, "https", "disabled", "resource_level", "Production and Sandbox", getSwaggerResponse.getData(), "Unlimited,Gold,Bronze"); HttpResponse apiManageResponse = manageAPI(apiManageBean); scenarioTestBase.verifyResponse(apiManageResponse); if (publish) { org.wso2.am.integration.test.utils.bean.APILifeCycleStateRequest updateLifeCycle = new org.wso2.am.integration.test.utils.bean.APILifeCycleStateRequest(apiName, apiDeveloperUsername, APILifeCycleState.PUBLISHED); HttpResponse apiPublishResponse = changeAPILifeCycleStatus(updateLifeCycle); scenarioTestBase.verifyResponse(apiPublishResponse); } Thread.sleep(15000); } catch (MalformedURLException e) { throw new MalformedURLException("Error in creating URL from the backendpoint: " + backendEndPoint); } }