Skip to content

Commit

Permalink
refactor UserMeApproval test user addition with workflow engagement
Browse files Browse the repository at this point in the history
  • Loading branch information
vinumaddumage committed Jun 14, 2023
1 parent 338824b commit 2a8336c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ protected void waitForWorkflowToDeploy() throws Exception {
runLoop = false;

if (!isBpelDeployed) {
url = super.getBackendURL() + addUserWorkflowName + "Service?wsdl";
url = identityContextUrls.getSecureServiceUrl() + "/" + addUserWorkflowName + "Service?wsdl";
} else {
url = super.getBackendURL() + addUserWorkflowName + "TaskService?wsdl";
url = identityContextUrls.getSecureServiceUrl() + "/" + addUserWorkflowName + "TaskService?wsdl";
}
HttpGet request = new HttpGet(url);
HttpResponse httpResponse = client.execute(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.um.ws.api.stub.ClaimValue;
import org.wso2.identity.integration.test.rest.api.user.approval.common.UserApprovalTestBase;

import java.io.IOException;
import java.util.Arrays;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
Expand All @@ -51,7 +53,6 @@ public class UserMeApprovalTest extends UserApprovalTestBase {
private static final String TEST_WORKFLOW_ADD_USER_FOR_REST_TASK = addUserWorkflowName + "Task";
private static final String JSON_PATH_MATCHING_REST_API_TEST_APPROVAL_TASK = "findAll{ it.presentationName == '"
+ TEST_WORKFLOW_ADD_USER_FOR_REST_TASK + "' }";
private static final int MAX_WAIT_ITERATIONS_TILL_WORKFLOW_DEPLOYMENT = 18;

private static String swaggerDefinition;
private String taskIdToApprove;
Expand Down Expand Up @@ -117,23 +118,22 @@ public void testListTasksWhenEmpty() {
@Test(dependsOnMethods = {"testListTasksWhenEmpty"})
public void testListTasksWhenAvailable() throws Exception {

addAssociationForMatch();
for (int i = 1; i <= MAX_WAIT_ITERATIONS_TILL_WORKFLOW_DEPLOYMENT; i++) {
log.info("Adding users matching the workflow engagement " + addUserWorkflowName + " to tenant " + tenant);
for (int i = 0; i < userToAdd.length; i++) {
usmClient.addUser(userToAdd[i], "test12345", Arrays.copyOfRange(rolesToAdd,0, i+1),
new ClaimValue[0],null, false);
// Wait till workflow is applied.
log.info("Waiting 5 seconds till the workflow is applied for association.");
Thread.sleep(5000);
int numOfTasks = getResponseOfGet(ME_APPROVAL_TASKS_ENDPOINT_URI)
.then()
.extract()
.path("findAll{ it.presentationName == '"
+ TEST_WORKFLOW_ADD_USER_FOR_REST_TASK + "' }.size()");
if (numOfTasks == 3) {
log.info("All approval tasks are created successfully");
break;
if (numOfTasks == i + 1) {
log.info("Tasks created successfully. Number of tasks created : " + numOfTasks + " of "
+ userToAdd.length);
}

// Wait till workflow is applied.
log.info("Waiting 5 seconds till the workflow is applied for association, iteration " + i + " of " +
MAX_WAIT_ITERATIONS_TILL_WORKFLOW_DEPLOYMENT);
log.info("Number of tasks created for now : " + numOfTasks);
Thread.sleep(5000);
}

getResponseOfGet(ME_APPROVAL_TASKS_ENDPOINT_URI)
Expand Down

0 comments on commit 2a8336c

Please sign in to comment.