Search in sources :

Example 1 with UpdateRepositoryEntryParams

use of com.enonic.xp.repo.impl.repository.UpdateRepositoryEntryParams in project xp by enonic.

the class DumpServiceImplTest method dumpAndLoadWithAttachments.

@Test
public void dumpAndLoadWithAttachments() throws Exception {
    NodeHelper.runAsAdmin(() -> {
        final Repository newRepo = NodeHelper.runAsAdmin(() -> doCreateRepository(RepositoryId.from("new-repo"), AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allowAll().build()).build(), ChildOrder.manualOrder()));
        final PropertyTree data = new PropertyTree();
        data.addBinaryReference("attachmentName", BinaryReference.from("image.png"));
        final UpdateRepositoryEntryParams updateParams = UpdateRepositoryEntryParams.create().repositoryId(newRepo.getId()).repositoryData(data).attachments(ImmutableList.of(new BinaryAttachment(BinaryReference.from("image.png"), ByteSource.wrap("attachmentName".getBytes())))).build();
        repositoryEntryService.updateRepositoryEntry(updateParams);
    });
    NodeHelper.runAsAdmin(() -> this.dumpService.dump(SystemDumpParams.create().dumpName("testDump").build()));
    NodeHelper.runAsAdmin(() -> {
        dumpDeleteAndLoad(true);
        final AttachedBinaries attachedBinaries = repositoryEntryService.getRepositoryEntry(RepositoryId.from("new-repo")).getAttachments();
        assertEquals(1, attachedBinaries.getSize());
        assertNotNull(attachedBinaries.getByBinaryReference(BinaryReference.from("image.png")));
    });
}
Also used : Repository(com.enonic.xp.repository.Repository) PropertyTree(com.enonic.xp.data.PropertyTree) AttachedBinaries(com.enonic.xp.node.AttachedBinaries) BinaryAttachment(com.enonic.xp.node.BinaryAttachment) UpdateRepositoryEntryParams(com.enonic.xp.repo.impl.repository.UpdateRepositoryEntryParams) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)1 AttachedBinaries (com.enonic.xp.node.AttachedBinaries)1 BinaryAttachment (com.enonic.xp.node.BinaryAttachment)1 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)1 UpdateRepositoryEntryParams (com.enonic.xp.repo.impl.repository.UpdateRepositoryEntryParams)1 Repository (com.enonic.xp.repository.Repository)1 Test (org.junit.jupiter.api.Test)1