Source:
<code>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); <START> Gson g = new Gson(); <END> 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"); }</code><technical_language>a more meaningful name 'gson' 'g'</technical_language>

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"); }