Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACS-6125: test support for path queries against categories #2602

Merged
merged 8 commits into from
Nov 23, 2023
Merged
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.alfresco.elasticsearch.reindexing;

import static java.lang.String.format;

import static org.alfresco.elasticsearch.SearchQueryService.req;
import static org.alfresco.utility.report.log.Step.STEP;

Expand Down Expand Up @@ -112,4 +114,58 @@
STEP("Verify that searching by PARENT and deleted category will find no descendant nodes.");
searchQueryService.expectResultsFromQuery(query, testUser);
}

@Test(groups = TestGroup.SEARCH)
public void testSearchByPath()
{
// given
String Kname = categories.get(K).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Kname' doesn't match '[a-z][a-zA-Z0-9]*'
String Lname = categories.get(L).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Lname' doesn't match '[a-z][a-zA-Z0-9]*'
String Aname = folders(A).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Aname' doesn't match '[a-z][a-zA-Z0-9]*'

// then
STEP("Verify that searching by PATH and category will find: folderA");
SearchRequest query = req(format("PATH:'/cm:categoryRoot/cm:generalclassifiable/cm:%s/cm:%s/cm:%s'", Kname, Lname, Aname));
searchQueryService.expectResultsFromQuery(query, testUser, folders(A).getName());
}

@Test(groups = TestGroup.SEARCH)
public void ensureCategoriesAreNotTransitive_lookingForExactChildren()

Check warning

Code scanning / PMD

The instance method name 'ensureCategoriesAreNotTransitive_lookingForAllDescendants_byParentCategory' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The instance method name 'ensureCategoriesAreNotTransitive_lookingForExactChildren' doesn't match '[a-z][a-zA-Z0-9]*'
{
// given
String Kname = categories.get(K).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Kname' doesn't match '[a-z][a-zA-Z0-9]*'
String Lname = categories.get(L).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Lname' doesn't match '[a-z][a-zA-Z0-9]*'
String Aname = folders(A).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Aname' doesn't match '[a-z][a-zA-Z0-9]*'
String Bname = folders(B).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*'

// then
STEP("Verify that searching by PATH for nested folder will return no results (Dependency to category is not transitive)");
SearchRequest query = req(format("PATH:'/cm:categoryRoot/cm:generalclassifiable/cm:%s/cm:%s/cm:%s/cm:%s'", Kname, Lname, Aname, Bname));
searchQueryService.expectResultsFromQuery(query, testUser);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a expectNoResultsFromQuery method that you can use for this.

}

@Test(groups = TestGroup.SEARCH)
public void ensureCategoriesAreNotTransitive_lookingForAllDescendants()

Check warning

Code scanning / PMD

The instance method name 'ensureCategoriesAreNotTransitive_lookingForAllDescendants_byParentCategory' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The instance method name 'ensureCategoriesAreNotTransitive_lookingForAllDescendants' doesn't match '[a-z][a-zA-Z0-9]*'
{
// given
String Kname = categories.get(K).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Kname' doesn't match '[a-z][a-zA-Z0-9]*'
String Lname = categories.get(L).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Lname' doesn't match '[a-z][a-zA-Z0-9]*'

// then
STEP("Verify that searching by PATH and category will find: folderA");
SearchRequest query = req(format("PATH:'/cm:categoryRoot/cm:generalclassifiable/cm:%s/cm:%s//*'", Kname, Lname));
searchQueryService.expectResultsFromQuery(query, testUser, folders(A).getName());
}

@Test(groups = TestGroup.SEARCH)
public void ensureCategoriesAreNotTransitive_lookingForAllDescendants_byParentCategory()

Check warning

Code scanning / PMD

The instance method name 'ensureCategoriesAreNotTransitive_lookingForAllDescendants_byParentCategory' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The instance method name 'ensureCategoriesAreNotTransitive_lookingForAllDescendants_byParentCategory' doesn't match '[a-z][a-zA-Z0-9]*'
{
// given
String Kname = categories.get(K).getName();

Check warning

Code scanning / PMD

The local variable name 'Bname' doesn't match '[a-z][a-zA-Z0-9]*' Warning test

The local variable name 'Kname' doesn't match '[a-z][a-zA-Z0-9]*'

// then
STEP("Verify that searching by PATH and category will find: folderA");
SearchRequest query = req(format("PATH:'/cm:categoryRoot/cm:generalclassifiable/cm:%s//*'", Kname));
searchQueryService.expectResultsFromQuery(query, testUser, categories.get(L).getName(), folders(A).getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ protected FileModel createDocument(String filename)
.createContent(new FileModel(filename, FileType.TEXT_PLAIN, "content"));
}



private static String generateRandomFolderNameWith(String folderSuffix)
{
return "folder" + folderSuffix + "_" + UUID.randomUUID();
Expand Down
Loading