// Path: vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/UpgradeInfo.java
// public enum InstallationMode {
//     /**
//      * Run all new or changed actions.
//      */
//     ON_CHANGE,
// 
//     /**
//      * Completely disregarding previous executions.
//      */
//     ALWAYS
// }
// 
// Path: vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/UpgradeHandler.java
// public interface UpgradeHandler {
// 
//     /**
//      * Is called to check if all requirements are met to create and run
//      * {@link UpgradeAction}s provided by this handler.
//      * 
//      * @return
//      */
//     boolean isAvailable(InstallContext ctx);
// 
//     /**
//      * Called by {@link UpgradeInfo} to get the {@link UpgradeAction}s which are
//      * configured in the content package.
//      * 
//      * @param ctx
//      * @param info
//      * @return
//      * @throws RepositoryException
//      */
//     Iterable<UpgradeAction> create(InstallContext ctx, UpgradeInfo info) throws RepositoryException;
// 
// }


import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collections;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.vault.fs.io.ImportOptions;
import org.apache.jackrabbit.vault.packaging.InstallContext;
import org.apache.jackrabbit.vault.packaging.InstallContext.Phase;
import org.apache.jackrabbit.vault.packaging.PackageException;
import org.apache.jackrabbit.vault.packaging.VaultPackage;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import biz.netcentric.vlt.upgrade.UpgradeInfo.InstallationMode;
import biz.netcentric.vlt.upgrade.handler.UpgradeHandler;
/*
 * (C) Copyright 2016 Netcentric AG.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package biz.netcentric.vlt.upgrade;






@RunWith(MockitoJUnitRunner.class)
public class UpgradeProcessorTest {

    @Rule
    public final SlingContext sling = new SlingContext(ResourceResolverType.JCR_MOCK);

    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
    private InstallContext ctx;

    @Mock
    private VaultPackage vaultPackage;

    @Mock
    private UpgradeInfo info;

    @Mock
    private UpgradeAction action;

    @Mock
    private UpgradeStatus status;

    private UpgradeProcessor processor;

    @Before
    public void setup() throws Exception {
        processor = new UpgradeProcessor();
        Mockito.when(ctx.getOptions()).thenReturn(Mockito.mock(ImportOptions.class));
        Mockito.when(ctx.getSession()).thenReturn(sling.resourceResolver().adaptTo(Session.class));
        Mockito.when(status.getNode()).thenReturn(Mockito.mock(Node.class));
        Mockito.when(info.getNode()).thenReturn(Mockito.mock(Node.class));
// Path: vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/UpgradeInfo.java
// public enum InstallationMode {
//     /**
//      * Run all new or changed actions.
//      */
//     ON_CHANGE,
// 
//     /**
//      * Completely disregarding previous executions.
//      */
//     ALWAYS
// }
// 
// Path: vault-upgrade-hook/src/main/java/biz/netcentric/vlt/upgrade/handler/UpgradeHandler.java
// public interface UpgradeHandler {
// 
//     /**
//      * Is called to check if all requirements are met to create and run
//      * {@link UpgradeAction}s provided by this handler.
//      * 
//      * @return
//      */
//     boolean isAvailable(InstallContext ctx);
// 
//     /**
//      * Called by {@link UpgradeInfo} to get the {@link UpgradeAction}s which are
//      * configured in the content package.
//      * 
//      * @param ctx
//      * @param info
//      * @return
//      * @throws RepositoryException
//      */
//     Iterable<UpgradeAction> create(InstallContext ctx, UpgradeInfo info) throws RepositoryException;
// 
// }


// Path: vault-upgrade-hook/src/test/java/biz/netcentric/vlt/upgrade/UpgradeProcessorTest.java
import static org.mockito.Mockito.*;
import java.util.Arrays;
import java.util.Collections;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.vault.fs.io.ImportOptions;
import org.apache.jackrabbit.vault.packaging.InstallContext;
import org.apache.jackrabbit.vault.packaging.InstallContext.Phase;
import org.apache.jackrabbit.vault.packaging.PackageException;
import org.apache.jackrabbit.vault.packaging.VaultPackage;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import biz.netcentric.vlt.upgrade.UpgradeInfo.InstallationMode;
import biz.netcentric.vlt.upgrade.handler.UpgradeHandler;

/*
 * (C) Copyright 2016 Netcentric AG.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package biz.netcentric.vlt.upgrade;






@RunWith(MockitoJUnitRunner.class)
public class UpgradeProcessorTest {

    @Rule
    public final SlingContext sling = new SlingContext(ResourceResolverType.JCR_MOCK);

    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
    private InstallContext ctx;

    @Mock
    private VaultPackage vaultPackage;

    @Mock
    private UpgradeInfo info;

    @Mock
    private UpgradeAction action;

    @Mock
    private UpgradeStatus status;

    private UpgradeProcessor processor;

    @Before
    public void setup() throws Exception {
        processor = new UpgradeProcessor();
        Mockito.when(ctx.getOptions()).thenReturn(Mockito.mock(ImportOptions.class));
        Mockito.when(ctx.getSession()).thenReturn(sling.resourceResolver().adaptTo(Session.class));
        Mockito.when(status.getNode()).thenReturn(Mockito.mock(Node.class));
        Mockito.when(info.getNode()).thenReturn(Mockito.mock(Node.class));
        Mockito.when(info.getHandler()).thenReturn(Mockito.mock(UpgradeHandler.class));