Source:
<code>public void setEnvironment() throws Exception { super.init(userMode); log.info("Test Starting user mode:" + userMode); providerName = publisherContext.getContextTenant().getContextUser().getUserName(); apiEndPointUrl = backEndServerUrl.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL; apiRequest = new APIRequest(apiName, apiContext, new URL(apiEndPointUrl)); apiRequest.setVersion(apiVersion); apiRequest.setTiersCollection(APIMIntegrationConstants.API_TIER.UNLIMITED); apiRequest.setTier(APIMIntegrationConstants.API_TIER.UNLIMITED); apiRequest.setProvider(providerName); apiRequest.setDescription(API_DESCRIPTION); HttpResponse createResponse = restAPIPublisher.addAPI(apiRequest); assertEquals(createResponse.getResponseCode(), 201, "Error in API Creation"); apis.add(0, createResponse.getData()); <START> restAPIPublisher <END> .changeAPILifeCycleStatus(createResponse.getData(), APILifeCycleAction.PUBLISH.getAction(), null); HttpResponse applicationResponse = restAPIStore.createApplication(applicationName, "app1", APIMIntegrationConstants.APPLICATION_TIER.UNLIMITED, ApplicationDTO.TokenTypeEnum.OAUTH); applications.add(0, applicationResponse.getData()); restAPIStore.createSubscription(createResponse.getData(), applicationResponse.getData(), "Unlimited"); DocumentDTO.VisibilityEnum docVisibility = DocumentDTO.VisibilityEnum.API_LEVEL; DocumentDTO.SourceTypeEnum sourceType = DocumentDTO.SourceTypeEnum.INLINE; String summary = "This is a sample documentation"; String name = "Introduction to PhoneVerification API"; DocumentDTO.TypeEnum type = DocumentDTO.TypeEnum.HOWTO; documentDTO.setName(name); documentDTO.setType(type); documentDTO.setSourceType(sourceType); documentDTO.setSummary(summary); documentDTO.setVisibility(docVisibility); HttpResponse documentationResponse = restAPIPublisher.addDocument(createResponse.getData(), documentDTO); assertEquals(documentationResponse.getResponseCode(), 200, "Error while add documentation to API"); documentId = documentationResponse.getData(); }</code><technical_language>Lets common method create publish API</technical_language>

Target:
public void setEnvironment() throws Exception { super.init(userMode); log.info("Test Starting user mode:" + userMode); apiPublisherClientUser = new APIPublisherRestClient(publisherURLHttp); providerName = publisherContext.getContextTenant().getContextUser().getUserName(); apiEndPointUrl = backEndServerUrl.getWebAppURLHttp() + API_END_POINT_POSTFIX_URL; apiRequest = new APIRequest(apiName, apiContext, new URL(apiEndPointUrl)); apiRequest.setVersion(apiVersion); apiRequest.setTiersCollection(APIMIntegrationConstants.API_TIER.UNLIMITED); apiRequest.setTier(APIMIntegrationConstants.API_TIER.UNLIMITED); apiRequest.setProvider(providerName); apiRequest.setDescription(API_DESCRIPTION); apiId = createAndPublishAPIUsingRest(apiRequest, restAPIPublisher, false); DocumentDTO.VisibilityEnum docVisibility = DocumentDTO.VisibilityEnum.API_LEVEL; DocumentDTO.SourceTypeEnum sourceType = DocumentDTO.SourceTypeEnum.INLINE; String summary = "This is a sample documentation"; String name = "Introduction to PhoneVerification API"; DocumentDTO.TypeEnum type = DocumentDTO.TypeEnum.HOWTO; documentDTO.setName(name); documentDTO.setType(type); documentDTO.setSourceType(sourceType); documentDTO.setSummary(summary); documentDTO.setVisibility(docVisibility); HttpResponse documentationResponse = restAPIPublisher.addDocument(apiId, documentDTO); assertEquals(documentationResponse.getResponseCode(), 200, "Error while add documentation to API"); documentId = documentationResponse.getData(); }