Search in sources :

Example 91 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class PropertyTreeMapperTest method map_in_map.

@Test
public void map_in_map() throws Exception {
    final PropertyTree properties = new PropertyTree();
    final PropertySet mySet = properties.addSet("mySet");
    mySet.setString("mySetValue", "value");
    final PropertySet mySetInSet = mySet.addSet("mySetInSet");
    mySetInSet.setString("mySetValue", "value");
    serializeAndAssert("mapper-map-in-map", properties);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 92 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_find method dsl_query_geo_point.

@Test
public void dsl_query_geo_point() throws Exception {
    PropertyTree data = createPropertyTreeForAllInputTypes();
    final Content content = this.contentService.create(CreateContentParams.create().type(ContentTypeName.folder()).contentData(data).name("myContent").parent(ContentPath.ROOT).displayName("my display-name").build());
    final Content child2 = createContent(ContentPath.ROOT, "c");
    final PropertyTree request = new PropertyTree();
    final PropertySet fulltext = request.addSet("term");
    fulltext.addString("field", "data.geoPoint");
    fulltext.addString("value", "59.91273,10.74609");
    final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request))).build();
    assertEquals(1, contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()).getHits());
}
Also used : ContentQuery(com.enonic.xp.content.ContentQuery) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 93 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_find method dsl_query_range.

@Test
public void dsl_query_range() throws Exception {
    final Content site = createContent(ContentPath.ROOT, "a");
    final Content child3 = createContent(site.getPath(), "d");
    final Content child2 = createContent(site.getPath(), "c");
    final Content child1 = createContent(site.getPath(), "b");
    final PropertyTree request = new PropertyTree();
    final PropertySet like = new PropertySet();
    request.addSet("like", like);
    like.addString("field", "_path");
    like.addString("value", "*a/*");
    PropertyTree order = new PropertyTree();
    order.addString("field", "displayName");
    order.addString("direction", "DESC");
    ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request), DslOrderExpr.from(order))).build();
    assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child3, child2, child1);
    order = new PropertyTree();
    order.addString("field", "displayName");
    queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request), DslOrderExpr.from(order))).build();
    assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child1, child2, child3);
}
Also used : ContentQuery(com.enonic.xp.content.ContentQuery) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 94 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_duplicate method data_removed_on_duplicate.

@Test
public void data_removed_on_duplicate() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("rootContent").parent(ContentPath.ROOT).type(ContentTypeName.folder()).permissions(AccessControlList.create().build()).build();
    final Content content = this.contentService.create(createContentParams);
    this.nodeService.update(UpdateNodeParams.create().id(NodeId.from(content.getId())).editor(toBeEdited -> {
        toBeEdited.data.addSet(ContentPropertyNames.PUBLISH_INFO, new PropertySet());
        toBeEdited.data.addString(ContentPropertyNames.ORIGIN_PROJECT, "some-project");
        toBeEdited.data.addStrings(ContentPropertyNames.INHERIT, ContentInheritType.CONTENT.name(), ContentInheritType.NAME.name());
    }).build());
    final Content duplicateContent = doDuplicateContent(content);
    assertNull(duplicateContent.getPublishInfo());
    assertNull(duplicateContent.getOriginProject());
    assertTrue(duplicateContent.getInherit().isEmpty());
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 95 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_duplicate method audit_data.

@Test
public void audit_data() throws Exception {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    final Content rootContent = createContent(ContentPath.ROOT);
    final Content childContent = createContent(rootContent.getPath());
    final Content duplicatedContent = doDuplicateContent(rootContent);
    Mockito.verify(auditLogService, Mockito.timeout(5000).times(3)).log(captor.capture());
    final PropertySet logResultSet = captor.getValue().getData().getSet("result");
    final Iterable<String> ids = logResultSet.getStrings("duplicatedContents");
    assertEquals(2, StreamSupport.stream(ids.spliterator(), false).count());
    assertTrue(StreamSupport.stream(ids.spliterator(), false).anyMatch(id -> id.equals(duplicatedContent.getId().toString())));
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) IdProviderKey(com.enonic.xp.security.IdProviderKey) DuplicateContentParams(com.enonic.xp.content.DuplicateContentParams) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) ContentTypeName(com.enonic.xp.schema.content.ContentTypeName) ArgumentCaptor(org.mockito.ArgumentCaptor) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ContextAccessor(com.enonic.xp.context.ContextAccessor) DuplicateContentsResult(com.enonic.xp.content.DuplicateContentsResult) StreamSupport(java.util.stream.StreamSupport) ContextBuilder(com.enonic.xp.context.ContextBuilder) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) PropertyTree(com.enonic.xp.data.PropertyTree) User(com.enonic.xp.security.User) ContentPropertyNames(com.enonic.xp.content.ContentPropertyNames) ContentPath(com.enonic.xp.content.ContentPath) PropertySet(com.enonic.xp.data.PropertySet) ContentInheritType(com.enonic.xp.content.ContentInheritType) Content(com.enonic.xp.content.Content) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) AccessControlList(com.enonic.xp.security.acl.AccessControlList) NodeId(com.enonic.xp.node.NodeId) UpdateNodeParams(com.enonic.xp.node.UpdateNodeParams) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) PrincipalKey(com.enonic.xp.security.PrincipalKey) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) Content(com.enonic.xp.content.Content) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)209 PropertyTree (com.enonic.xp.data.PropertyTree)134 Test (org.junit.jupiter.api.Test)68 Content (com.enonic.xp.content.Content)29 Node (com.enonic.xp.node.Node)20 CreateContentParams (com.enonic.xp.content.CreateContentParams)12 ContentId (com.enonic.xp.content.ContentId)11 Property (com.enonic.xp.data.Property)11 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)10 PrincipalKey (com.enonic.xp.security.PrincipalKey)9 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 ContentQuery (com.enonic.xp.content.ContentQuery)6 ExtraDatas (com.enonic.xp.content.ExtraDatas)6 Form (com.enonic.xp.form.Form)6 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)6 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)5 ContentPropertyNames (com.enonic.xp.content.ContentPropertyNames)5 ExtraData (com.enonic.xp.content.ExtraData)5 PropertyPath (com.enonic.xp.data.PropertyPath)5 Page (com.enonic.xp.page.Page)5