Source:
public void createApiWithValidOAS2DocumentAsJSONFile() throws Exception { swagger_file = new File(resourceLocation + File.separator + "swaggerFiles/OAS2Document.json"); apiRequest = new APIRequest(import_definition_file, swagger_file.getAbsolutePath(), "", type); HttpResponse designResponse1 = apiPublisher.designAPIWithOAS(apiRequest); Assert.assertTrue(designResponse1.getData().contains("imported")); String payload = readFromFile(swagger_file.getAbsolutePath()); JSONObject json = new JSONObject(payload); apiName = json.getJSONObject("info").get("title").toString(); apiContext = json.get("basePath").toString(); apiVersion = json.getJSONObject("info").get("version").toString(); apiRequest = new APIRequest(apiName, apiContext, apiVersion); apiRequest.setSwagger(payload); HttpResponse designResponse2 = apiPublisher.designAPI(apiRequest); verifyResponse(designResponse2); String name = (new JSONObject(designResponse2.getData())).getJSONObject("data").get("apiName").toString(); String version = (new JSONObject(designResponse2.getData())).getJSONObject("data").get("version").toString(); Assert.assertEquals(name, apiName, "Api name was not imported correctly"); Assert.assertEquals(version, apiVersion, "Api version was not imported correctly"); HttpResponse getResponse = apiPublisher.getAPI(apiName, "admin", apiVersion); String resource = (new JSONObject(getResponse.getData())).getJSONObject("api").get("resources").toString(); Assert.assertTrue(resource != "null", "API resource was not imported correctly"); assertGETResource(((JSONArray)((JSONArray)(new JSONObject(getResponse.getData())).getJSONObject("api"). get("templates")).get(0))); }

Target:
public void createApiWithValidOAS2DocumentAsJSONFile() throws Exception { swagger_file = new File(resourceLocation + File.separator + "swaggerFiles/OAS2Document.json"); apiRequest = new APIRequest(import_definition_file, swagger_file.getAbsolutePath(), "", type); HttpResponse designResponse1 = apiPublisher.designAPIWithOAS(apiRequest); Assert.assertTrue(designResponse1.getData().contains("imported")); String payload = readFromFile(swagger_file.getAbsolutePath()); JSONObject json = new JSONObject(payload); apiName = json.getJSONObject("info").get("title").toString(); apiContext = json.get("basePath").toString(); apiVersion = json.getJSONObject("info").get("version").toString(); apiRequest = new APIRequest(apiName, apiContext, apiVersion); apiRequest.setSwagger(payload); HttpResponse designResponse2 = apiPublisher.designAPI(apiRequest); verifyResponse(designResponse2); String name = (new JSONObject(designResponse2.getData())).getJSONObject("data").get("apiName").toString(); String version = (new JSONObject(designResponse2.getData())).getJSONObject("data").get("version").toString(); Assert.assertEquals(name, apiName, "Api name was not imported correctly"); Assert.assertEquals(version, apiVersion, "Api version was not imported correctly"); HttpResponse getResponse = apiPublisher.getAPI(apiName, "admin", apiVersion); String resource = (new JSONObject(getResponse.getData())).getJSONObject("api").get("resources").toString(); Assert.assertTrue(resource != "null", "API resource was not imported correctly"); assertGETResource(((JSONArray) (new JSONObject(getResponse.getData())).getJSONObject("api"). get("templates")).get(0)); }