Skip to content

Commit

Permalink
ACS-6256: Move logic related with managing folders and categories for…
Browse files Browse the repository at this point in the history
… TAS tests from acs-packaging to community-repo
  • Loading branch information
krdabrowski committed Nov 17, 2023
1 parent 8f9d183 commit 37bd06b
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 562 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<groupId>org.alfresco</groupId>
<artifactId>alfresco-enterprise-repo</artifactId>
<relativePath>../alfresco-enterprise-repo/pom.xml</relativePath>
<version>23.2.0.10</version>
<version>23.2.0.11-SNAPSHOT</version>
</parent>

<properties>
<dependency.alfresco-enterprise-repo.version>23.2.0.10</dependency.alfresco-enterprise-repo.version>
<dependency.alfresco-enterprise-repo.version>23.2.0.11-SNAPSHOT</dependency.alfresco-enterprise-repo.version>
<dependency.alfresco-enterprise-share.version>23.2.0.2</dependency.alfresco-enterprise-share.version>

<alfresco.rm-enterprise-rest-api-explorer.version>3.0.2</alfresco.rm-enterprise-rest-api-explorer.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static org.alfresco.elasticsearch.SearchQueryService.req;
import static org.alfresco.utility.report.log.Step.STEP;

import org.alfresco.elasticsearch.reindexing.utils.Categories;
import org.alfresco.rest.repo.resource.Categories;
import org.alfresco.rest.search.SearchRequest;
import org.alfresco.utility.model.TestGroup;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -13,7 +13,7 @@
/**
* Tests verifying live indexing of secondary children and ANCESTOR index in Elasticsearch.
*/
@SuppressWarnings({"PMD.JUnitTestsShouldIncludeAssert", "PMD.JUnit4TestShouldUseTestAnnotation"}) // these are testng tests and use searchQueryService.expectResultsFromQuery for assertion
@SuppressWarnings({"PMD.JUnitTestsShouldIncludeAssert"}) // these are testng tests and use searchQueryService.expectResultsFromQuery for assertion
public class NodeWithCategoryIndexingTests extends NodesSecondaryChildrenRelatedTests
{

Expand All @@ -34,13 +34,13 @@ public void dataPreparation()

// given
STEP("Create nested folders in site's Document Library.");
folders().createNestedFolders(A, B);
folders.add().nestedRandomFolders(A, B).create();

STEP("Create nested categories.");
categories.createNestedCategories(K, L);
categories.add().nestedRandomCategories(K, L).create();

STEP("Link folders to category.");
folders(A).linkToCategory(categories.get(L));
folders.modify(A).linkTo(categories.get(L));
}

@Test(groups = TestGroup.SEARCH)
Expand All @@ -58,30 +58,30 @@ public void testParentQueryAgainstFolder()
// then
STEP("Verify that searching by PARENT and category will find one descendant node: folderA.");
SearchRequest query = req("PARENT:" + categories.get(L).getId());
searchQueryService.expectResultsFromQuery(query, testUser, folders(A).getName());
searchQueryService.expectResultsFromQuery(query, testUser, folders.get(A).getName());
}

@Test(groups = TestGroup.SEARCH)
public void testParentQueryAgainstFolderAfterCategoryDeletion()
{
// given
STEP("Create nested folders in site's Document Library.");
folders().createNestedFolders(C);
folders.add().randomFolder(C).create();

STEP("Create nested categories.");
categories.createNestedCategories(M);
categories.add().randomCategory(M).create();

STEP("Link folders to category.");
folders(C).linkToCategory(categories.get(M));
folders.modify(C).linkTo(categories.get(M));

// when
STEP("Verify that searching by PARENT and category will find one descendant node: folderC.");
SearchRequest query = req("PARENT:" + categories.get(M).getId());
searchQueryService.expectResultsFromQuery(query, testUser, folders(C).getName());
searchQueryService.expectResultsFromQuery(query, testUser, folders.get(C).getName());

// then
STEP("Delete categoryM.");
categories.delete(M);
categories.delete(categories.get(M));

STEP("Verify that searching by PARENT and deleted category will find no descendant nodes.");
searchQueryService.expectResultsFromQuery(query, testUser);
Expand All @@ -92,22 +92,22 @@ public void testParentQueryAgainstFolderAfterParentCategoryDeletion()
{
// given
STEP("Create nested folders in site's Document Library.");
folders().createNestedFolders(C);
folders.add().randomFolder(X).create();

STEP("Create nested categories.");
categories.createNestedCategories(P, Q);
categories.add().nestedRandomCategories(P, Q).create();

STEP("Link folders to category.");
folders(C).linkToCategory(categories.get(Q));
folders.modify(X).linkTo(categories.get(Q));

// when
STEP("Verify that searching by PARENT and category will find one descendant node: folderC.");
SearchRequest query = req("PARENT:" + categories.get(Q).getId());
searchQueryService.expectResultsFromQuery(query, testUser, folders(C).getName());
searchQueryService.expectResultsFromQuery(query, testUser, folders.get(X).getName());

// then
STEP("Delete categoryM.");
categories.delete(P);
categories.delete(categories.get(P));

STEP("Verify that searching by PARENT and deleted category will find no descendant nodes.");
searchQueryService.expectResultsFromQuery(query, testUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.alfresco.rest.search.SearchRequest;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.TestGroup;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand Down Expand Up @@ -46,58 +47,55 @@ public void dataPreparation()

// given
STEP("Create few sets of nested folders in site's Document Library.");
folders().createNestedFolders(A, B, C);
folders().createNestedFolders(K, L, M);
folders().createNestedFolders(X, Y, Z);
folders().createFolder(P);
folders().createFolder(Q);
folders().createFolder(R);
folders().createFolder(S);
fileInP = folders(P).createRandomDocument();
folders.add().nestedRandomFolders(A, B, C).create();
folders.add().nestedRandomFolders(K, L, M).create();
folders.add().nestedRandomFolders(X, Y, Z).create();
folders.add().randomFolders(P, Q, R, S).create();
fileInP = folders.modify(P).add().randomFile().withRandomTitle().withRandomDescription().withRandomContent().create();

STEP("Create few secondary parent-child relationships.");
folders(K).addSecondaryChild(folders(B));
folders(X).addSecondaryChild(folders(K));
folders(L).addSecondaryChildren(folders(C), folders(Y));
folders(M).addSecondaryChild(folders(C));
folders(A).addSecondaryChild(fileInP);
folders.modify(K).add().secondaryContent(folders.get(B));
folders.modify(X).add().secondaryContent(folders.get(K));
folders.modify(L).add().secondaryContent(folders.get(C), folders.get(Y));
folders.modify(M).add().secondaryContent(folders.get(C));
folders.modify(A).add().secondaryContent(fileInP);
}

@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithNodeHavingOneSecondaryChild()
{
// then
STEP("Verify that searching by ANCESTOR and folderM will find one descendant node: folderC.");
SearchRequest query = req("ANCESTOR:" + folders(M).getNodeRef());
SearchRequest query = req("ANCESTOR:" + folders.get(M).getNodeRef());
searchQueryService.expectResultsFromQuery(query, testUser,
folders(C).getName());
folders.get(C).getName());
}

@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithNodeHavingTwoSecondaryChildren()
{
// then
STEP("Verify that searching by ANCESTOR and folderL will find nodes: folderM, folderC, folderY and folderZ.");
SearchRequest queryAncestorL = req("ANCESTOR:" + folders(L).getNodeRef());
SearchRequest queryAncestorL = req("ANCESTOR:" + folders.get(L).getNodeRef());
searchQueryService.expectResultsFromQuery(queryAncestorL, testUser,
// primary descendant
folders(M).getName(),
folders.get(M).getName(),
// secondary descendants
folders(C).getName(),
folders(Y).getName(),
folders(Z).getName());
folders.get(C).getName(),
folders.get(Y).getName(),
folders.get(Z).getName());
}

@Test(groups = TestGroup.SEARCH)
public void testSecondaryAncestorWithDocumentAsSecondaryChild()
{
// then
STEP("Verify that searching by ANCESTOR and folderA will find nodes: folderB, folderC and fileInP.");
SearchRequest query = req("ANCESTOR:" + folders(A).getNodeRef());
SearchRequest query = req("ANCESTOR:" + folders.get(A).getNodeRef());
searchQueryService.expectResultsFromQuery(query, testUser,
// primary descendants
folders(B).getName(),
folders(C).getName(),
folders.get(B).getName(),
folders.get(C).getName(),
// secondary descendant
fileInP.getName());
}
Expand All @@ -107,17 +105,17 @@ public void testSecondaryAncestorWithNodeHavingComplexSecondaryRelationship()
{
// then
STEP("Verify that all descendant of folderX can be found.");
SearchRequest query = req("ANCESTOR:" + folders(X).getNodeRef());
SearchRequest query = req("ANCESTOR:" + folders.get(X).getNodeRef());
searchQueryService.expectResultsFromQuery(query, testUser,
// primary descendants
folders(Y).getName(),
folders(Z).getName(),
folders.get(Y).getName(),
folders.get(Z).getName(),
// secondary descendants
folders(B).getName(),
folders(C).getName(),
folders(K).getName(),
folders(L).getName(),
folders(M).getName()
folders.get(B).getName(),
folders.get(C).getName(),
folders.get(K).getName(),
folders.get(L).getName(),
folders.get(M).getName()
);
}

Expand All @@ -143,17 +141,17 @@ public void testSecondaryAncestorWithDeletedSecondaryRelationship()
{
// given
STEP("Add to folderQ a secondary child folderR and verify if it can be found using ANCESTOR index and secondary child node reference.");
folders(Q).addSecondaryChild(folders(R));
folders.modify(Q).add().secondaryContent(folders.get(R));

STEP("Verify that searching by ANCESTOR and folderQ will find secondary descendant node: folderR.");
SearchRequest query = req("ANCESTOR:" + folders(Q).getNodeRef());
SearchRequest query = req("ANCESTOR:" + folders.get(Q).getNodeRef());
searchQueryService.expectResultsFromQuery(query, testUser,
// secondary descendant
folders(R).getName());
folders.get(R).getName());

// when
STEP("Delete the secondary parent-child relationship between folderQ and FolderR.");
folders(Q).removeSecondaryChild(folders(R));
folders.modify(Q).remove().secondaryContent(folders.get(R));

// then
STEP("Verify that folderQ cannot be found by ANCESTOR and folderQ anymore.");
Expand Down Expand Up @@ -185,23 +183,23 @@ public void testSecondaryAncestorWithDeletedSecondaryParentNode()
{
// given
STEP("Create two nested folders (E and F) in Document Library.");
Folder folderE = folders().createFolder( "E");
Folder folderF = folderE.createNestedFolder( "F");
FolderModel folderE = folders.add().randomFolder("E").create();
FolderModel folderF = folders.modify(folderE).add().randomFolder("F").create();
STEP("Make folderE a secondary children of folderQ and folderR a secondary children of folderE.");
folders(Q).addSecondaryChild(folderE);
folderE.addSecondaryChild(folders(R));
folders.modify(Q).add().secondaryContent(folderE);
folders.modify(folderE).add().secondaryContent(folders.get(R));

STEP("Verify that searching by ANCESTOR and folderQ will find its secondary descendant: folderE, folderF and folderR.");
SearchRequest queryAncestorQ = req("ANCESTOR:" + folders(Q).getNodeRef());
SearchRequest queryAncestorQ = req("ANCESTOR:" + folders.get(Q).getNodeRef());
searchQueryService.expectResultsFromQuery(queryAncestorQ, testUser,
// secondary descendants
folderE.getName(),
folderF.getName(),
folders(R).getName());
folders.get(R).getName());

// when
STEP("Delete folderE with its content.");
folders().delete(folderE);
folders.modify(folderE).delete();

// then
STEP("Verify that searching by ANCESTOR and folderQ will not find any nodes.");
Expand All @@ -228,24 +226,24 @@ public void testSecondaryAncestorWithMovedSecondaryParentNode()
{
// given
STEP("Create folderD inside folderQ, and add folderP to D as a secondary child.");
Folder folderD = folders(Q).createNestedFolder( "D");
folderD.addSecondaryChild(folders(P));
FolderModel folderD = folders.modify(Q).add().randomFolder("D").create();
folders.modify(folderD).add().secondaryContent(folders.get(P));

STEP("Verify that searching by ANCESTOR and folderQ will find its primary and secondary descendant nodes: folderD, folderP and file.");
SearchRequest queryAncestorQ = req("ANCESTOR:" + folders(Q).getNodeRef());
SearchRequest queryAncestorQ = req("ANCESTOR:" + folders.get(Q).getNodeRef());
searchQueryService.expectResultsFromQuery(queryAncestorQ, testUser,
// primary descendant
folderD.getName(),
// secondary descendants
folders(P).getName(),
folders.get(P).getName(),
fileInP.getName());
STEP("Verify that searching by ANCESTOR and folderR will not find any descendant nodes.");
SearchRequest queryAncestorR = req("ANCESTOR:" + folders(R).getNodeRef());
SearchRequest queryAncestorR = req("ANCESTOR:" + folders.get(R).getNodeRef());
searchQueryService.expectNoResultsFromQuery(queryAncestorR, testUser);

// when
STEP("Move folderD from folderQ to folderR.");
folderD.moveTo(folders(R));
folders.modify(folderD).moveTo(folders.get(R));

// then
STEP("Verify that search result for ANCESTOR and folderQ will not find any descendant anymore.");
Expand All @@ -255,11 +253,11 @@ public void testSecondaryAncestorWithMovedSecondaryParentNode()
// primary descendant
folderD.getName(),
// secondary descendants
folders(P).getName(),
folders.get(P).getName(),
fileInP.getName());

STEP("Clean-up - delete folderD.");
folders().delete(folderD);
folders.modify(folderD).delete();
}

/**
Expand Down Expand Up @@ -290,27 +288,27 @@ public void testSecondaryAncestorWithCopiedSecondaryParentNode()
{
// given
STEP("Create nested folders (G and H) inside folderS and folderT in Document Library. Make folderP a secondary child of folderG.");
Folder folderG = folders(S).createNestedFolder( "G");
Folder folderH = folderG.createNestedFolder("H");
Folder folderT = folders().createFolder("T");
folderG.addSecondaryChild(folders(P));
FolderModel folderG = folders.modify(S).add().randomFolder( "G").create();
FolderModel folderH = folders.modify(folderG).add().randomFolder("H").create();
FolderModel folderT = folders.add().randomFolder("T").create();
folders.modify(folderG).add().secondaryContent(folders.get(P));

STEP("Verify that searching by ANCESTOR and folderS will find its descendant nodes: folderG, folderH, folderP and file in P.");
SearchRequest queryAncestorS = req("ANCESTOR:" + folders(S).getNodeRef());
SearchRequest queryAncestorS = req("ANCESTOR:" + folders.get(S).getNodeRef());
searchQueryService.expectResultsFromQuery(queryAncestorS, testUser,
// primary descendants
folderG.getName(),
folderH.getName(),
// secondary descendants
folders(P).getName(),
folders.get(P).getName(),
fileInP.getName());
STEP("Verify that searching by ANCESTOR and folderT will not find any nodes.");
SearchRequest queryAncestorT = req("ANCESTOR:" + folderT.getNodeRef());
searchQueryService.expectNoResultsFromQuery(queryAncestorT, testUser);

// when
STEP("Copy folderG with its content to folderT.");
Folder folderGCopy = folderG.copyTo(folderT);
FolderModel folderGCopy = folders.modify(folderG).copyTo(folderT);

// then
STEP("Verify that searching by ANCESTOR and folderS will find its descendant nodes: folderG, folderH, folderP and file in P.");
Expand All @@ -319,19 +317,19 @@ public void testSecondaryAncestorWithCopiedSecondaryParentNode()
folderG.getName(),
folderH.getName(),
// secondary descendants
folders(P).getName(),
folders.get(P).getName(),
fileInP.getName());
STEP("Verify that searching by ANCESTOR and folderT will find its descendant nodes: folderG-copy, folderH-copy, folderP, file.");
searchQueryService.expectResultsFromQuery(queryAncestorT, testUser,
// primary descendants
folderGCopy.getName(),
folderH.getName(), // the same name as folderH-copy
// secondary descendants
folders(P).getName(),
folders.get(P).getName(),
fileInP.getName());

STEP("Clean-up - delete folderG and folderT (with G's copy).");
folders().delete(folderG);
folders().delete(folderT);
folders.modify(folderG).delete();
folders.modify(folderT).delete();
}
}
Loading

0 comments on commit 37bd06b

Please sign in to comment.