Source:
public void setDefaultVersionToNewcopy() throws Exception { String gatewayUrl; if (gatewayContextWrk.getContextTenant().getDomain().equals("carbon.super")) { gatewayUrl = gatewayUrlsWrk.getWebAppURLNhttp(); } else { gatewayUrl = gatewayUrlsWrk.getWebAppURLNhttp() + "t/" + gatewayContextWrk.getContextTenant().getDomain() + "/"; } String endpointUrl = gatewayUrl + "jaxrs_basic/services/customers/customerservice"; providerName = publisherContext.getContextTenant().getContextUser().getUserName(); APIRequest apiRequest = new APIRequest(API_NAME, apiContext, new URL(endpointUrl)); apiRequest.setTags(TAGS); apiRequest.setDescription(description); apiRequest.setVersion(version); apiRequest.setProvider(providerName); apiRequest.setEndpointType(endPointType); apiRequest.setResourceMethodAuthType(resourceMethodAuthType); apiRequest.setTier(tier); apiRequest.setResourceMethodThrottlingTier(resTier); apiRequest.setUriTemplate(uriTemplate); apiRequest.setVisibility(visibility); HttpResponse serviceResponse = restAPIPublisher.addAPI(apiRequest); apiId = serviceResponse.getData(); assertEquals(serviceResponse.getResponseCode(), Response.Status.CREATED.getStatusCode(), "Invalid Response Code"); HttpResponse apiCopyResponse = restAPIPublisher.copyAPI(newVersion, apiId, true); defaultApiId = apiCopyResponse.getData(); assertEquals(apiCopyResponse.getResponseCode(), Response.Status.OK.getStatusCode(), "Response Code Mismatch"); HttpResponse newVersionApi = restAPIPublisher.getAPI(defaultApiId); Gson g = new Gson(); APIDTO apidto = g.fromJson(newVersionApi.getData(), APIDTO.class); boolean version = apidto.isIsDefaultVersion(); assertEquals(version, true, "Copied API is not the default version"); assertEquals(apidto.getName(), API_NAME, "API name is mismatched"); assertEquals(apidto.getVersion(), newVersion, "API Version is mismatched"); }

Target:
public void setDefaultVersionToNewcopy() throws Exception { String gatewayUrl; if (gatewayContextWrk.getContextTenant().getDomain().equals("carbon.super")) { gatewayUrl = gatewayUrlsWrk.getWebAppURLNhttp(); } else { gatewayUrl = gatewayUrlsWrk.getWebAppURLNhttp() + "t/" + gatewayContextWrk.getContextTenant().getDomain() + "/"; } String endpointUrl = gatewayUrl + "jaxrs_basic/services/customers/customerservice"; providerName = publisherContext.getContextTenant().getContextUser().getUserName(); APIRequest apiRequest = new APIRequest(API_NAME, apiContext, new URL(endpointUrl)); apiRequest.setTags(TAGS); apiRequest.setDescription(description); apiRequest.setVersion(version); apiRequest.setProvider(providerName); apiRequest.setEndpointType(endPointType); apiRequest.setResourceMethodAuthType(resourceMethodAuthType); apiRequest.setTier(tier); apiRequest.setResourceMethodThrottlingTier(resTier); apiRequest.setUriTemplate(uriTemplate); apiRequest.setVisibility(visibility); HttpResponse serviceResponse = restAPIPublisher.addAPI(apiRequest); apiId = serviceResponse.getData(); assertEquals(serviceResponse.getResponseCode(), Response.Status.CREATED.getStatusCode(), "Invalid Response Code"); HttpResponse apiCopyResponse = restAPIPublisher.copyAPI(newVersion, apiId, true); defaultApiId = apiCopyResponse.getData(); assertEquals(apiCopyResponse.getResponseCode(), Response.Status.OK.getStatusCode(), "Response Code Mismatch"); HttpResponse newVersionApi = restAPIPublisher.getAPI(defaultApiId); Gson gson = new Gson(); APIDTO apidto = gson.fromJson(newVersionApi.getData(), APIDTO.class); boolean version = apidto.isIsDefaultVersion(); assertEquals(version, true, "Copied API is not the default version"); assertEquals(apidto.getName(), API_NAME, "API name is mismatched"); assertEquals(apidto.getVersion(), newVersion, "API Version is mismatched"); }