@Test
  public void testRevertEU() throws Exception {
    ConfigHelper configHelper = createNiceMock(ConfigHelper.class);
    UpgradeHelper upgradeHelper = createNiceMock(UpgradeHelper.class);
    UpgradePack upgradePack = createNiceMock(UpgradePack.class);
    AmbariMetaInfo ami = createNiceMock(AmbariMetaInfo.class);

    Map<String, UpgradePack> map = ImmutableMap.<String, UpgradePack>builder()
        .put("myUpgradePack", upgradePack)
        .build();

    expect(ami.getUpgradePacks(EasyMock.anyString(), EasyMock.anyString())).andReturn(map).anyTimes();

    expect(m_upgradeDAO.findRevertable(1L)).andReturn(m_completedRevertableUpgrade).once();
    expect(m_completedRevertableUpgrade.getUpgradeType()).andReturn(UpgradeType.NON_ROLLING);

    Map<String, Object> requestMap = new HashMap<>();
    requestMap.put(UpgradeResourceProvider.UPGRADE_REVERT_UPGRADE_ID, "1");

    replayAll();

    UpgradeContext context = new UpgradeContext(m_cluster, requestMap, null, upgradeHelper,
      m_upgradeDAO, m_repositoryVersionDAO, configHelper, ami);

    assertEquals(Direction.DOWNGRADE, context.getDirection());
    assertEquals(RepositoryType.PATCH, context.getOrchestrationType());
    assertEquals(UpgradeType.NON_ROLLING, context.getType());
    assertEquals(1, context.getSupportedServices().size());
    assertTrue(context.isPatchRevert());

    verifyAll();
  }
Tests that the {@link UpgradeContext} for a EU reversion has the correct
parameters set.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/stack/upgrade/orchestrate/UpgradeContextTest.java