Search in sources :

Example 86 with PropertyTree

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

the class RangeQueryBuilderTest method test.

private void test(final String fileName) throws Exception {
    final String queryString = load("range/query/" + fileName + ".json");
    final PropertyTree dslExpression = readJson(queryString);
    final QueryBuilder builder = new RangeQueryBuilder(dslExpression.getSet("range")).create();
    assertJson("range/result/" + fileName + ".json", builder.toString());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) QueryBuilder(org.elasticsearch.index.query.QueryBuilder)

Example 87 with PropertyTree

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

the class RepositoryServiceImplTest method update_data.

@Test
void update_data() {
    final String repoId = "repo-with-data";
    doCreateRepo(repoId);
    Context mockCurrentContext = ContextBuilder.create().branch("master").repositoryId(repoId).authInfo(REPO_TEST_DEFAULT_USER_AUTHINFO).build();
    PropertyTree data = new PropertyTree();
    data.setString("myProp", "b");
    mockCurrentContext.callWith(() -> repositoryService.updateRepository(UpdateRepositoryParams.create().repositoryId(RepositoryId.from(repoId)).editor(edit -> edit.data = data).build()));
    final Repository persistedRepo = getPersistedRepoWithoutCache(repoId);
    assertEquals("b", persistedRepo.getData().getString("myProp"));
}
Also used : Context(com.enonic.xp.context.Context) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) IdProviderKey(com.enonic.xp.security.IdProviderKey) CreateNodeParams(com.enonic.xp.node.CreateNodeParams) DeleteRepositoryParams(com.enonic.xp.repository.DeleteRepositoryParams) Node(com.enonic.xp.node.Node) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Branch(com.enonic.xp.branch.Branch) NodeHelper(com.enonic.xp.repo.impl.node.NodeHelper) RepositoryId(com.enonic.xp.repository.RepositoryId) ImmutableList(com.google.common.collect.ImmutableList) CreateBranchParams(com.enonic.xp.repository.CreateBranchParams) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ContextAccessor(com.enonic.xp.context.ContextAccessor) ContextBuilder(com.enonic.xp.context.ContextBuilder) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ByteSource(com.google.common.io.ByteSource) SystemConstants(com.enonic.xp.security.SystemConstants) PropertyTree(com.enonic.xp.data.PropertyTree) BinaryReference(com.enonic.xp.util.BinaryReference) DeleteBranchParams(com.enonic.xp.repository.DeleteBranchParams) User(com.enonic.xp.security.User) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) NodePath(com.enonic.xp.node.NodePath) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) AccessControlList(com.enonic.xp.security.acl.AccessControlList) CreateRepositoryParams(com.enonic.xp.repository.CreateRepositoryParams) UpdateRepositoryParams(com.enonic.xp.repository.UpdateRepositoryParams) Test(org.junit.jupiter.api.Test) PrincipalKey(com.enonic.xp.security.PrincipalKey) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) RoleKeys(com.enonic.xp.security.RoleKeys) Context(com.enonic.xp.context.Context) Assertions.assertDoesNotThrow(org.junit.jupiter.api.Assertions.assertDoesNotThrow) AccessControlEntry(com.enonic.xp.security.acl.AccessControlEntry) Repository(com.enonic.xp.repository.Repository) Repository(com.enonic.xp.repository.Repository) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 88 with PropertyTree

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

the class ValueCountAggregationTest method createNode.

private Node createNode(final String categoryValue, final String name, final NodePath parent) {
    final PropertyTree data = new PropertyTree();
    data.addString("category", categoryValue);
    return createNode(CreateNodeParams.create().parent(parent).name(name).data(data).build());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree)

Example 89 with PropertyTree

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

the class RepositoryNodeTranslatorTest method values_not_duplicated.

@Test
public void values_not_duplicated() throws Exception {
    final PropertyTree indexMapping = new PropertyTree();
    indexMapping.addString("myMapping", "myMappingValue");
    final PropertyTree indexSettings = new PropertyTree();
    indexSettings.addString("mySetting", "mySettingValue");
    final Repository repo = Repository.create().branches(Branch.from("master")).id(RepositoryId.from("myrepoid")).settings(RepositorySettings.create().indexDefinitions(IndexDefinitions.create().add(IndexType.VERSION, IndexDefinition.create().mapping(IndexMapping.from(indexMapping)).settings(IndexSettings.from(indexSettings)).build()).add(IndexType.BRANCH, IndexDefinition.create().mapping(IndexMapping.from(indexMapping)).settings(IndexSettings.from(indexSettings)).build()).add(IndexType.COMMIT, IndexDefinition.create().mapping(IndexMapping.from(indexMapping)).settings(IndexSettings.from(indexSettings)).build()).build()).build()).build();
    final Node node = RepositoryNodeTranslator.toNode(repo);
    final PropertyTree data = node.data();
    assertNotNull(data.getProperty("indexConfigs.version.mapping.myMapping"));
    assertNull(data.getProperty("indexConfigs.version.mapping.myMapping[1]"));
    assertNotNull(data.getProperty("indexConfigs.version.settings.mySetting"));
    assertNull(data.getProperty("indexConfigs.version.settings.mySetting[1]"));
    assertNotNull(data.getProperty("indexConfigs.branch.mapping.myMapping"));
    assertNull(data.getProperty("indexConfigs.branch.mapping.myMapping[1]"));
    assertNotNull(data.getProperty("indexConfigs.branch.settings.mySetting"));
    assertNull(data.getProperty("indexConfigs.branch.settings.mySetting[1]"));
}
Also used : Repository(com.enonic.xp.repository.Repository) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 90 with PropertyTree

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

the class DateRangeAggregationTest method createNode.

private Node createNode(final Instant instantValue, final String name, final NodePath parent) {
    final PropertyTree data = new PropertyTree();
    data.addInstant("instant", instantValue);
    return createNode(CreateNodeParams.create().parent(parent).name(name).data(data).build());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree)

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)660 Test (org.junit.jupiter.api.Test)405 PropertySet (com.enonic.xp.data.PropertySet)150 Content (com.enonic.xp.content.Content)126 Node (com.enonic.xp.node.Node)112 CreateContentParams (com.enonic.xp.content.CreateContentParams)64 Form (com.enonic.xp.form.Form)37 Page (com.enonic.xp.page.Page)32 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)31 DescriptorKey (com.enonic.xp.page.DescriptorKey)30 GetContentTypeParams (com.enonic.xp.schema.content.GetContentTypeParams)30 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)28 PrincipalKey (com.enonic.xp.security.PrincipalKey)28 BinaryReference (com.enonic.xp.util.BinaryReference)28 Property (com.enonic.xp.data.Property)26 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)24 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)23 ByteSource (com.google.common.io.ByteSource)22 ExtraData (com.enonic.xp.content.ExtraData)21 Instant (java.time.Instant)21