use of com.enonic.xp.content.FindContentByQueryResult in project xp by enonic.
the class ContentServiceImplTest_find method test_publish_expired_master.
@Test
public void test_publish_expired_master() throws Exception {
authorizedMasterContext().callWith(() -> {
final FindContentByQueryResult result = createAndFindContent(ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().minus(Duration.ofDays(1))).build());
assertEquals(0, result.getTotalHits());
return null;
});
}
use of com.enonic.xp.content.FindContentByQueryResult in project xp by enonic.
the class ContentServiceImplTest_find method test_publish_expired_draft.
@Test
public void test_publish_expired_draft() throws Exception {
final FindContentByQueryResult result = createAndFindContent(ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().minus(Duration.ofDays(1))).build());
assertEquals(1, result.getTotalHits());
}
use of com.enonic.xp.content.FindContentByQueryResult in project xp by enonic.
the class ContentServiceImplTest_find method test_published_master.
@Test
public void test_published_master() throws Exception {
authorizedMasterContext().callWith(() -> {
final FindContentByQueryResult result = createAndFindContent(ContentPublishInfo.create().from(Instant.now().minus(Duration.ofDays(1))).to(Instant.now().plus(Duration.ofDays(1))).build());
assertEquals(1, result.getTotalHits());
return null;
});
}
use of com.enonic.xp.content.FindContentByQueryResult in project xp by enonic.
the class CheckContentValidityCommand method execute.
public ContentValidityResult execute() {
if (this.contentIds.getSize() == 0) {
return ContentValidityResult.empty();
}
// valid == false
final Filter notValid = ValueFilter.create().fieldName(ContentPropertyNames.VALID).addValue(ValueFactory.newBoolean(false)).build();
// workflow != null && workflow != READY
final Filter notReady = BooleanFilter.create().must(ExistsFilter.create().fieldName(WORKFLOW_STATE_FIELD).build()).mustNot(ValueFilter.create().fieldName(WORKFLOW_STATE_FIELD).addValues(WorkflowState.READY.toString()).build()).build();
// valid == false OR (workflow != null && workflow != READY)
final Filter filter = BooleanFilter.create().should(notValid).should(notReady).build();
final ContentQuery query = ContentQuery.create().queryFilter(filter).queryFilter(IdFilter.create().fieldName(ContentIndexPath.ID.getPath()).values(contentIds.asStrings()).build()).size(-1).build();
final FindContentByQueryResult result = FindContentByQueryCommand.create().params(FindContentByQueryParams.create().contentQuery(query).populateChildren(false).build()).contentTypeService(this.contentTypeService).eventPublisher(this.eventPublisher).nodeService(this.nodeService).translator(this.translator).build().execute();
ContentIds.Builder invalidContentIds = ContentIds.create();
ContentIds.Builder notReadyContentIds = ContentIds.create();
result.getContents().forEach(content -> {
if (!content.isValid()) {
invalidContentIds.add(content.getId());
}
if (!content.getWorkflowInfo().getState().equals(WorkflowState.READY)) {
notReadyContentIds.add(content.getId());
}
});
return ContentValidityResult.create().notValidContentIds(invalidContentIds.build()).notReadyContentIds(notReadyContentIds.build()).build();
}
use of com.enonic.xp.content.FindContentByQueryResult in project xp by enonic.
the class ContentServiceImplTest_selectorSearch method same_site_first.
// Implement path search match first
@Disabled
@Test
public void same_site_first() throws Exception {
final Content site1 = createContent(ContentPath.ROOT, "site1");
final Content site2 = createContent(ContentPath.ROOT, "site2");
final Content third = createContent(site1.getPath(), "Fisk ost");
final Content second = createContent(site2.getPath(), "Fisk ost");
final FunctionExpr fulltext = FunctionExpr.from("fulltext", ValueExpr.string("displayName"), ValueExpr.string("ost"));
final OrderExpr order = FieldOrderExpr.create(IndexPath.from("_score"), OrderExpr.Direction.DESC);
final ContentQuery query = ContentQuery.create().queryExpr(QueryExpr.from(new DynamicConstraintExpr(fulltext), order)).build();
final FindContentByQueryResult result = contentService.find(FindContentByQueryParams.create().contentQuery(query).build());
assertOrder(result, second, third);
}
Aggregations