Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
…-hook into develop
  • Loading branch information
nc-andreashaller committed Jul 19, 2019
2 parents 9639524 + 2b2f5f8 commit 9bbda8a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected void loadInfos(final InstallContext ctx) throws RepositoryException {
@Override
public int compare(UpgradeInfo info1, UpgradeInfo info2) {
try {
return info1.getNode().getName().compareTo(info1.getNode().getName());
return info1.getNode().getName().compareTo(info2.getNode().getName());
} catch (RepositoryException e) {
LOG.warn(ctx, "Could not compare upgrade infos [{}/{}]", info1.getNode(), info2.getNode(), e);
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
package biz.netcentric.vlt.upgrade;

import static org.mockito.Mockito.*;

import java.util.Arrays;
import java.util.Collections;

Expand Down Expand Up @@ -146,6 +148,29 @@ public void testException() throws Exception {
processor.execute(ctx);
}

@Test
public void testOrderedExecution() throws Exception {
Mockito.when(ctx.getPhase()).thenReturn(Phase.PREPARE);
Mockito.when(ctx.getPackage().getId().getName()).thenReturn("testVaultPackage");
Mockito.when(ctx.getPackage().getId().getGroup()).thenReturn("testVaultGroup");
Mockito.when(ctx.getPackage().getId().getInstallationPath()).thenReturn("/test/installation/path");
Mockito.when(ctx.getPackage().getId().getVersionString()).thenReturn("1.0.1-SNAPSHOT");

sling.build().resource(
"/test/installation/path.zip/jcr:content/vlt:definition/upgrader/second", //
"handler", "biz.netcentric.vlt.upgrade.UpgradeProcessorTest$TestHandler" //
);
sling.build().resource(
"/test/installation/path.zip/jcr:content/vlt:definition/upgrader/first", //
"handler", "biz.netcentric.vlt.upgrade.UpgradeProcessorTest$TestHandler" //
);

processor.execute(ctx);

Assert.assertEquals(2, processor.infos.size());
Assert.assertEquals("first", processor.infos.get(0).getNode().getName());
}

@Test(expected = PackageException.class)
public void testActionException() throws Exception {
processor.infos = Arrays.asList(info);
Expand Down

0 comments on commit 9bbda8a

Please sign in to comment.