Search in sources :

Example 1 with FileDumpReader

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());
    });
}
Also used : DumpMeta(com.enonic.xp.repo.impl.dump.model.DumpMeta) UpgradeListener(com.enonic.xp.upgrade.UpgradeListener) Version(com.enonic.xp.util.Version) NodeVersion(com.enonic.xp.node.NodeVersion) SystemDumpUpgradeParams(com.enonic.xp.dump.SystemDumpUpgradeParams) DumpUpgradeResult(com.enonic.xp.dump.DumpUpgradeResult) FileDumpReader(com.enonic.xp.repo.impl.dump.reader.FileDumpReader) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Example 2 with FileDumpReader

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);
        });
    });
}
Also used : DumpMeta(com.enonic.xp.repo.impl.dump.model.DumpMeta) NodeVersionId(com.enonic.xp.node.NodeVersionId) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) NodePath(com.enonic.xp.node.NodePath) FileDumpReader(com.enonic.xp.repo.impl.dump.reader.FileDumpReader) Test(org.junit.jupiter.api.Test) AbstractNodeTest(com.enonic.xp.repo.impl.node.AbstractNodeTest)

Aggregations

DumpMeta (com.enonic.xp.repo.impl.dump.model.DumpMeta)2 FileDumpReader (com.enonic.xp.repo.impl.dump.reader.FileDumpReader)2 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)2 Test (org.junit.jupiter.api.Test)2 DumpUpgradeResult (com.enonic.xp.dump.DumpUpgradeResult)1 SystemDumpUpgradeParams (com.enonic.xp.dump.SystemDumpUpgradeParams)1 Node (com.enonic.xp.node.Node)1 NodeId (com.enonic.xp.node.NodeId)1 NodePath (com.enonic.xp.node.NodePath)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 NodeVersionId (com.enonic.xp.node.NodeVersionId)1 UpgradeListener (com.enonic.xp.upgrade.UpgradeListener)1 Version (com.enonic.xp.util.Version)1