use of com.enonic.xp.repo.impl.dump.reader.FileDumpReader in project xp by enonic.
the class DumpServiceImplTest method upgrade.
@Test
public void upgrade() throws Exception {
final String dumpName = "testDump";
createIncompatibleDump(dumpName);
NodeHelper.runAsAdmin(() -> {
final UpgradeListener upgradeListener = mock(UpgradeListener.class);
final SystemDumpUpgradeParams params = SystemDumpUpgradeParams.create().dumpName(dumpName).upgradeListener(upgradeListener).build();
final DumpUpgradeResult result = this.dumpService.upgrade(params);
assertEquals(new Version(0, 0, 0), result.getInitialVersion());
assertEquals(DumpConstants.MODEL_VERSION, result.getUpgradedVersion());
Mockito.verify(upgradeListener, Mockito.times(8)).upgraded();
Mockito.verify(upgradeListener, Mockito.times(1)).total(8);
FileDumpReader reader = FileDumpReader.create(null, temporaryFolder, dumpName);
final DumpMeta updatedMeta = reader.getDumpMeta();
assertEquals(DumpConstants.MODEL_VERSION, updatedMeta.getModelVersion());
});
}
use of com.enonic.xp.repo.impl.dump.reader.FileDumpReader in project xp by enonic.
the class DumpServiceImplTest method loadWithUpgrade.
@Test
public void loadWithUpgrade() throws Exception {
final String dumpName = "testDump";
createIncompatibleDump(dumpName);
NodeHelper.runAsAdmin(() -> {
this.dumpService.load(SystemLoadParams.create().dumpName(dumpName).upgrade(true).includeVersions(true).build());
FileDumpReader reader = FileDumpReader.create(null, temporaryFolder, dumpName);
final DumpMeta updatedMeta = reader.getDumpMeta();
assertEquals(DumpConstants.MODEL_VERSION, updatedMeta.getModelVersion());
final NodeId nodeId = NodeId.from("f0fb822c-092d-41f9-a961-f3811d81e55a");
final NodeId fragmentNodeId = NodeId.from("7ee16649-85c6-4a76-8788-74be03be6c7a");
final NodeId postNodeId = NodeId.from("1f798176-5868-411b-8093-242820c20620");
final NodePath nodePath = NodePath.create("/content/mysite").build();
final NodeVersionId draftNodeVersionId = NodeVersionId.from("f3765655d5f0c7c723887071b517808dae00556c");
final NodeVersionId masterNodeVersionId = NodeVersionId.from("02e61f29a57309834d96bbf7838207ac456bbf5c");
ContextBuilder.from(ContextAccessor.current()).repositoryId("com.enonic.cms.default").build().runWith(() -> {
final Node draftNode = nodeService.getById(nodeId);
assertNotNull(draftNode);
assertEquals(draftNodeVersionId, draftNode.getNodeVersionId());
assertEquals(nodePath, draftNode.path());
assertEquals("2019-02-20T14:44:06.883Z", draftNode.getTimestamp().toString());
final Node masterNode = ContextBuilder.from(ContextAccessor.current()).branch(Branch.from("master")).build().callWith(() -> nodeService.getById(nodeId));
assertNotNull(masterNode);
assertEquals(masterNodeVersionId, masterNode.getNodeVersionId());
assertEquals(nodePath, masterNode.path());
assertEquals("2018-11-23T11:14:21.662Z", masterNode.getTimestamp().toString());
checkCommitUpgrade(nodeId);
checkPageFlatteningUpgradePage(draftNode);
final Node fragmentNode = nodeService.getById(fragmentNodeId);
checkPageFlatteningUpgradeFragment(fragmentNode);
checkRepositoryUpgrade(updatedMeta);
final Node postNode = nodeService.getById(postNodeId);
checkHtmlAreaUpgrade(draftNode, postNode);
checkLanguageUpgrade(draftNode);
});
});
}
Aggregations