mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'master' of https://gitlab.alfresco.com/tas/alfresco-tas-restapi-test
This commit is contained in:
@@ -3,11 +3,14 @@ package org.alfresco.rest;
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.model.*;
|
||||
import org.alfresco.utility.constants.ActivityType;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -24,6 +27,10 @@ public class FunctionalCasesTests extends RestTest
|
||||
private RestFavoriteSiteModel restFavoriteSiteModel;
|
||||
private RestActivityModelsCollection activities;
|
||||
private FileModel file;
|
||||
private RestActivityModelsCollection restActivityModelsCollection;
|
||||
private FolderModel folderInSite;
|
||||
private FileModel fileInSite;
|
||||
private RestCommentModel commentModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
@@ -621,5 +628,63 @@ public class FunctionalCasesTests extends RestTest
|
||||
.assertThat().entriesListDoesNotContain("id", testUser.getUsername());
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scenario:
|
||||
* 1. Add user to site
|
||||
* 2. Create folder
|
||||
* 3. Create document
|
||||
* 4. Add comment to the document
|
||||
* 5. Like document
|
||||
* 6. Update Comment
|
||||
* 7. Update user role
|
||||
* 8. Delete like rating
|
||||
* 9. Delete site member
|
||||
* 10. Delete comment
|
||||
* 11. Get Activities
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Bug(id="REPO-1830")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES, TestGroup.FULL })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.ACTIVITIES }, executionType = ExecutionType.REGRESSION, description = "Verify user gets its activities with Rest API and response is successful")
|
||||
public void userGetsItsPeopleActivities() throws Exception
|
||||
{
|
||||
UserModel newUser = dataUser.createRandomTestUser();
|
||||
SiteModel userSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite();
|
||||
dataUser.addUserToSite(newUser, userSiteModel, UserRole.SiteCollaborator);
|
||||
folderInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createFolder();
|
||||
fileInSite = dataContent.usingUser(newUser).usingSite(userSiteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
String newContent = "This is a new comment added by " + newUser.getUsername();
|
||||
commentModel = restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).addComment(newContent);
|
||||
restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).likeDocument();
|
||||
|
||||
restClient.withCoreAPI().usingResource(fileInSite).updateComment(commentModel, "new Content");
|
||||
newUser.setUserRole(UserRole.SiteManager);
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).updateSiteMember(newUser);
|
||||
|
||||
restClient.authenticateUser(newUser).withCoreAPI().usingResource(fileInSite).deleteLikeRating();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(fileInSite).deleteComment(commentModel);
|
||||
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(userSiteModel).deleteSiteMember(newUser);
|
||||
|
||||
restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivitiesUntilEntriesCountIs(10);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restActivityModelsCollection.assertThat().paginationField("count").is("10");
|
||||
|
||||
restActivityModelsCollection = restClient.authenticateUser(newUser).withCoreAPI().usingMe().getPersonActivities();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restActivityModelsCollection.assertThat().paginationField("count").is("10");
|
||||
|
||||
restActivityModelsCollection.assertThat().entriesListContains("activityType", ActivityType.USER_JOINED.toString()).assertThat()
|
||||
.entriesListContains("activityType", ActivityType.FILE_ADDED.toString()).assertThat()
|
||||
.entriesListContains("activityType", ActivityType.FOLDER_ADDED.toString()).assertThat()
|
||||
.entriesListContains("activityType", ActivityType.COMMENT_CREATED.toString()).assertThat()
|
||||
.entriesListContains("activityType", ActivityType.FILE_LIKED.toString()).assertThat()
|
||||
.entriesListContains("activityType", ActivityType.COMMENT_UPDATED.toString()).assertThat()
|
||||
.entriesListContains("activityType", ActivityType.USER_ROLE_CHANGED.toString()).assertThat()
|
||||
.entriesListContains("activityType", ActivityType.COMMENT_DELETED.toString()).assertThat()
|
||||
.entriesListContains("activityType", ActivityType.USER_LEFT.toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package org.alfresco.rest.workflow.tasks;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.dataprep.CMISUtil.Priority;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestProcessModel;
|
||||
import org.alfresco.rest.model.RestTaskModel;
|
||||
import org.alfresco.rest.model.RestTaskModelsCollection;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetTasksFullTests extends RestTest
|
||||
{
|
||||
UserModel userModel, adminUser;
|
||||
SiteModel siteModel;
|
||||
UserModel candidateUser;
|
||||
FileModel fileModel;
|
||||
UserModel assigneeUser;
|
||||
RestTaskModelsCollection taskModels;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
adminUser = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
|
||||
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
assigneeUser = dataUser.createRandomTestUser();
|
||||
dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that skipCount parameter is applied.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
|
||||
public void skipCountParameterApplied() throws Exception
|
||||
{
|
||||
RestTaskModelsCollection taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel();
|
||||
RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel();
|
||||
|
||||
taskModels = restClient.withParams("skipCount=2").withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
taskModels.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListDoesNotContain("id", firstTask.getId())
|
||||
.assertThat().entriesListDoesNotContain("id", secondTask.getId());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that maxItems parameter is applied.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
|
||||
public void maxItemsParameterApplied() throws Exception
|
||||
{
|
||||
RestTaskModelsCollection taskCollections = restClient.authenticateUser(dataUser.getAdminUser()).withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
RestTaskModel firstTask = taskCollections.getEntries().get(0).onModel();
|
||||
RestTaskModel secondTask = taskCollections.getEntries().get(1).onModel();
|
||||
|
||||
taskModels = restClient.withParams("maxItems=2").withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
taskModels.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("id", firstTask.getId())
|
||||
.assertThat().entriesListContains("id", secondTask.getId());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Check that properties parameter is applied.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
|
||||
public void propertiesParameterApplied() throws Exception
|
||||
{
|
||||
taskModels = restClient.authenticateUser(dataUser.getAdminUser()).withParams("properties=name,description").withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
taskModels.assertThat().entriesListIsNotEmpty()
|
||||
.assertThat().entriesListContains("name")
|
||||
.assertThat().entriesListContains("description")
|
||||
.assertThat().entriesListDoesNotContain("processDefinitionId")
|
||||
.assertThat().entriesListDoesNotContain("processId")
|
||||
.assertThat().entriesListDoesNotContain("startedAt")
|
||||
.assertThat().entriesListDoesNotContain("id")
|
||||
.assertThat().entriesListDoesNotContain("state")
|
||||
.assertThat().entriesListDoesNotContain("activityDefinitionId")
|
||||
.assertThat().entriesListDoesNotContain("priority")
|
||||
.assertThat().entriesListDoesNotContain("formResourceKey");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW,
|
||||
TestGroup.TASKS }, executionType = ExecutionType.REGRESSION, description = "Use invalid where parameter. Check default error model schema.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
|
||||
public void invalidWhereParameterCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(dataUser.getAdminUser()).where("assignee AND '" + assigneeUser.getUsername() + "'").withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsErrorKey(RestErrorModel.INVALID_QUERY_ERRORKEY)
|
||||
.containsSummary(String.format(RestErrorModel.INVALID_WHERE_QUERY, "(assignee AND '" + assigneeUser.getUsername() + "')"))
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER);
|
||||
}
|
||||
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that for admin network gets tasks only from its network.")
|
||||
public void adminTenantGetsTasksOnlyFromItsNetwork() throws Exception
|
||||
{
|
||||
UserModel adminTenant1 = UserModel.getAdminTenantUser();
|
||||
restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant1);
|
||||
|
||||
UserModel adminTenant2 = UserModel.getAdminTenantUser();
|
||||
restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenant2);
|
||||
|
||||
UserModel tenantUser1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenant1");
|
||||
UserModel tenantUserAssignee1 = dataUser.usingUser(adminTenant1).createUserWithTenant("userTenantAssignee1");
|
||||
|
||||
UserModel tenantUser2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenant2");
|
||||
UserModel tenantUserAssignee2 = dataUser.usingUser(adminTenant2).createUserWithTenant("userTenantAssignee2");
|
||||
|
||||
RestProcessModel processOnTenant1 = restClient.authenticateUser(tenantUser1).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee1, false, Priority.Low);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
RestProcessModel processOnTenant2 = restClient.authenticateUser(tenantUser2).withWorkflowAPI().addProcess("activitiAdhoc", tenantUserAssignee2, false, Priority.Normal);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
RestTaskModelsCollection tenantTasks1 = restClient.authenticateUser(adminTenant1).withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
tenantTasks1.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListCountIs(1)
|
||||
.and().entriesListContains("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase()))
|
||||
.and().entriesListContains("processId", processOnTenant1.getId())
|
||||
.and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase()))
|
||||
.and().entriesListDoesNotContain("processId", processOnTenant2.getId());
|
||||
|
||||
RestTaskModelsCollection tenantTasks2 = restClient.authenticateUser(adminTenant2).withWorkflowAPI().getTasks();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
tenantTasks2.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListCountIs(1)
|
||||
.and().entriesListContains("assignee", String.format("userTenantAssignee2@%s", tenantUserAssignee2.getDomain().toLowerCase()))
|
||||
.and().entriesListContains("processId", processOnTenant2.getId())
|
||||
.and().entriesListDoesNotContain("assignee", String.format("userTenantAssignee1@%s", tenantUserAssignee1.getDomain().toLowerCase()))
|
||||
.and().entriesListDoesNotContain("processId", processOnTenant1.getId());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user