Source:
public void testPublishAPIByUpdatingRoleInUser(String role) throws Exception { apiName = "API" + count; apiContext = "/verify" + count; creatorUser = "User_" + count; testUser = "User" + count; password = "password123$"; count++; createUserWithCreatorRole(creatorUser, password, ADMIN_LOGIN_USERNAME, ADMIN_PASSWORD); apiPublisher.login(creatorUser, password); apiRequest = new APIRequest(apiName, apiContext, apiVisibility, apiVersion, apiResource, tierCollection, new URL(backendEndPoint)); createAPI(apiRequest); getAPI(apiName, creatorUser, apiVersion); apiNames.put(apiName, creatorUser); userList.add(testUser); apiPublisher.logout(); createUser(testUser, password, new String[]{role}, ADMIN_LOGIN_USERNAME, ADMIN_PASSWORD); apiPublisher.login(testUser, password); HttpResponse publishAPI = changeAPILifeCycleStatus(apiName, creatorUser, APILifeCycleState.PUBLISHED); assertFalse(publishAPI.getData().contains("PUBLISHED"), "API has been created in publisher"); updateUser(testUser, "internal/publisher", role, ADMIN_LOGIN_USERNAME, ADMIN_PASSWORD); apiPublisher.login(testUser, password); HttpResponse publisherPublishAPI = changeAPILifeCycleStatus(apiName, creatorUser, APILifeCycleState.PUBLISHED); verifyResponse(publisherPublishAPI); assertTrue(publisherPublishAPI.getData().contains("PUBLISHED"), "API has not been created in publisher"); HttpResponse changeAPIStatus = changeAPILifeCycleStatus(apiName, creatorUser, APILifeCycleState.CREATED); verifyResponse(changeAPIStatus); assertTrue(changeAPIStatus.getData().contains("CREATED"), "API has been created in publisher"); updateUser(testUser, "admin", role, ADMIN_LOGIN_USERNAME, ADMIN_PASSWORD); apiPublisher.login(testUser, password); HttpResponse adminChangeAPIStatus = changeAPILifeCycleStatus(apiName, creatorUser, APILifeCycleState.PUBLISHED); verifyResponse(adminChangeAPIStatus); assertTrue(adminChangeAPIStatus.getData().contains("PUBLISHED"), "API has not been created in publisher"); }

Target:
public void testPublishAPIByUpdatingRoleInUser(String role) throws Exception { apiName = "API" + count; apiContext = "/verify" + count; creatorUser = "User_" + count; testUser = "User" + count; password = "password123$"; count++; createUserWithCreatorRole(creatorUser, password, ADMIN_LOGIN_USERNAME, ADMIN_PASSWORD); apiPublisher.login(creatorUser, password); apiRequest = new APIRequest(apiName, apiContext, apiVisibility, apiVersion, apiResource, tierCollection, new URL(backendEndPoint)); createAPI(apiRequest); getAPI(apiName, creatorUser, apiVersion); apiNames.put(apiName, creatorUser); userList.add(testUser); apiPublisher.logout(); createUser(testUser, password, new String[]{role}, ADMIN_LOGIN_USERNAME, ADMIN_PASSWORD); apiPublisher.login(testUser, password); HttpResponse publishAPI = changeAPILifeCycleStatus(apiName, creatorUser, APILifeCycleState.PUBLISHED); assertFalse(publishAPI.getData().contains("PUBLISHED"), "API has been published"); updateUser(testUser, "internal/publisher", role, ADMIN_LOGIN_USERNAME, ADMIN_PASSWORD); apiPublisher.login(testUser, password); HttpResponse publisherPublishAPI = changeAPILifeCycleStatus(apiName, creatorUser, APILifeCycleState.PUBLISHED); verifyResponse(publisherPublishAPI); assertTrue(publisherPublishAPI.getData().contains("PUBLISHED"), "API has not been published by internal/publisher"); HttpResponse changeAPIStatus = changeAPILifeCycleStatus(apiName, creatorUser, APILifeCycleState.CREATED); verifyResponse(changeAPIStatus); assertTrue(changeAPIStatus.getData().contains("CREATED")); updateUser(testUser, "admin", role, ADMIN_LOGIN_USERNAME, ADMIN_PASSWORD); apiPublisher.login(testUser, password); HttpResponse adminChangeAPIStatus = changeAPILifeCycleStatus(apiName, creatorUser, APILifeCycleState.PUBLISHED); verifyResponse(adminChangeAPIStatus); assertTrue(adminChangeAPIStatus.getData().contains("PUBLISHED"), "API has not been published by admin"); }