@Test public void testBuildOrder() throws Exception { Cluster cluster = createNiceMock(Cluster.class); EasyMock.expect(cluster.getCurrentStackVersion()).andReturn(HDP_21).atLeastOnce(); EasyMock.expect(cluster.getDesiredStackVersion()).andReturn(HDP_21).anyTimes(); RepositoryVersionEntity repoVersionEntity = createNiceMock(RepositoryVersionEntity.class); EasyMock.expect(repoVersionEntity.getStackId()).andReturn(HDP_21).anyTimes(); RepositoryVersionDAO repoVersionDAO = createNiceMock(RepositoryVersionDAO.class); EasyMock.expect(repoVersionDAO.findByStackNameAndVersion(EasyMock.anyString(), EasyMock.anyString())).andReturn(repoVersionEntity).anyTimes(); replayAll(); UpgradeContext upgradeContext = new UpgradeContext(cluster, UpgradeType.ROLLING, Direction.UPGRADE, HDP_21.toString(), new HashMap<String, Object>(), repoVersionDAO); MockStageWrapperBuilder builder = new MockStageWrapperBuilder(null); List<StageWrapper> stageWrappers = builder.build(upgradeContext); List<Integer> invocationOrder = builder.getInvocationOrder(); Assert.assertEquals(Integer.valueOf(0), invocationOrder.get(0)); Assert.assertEquals(Integer.valueOf(1), invocationOrder.get(1)); Assert.assertEquals(Integer.valueOf(2), invocationOrder.get(2)); Assert.assertTrue(stageWrappers.isEmpty()); verifyAll(); }
public final List<StageWrapper> build(UpgradeContext upgradeContext) { List<StageWrapper> stageWrappers = beforeBuild(upgradeContext); stageWrappers = build(upgradeContext, stageWrappers); stageWrappers = afterBuild(upgradeContext, stageWrappers); return stageWrappers; }
StageWrapperBuilder { public final List<StageWrapper> build(UpgradeContext upgradeContext) { List<StageWrapper> stageWrappers = beforeBuild(upgradeContext); stageWrappers = build(upgradeContext, stageWrappers); stageWrappers = afterBuild(upgradeContext, stageWrappers); return stageWrappers; } }
StageWrapperBuilder { public final List<StageWrapper> build(UpgradeContext upgradeContext) { List<StageWrapper> stageWrappers = beforeBuild(upgradeContext); stageWrappers = build(upgradeContext, stageWrappers); stageWrappers = afterBuild(upgradeContext, stageWrappers); return stageWrappers; } protected  StageWrapperBuilder(Grouping grouping); }
StageWrapperBuilder { public final List<StageWrapper> build(UpgradeContext upgradeContext) { List<StageWrapper> stageWrappers = beforeBuild(upgradeContext); stageWrappers = build(upgradeContext, stageWrappers); stageWrappers = afterBuild(upgradeContext, stageWrappers); return stageWrappers; } protected  StageWrapperBuilder(Grouping grouping); abstract void add(UpgradeContext upgradeContext, HostsType hostsType, String service,
      boolean clientOnly, ProcessingComponent pc, Map<String, String> params); final List<StageWrapper> build(UpgradeContext upgradeContext); abstract List<StageWrapper> build(UpgradeContext upgradeContext,
      List<StageWrapper> stageWrappers); }
StageWrapperBuilder { public final List<StageWrapper> build(UpgradeContext upgradeContext) { List<StageWrapper> stageWrappers = beforeBuild(upgradeContext); stageWrappers = build(upgradeContext, stageWrappers); stageWrappers = afterBuild(upgradeContext, stageWrappers); return stageWrappers; } protected  StageWrapperBuilder(Grouping grouping); abstract void add(UpgradeContext upgradeContext, HostsType hostsType, String service,
      boolean clientOnly, ProcessingComponent pc, Map<String, String> params); final List<StageWrapper> build(UpgradeContext upgradeContext); abstract List<StageWrapper> build(UpgradeContext upgradeContext,
      List<StageWrapper> stageWrappers);  }