Skip to content

Commit

Permalink
ALFREDAPI-562: Fix search test
Browse files Browse the repository at this point in the history
  • Loading branch information
WimCrols committed Dec 10, 2024
1 parent 041fae3 commit 61d1750
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import eu.xenit.alfred.api.search.ISearchService;
import eu.xenit.alfred.api.search.QueryBuilder;
import eu.xenit.alfred.api.search.SearchQuery;
import eu.xenit.alfred.api.search.SearchQueryConsistency;
import eu.xenit.alfred.api.search.SearchQueryResult;
import eu.xenit.alfred.api.tests.JavaApiBaseTest;
import java.io.Serializable;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void setup() {
try {
createMainTestFolder(repository.getCompanyHome());
} catch (FileExistsException e) {
logger.warn("Test folder already created. Skipping (" + e.getMessage() + ")");
logger.warn("Test folder already created. Skipping", e);
}
createUserAndGroupsWithLimitedRights();

Expand All @@ -90,7 +91,7 @@ public void setup() {
alfNodeService.setProperty(nodeForbidden, PROP_QNAME_VERSION_LABEL, PROPERTY_VALUE);

} catch (FileExistsException e) {
logger.warn("Test folder already created. Skipping (" + e.getMessage() + ")");
logger.warn("Test folder already created. Skipping", e);
}

try {
Expand All @@ -103,14 +104,13 @@ public void setup() {
alfNodeService.setProperty(nodeAllowed, PROP_QNAME_VERSION_LABEL, PROPERTY_VALUE);

} catch (FileExistsException e) {
logger.warn("Test folder already created. Skipping (" + e.getMessage() + ")");
logger.warn("Test folder already created. Skipping", e);
}
}

@After
public void teardown() {
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
alfPersonService.deletePerson(USERNAME_NORIGHTS_JOS);
cleanUp();
}

Expand All @@ -126,15 +126,15 @@ private void createUserAndGroupsWithLimitedRights() {
alfPersonService.createPerson(userProperties);
logger.info("User " + USERNAME_NORIGHTS_JOS + " successfully created");
} catch (AuthenticationException e) {
logger.warn("User already created. Skipping (" + e.getMessage() + ")");
logger.warn("User already created. Skipping", e);
}

try {
alfAuthorityService.createAuthority(AuthorityType.GROUP, GROUPNAME);
alfAuthorityService.addAuthority(GROUPID, USERNAME_NORIGHTS_JOS);
logger.info("Group " + GROUPNAME + " successfully created");
} catch (DuplicateChildNodeNameException e) {
logger.warn("Group already created. Skipping (" + e.getMessage() + ")");
logger.warn("Group already created. Skipping", e);
}
}

Expand All @@ -145,16 +145,15 @@ public void testSearch() {

SearchQuery query = new SearchQuery();
query.setQuery(new QueryBuilder()
.startAnd()
.term("path", "/app:company_home/cm:" + mainTestFolderName + "//*") // x2 slash means: recurse
.term("type", "cm:content")
.end()
.property(PROP_QNAME_VERSION_LABEL.toString(), PROPERTY_VALUE, true)
.create());
query.setConsistency(SearchQueryConsistency.TRANSACTIONAL);
SearchQueryResult result = apixSearchService.query(query);

Assert.assertEquals(1, result.totalResultCount);
Assert.assertEquals(nodeAllowed.toString(), result.getNoderefs().get(0));
}


@Test
public void testGetNodeMetadata() {
// Switch to non-admin user
Expand All @@ -172,5 +171,4 @@ public void testGetNodeMetadata() {
}
}


}

0 comments on commit 61d1750

Please sign in to comment.