mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
[APPS-3242] Fix for facet query for elasticsearch (#3260)
Co-authored-by: mohit-singh4 <mohit.singh@contractors.hyland.com>
This commit is contained in:
@@ -96,6 +96,45 @@ public class NodeSizeDetailsTests extends RestTest
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* calculateNodeSizeForEmptyFolder testcase
|
||||
*/
|
||||
@TestRail(section = {TestGroup.REST_API, TestGroup.NODES}, executionType = ExecutionType.SANITY)
|
||||
@Test(groups = {TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY})
|
||||
public void calculateNodeSizeForEmptyFolder() throws Exception
|
||||
{
|
||||
|
||||
STEP("1. Create a folder in the test site.");
|
||||
folder = dataContent.usingUser(user1).usingSite(siteModel).createFolder(FolderModel.getRandomFolderModel());
|
||||
|
||||
RestSizeDetailsModel restSizeDetailsModel = restClient.authenticateUser(user1).withCoreAPI().usingNode(folder).executeSizeDetails();
|
||||
restClient.assertStatusCodeIs(HttpStatus.ACCEPTED);
|
||||
restSizeDetailsModel.assertThat().field("jobId").isNotEmpty();
|
||||
|
||||
jobId = restSizeDetailsModel.getJobId();
|
||||
|
||||
STEP("2. Wait for 5 seconds for the processing to complete.");
|
||||
Awaitility
|
||||
.await()
|
||||
.atMost(Duration.ofSeconds(5))
|
||||
.pollInterval(Durations.ONE_SECOND)
|
||||
.ignoreExceptions()
|
||||
.untilAsserted(() -> {
|
||||
RestSizeDetailsModel sizeDetailsModel = restClient.authenticateUser(user1)
|
||||
.withCoreAPI()
|
||||
.usingNode(folder)
|
||||
.getSizeDetails(jobId);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
sizeDetailsModel.assertThat()
|
||||
.field("sizeInBytes")
|
||||
.isNotEmpty();
|
||||
Assert.assertEquals(sizeDetailsModel.getSizeInBytes(), 0,
|
||||
"Value of sizeInBytes should be 0 " + sizeDetailsModel.getSizeInBytes());
|
||||
Assert.assertEquals(sizeDetailsModel.getStatus().name(), "COMPLETED",
|
||||
"Status should be - COMPLETED" + sizeDetailsModel.getStatus().name());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* checkJobIdPresentInCache testcase
|
||||
*/
|
||||
|
@@ -58,6 +58,7 @@ public class NodeSizeDetailsServiceImpl implements NodeSizeDetailsService, Initi
|
||||
private static final Logger LOG = LoggerFactory.getLogger(NodeSizeDetailsServiceImpl.class);
|
||||
private static final String FIELD_FACET = "content.size";
|
||||
private static final String FACET_QUERY = "{!afts}content.size:[0 TO " + Integer.MAX_VALUE + "]";
|
||||
private static final int DEFAULT_FACET_LIMIT = 100;
|
||||
private SearchService searchService;
|
||||
private SimpleCache<Serializable, NodeSizeDetails> simpleCache;
|
||||
private TransactionService transactionService;
|
||||
@@ -214,7 +215,11 @@ public class NodeSizeDetailsServiceImpl implements NodeSizeDetailsService, Initi
|
||||
}
|
||||
searchParameters.addFacetQuery(FACET_QUERY);
|
||||
FieldFacet fieldFacet = new FieldFacet(FIELD_FACET);
|
||||
fieldFacet.setLimitOrNull((int) resultsWithoutFacet.getNumberFound());
|
||||
int numberFound = Optional.ofNullable(resultsWithoutFacet.getNumberFound())
|
||||
.map(Long::intValue)
|
||||
.filter(n -> n > 0)
|
||||
.orElse(DEFAULT_FACET_LIMIT);
|
||||
fieldFacet.setLimitOrNull(numberFound);
|
||||
searchParameters.addFieldFacet(fieldFacet);
|
||||
resultsWithoutFacet.close();
|
||||
return searchService.query(searchParameters);
|
||||
|
Reference in New Issue
Block a user