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")));
});
}
Aggregations