Repository: ambari Updated Branches: refs/heads/branch-feature-AMBARI-21348 7b8f0eab5 -> 7ad307c2c
http://git-wip-us.apache.org/repos/asf/ambari/blob/7ad307c2/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java index 0eef638..5cef95d 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java @@ -19,7 +19,6 @@ package org.apache.ambari.server.state.stack.upgrade; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; @@ -52,7 +51,7 @@ public class StageWrapperBuilderTest extends EasyMockSupport { @Test public void testBuildOrder() throws Exception { Cluster cluster = createNiceMock(Cluster.class); - EasyMock.expect(cluster.getCurrentStackVersion()).andReturn(HDP_21).atLeastOnce(); + EasyMock.expect(cluster.getCurrentStackVersion()).andReturn(HDP_21).anyTimes(); EasyMock.expect(cluster.getDesiredStackVersion()).andReturn(HDP_21).anyTimes(); RepositoryVersionEntity repoVersionEntity = createNiceMock(RepositoryVersionEntity.class); @@ -62,10 +61,16 @@ public class StageWrapperBuilderTest extends EasyMockSupport { EasyMock.expect(repoVersionDAO.findByStackNameAndVersion(EasyMock.anyString(), EasyMock.anyString())).andReturn(repoVersionEntity).anyTimes(); - replayAll(); + UpgradeContext upgradeContext = EasyMock.createNiceMock(UpgradeContext.class); + EasyMock.expect(upgradeContext.getCluster()).andReturn(cluster).anyTimes(); + EasyMock.expect(upgradeContext.getType()).andReturn(UpgradeType.ROLLING).anyTimes(); + EasyMock.expect(upgradeContext.getDirection()).andReturn(Direction.UPGRADE).anyTimes(); + EasyMock.expect(upgradeContext.getSourceRepositoryVersion()).andReturn(repoVersionEntity).anyTimes(); + EasyMock.expect(upgradeContext.getTargetRepositoryVersion()).andReturn(repoVersionEntity).anyTimes(); + EasyMock.expect(upgradeContext.isComponentFailureAutoSkipped()).andReturn(false).anyTimes(); + EasyMock.expect(upgradeContext.isServiceCheckFailureAutoSkipped()).andReturn(false).anyTimes(); - UpgradeContext upgradeContext = new UpgradeContext(cluster, UpgradeType.ROLLING, - Direction.UPGRADE, HDP_21.toString(), new HashMap<String, Object>(), repoVersionDAO); + replayAll(); MockStageWrapperBuilder builder = new MockStageWrapperBuilder(null); List<StageWrapper> stageWrappers = builder.build(upgradeContext); @@ -90,7 +95,7 @@ public class StageWrapperBuilderTest extends EasyMockSupport { @Test public void testAutoSkipCheckInserted() throws Exception { Cluster cluster = createNiceMock(Cluster.class); - EasyMock.expect(cluster.getCurrentStackVersion()).andReturn(HDP_21).atLeastOnce(); + EasyMock.expect(cluster.getCurrentStackVersion()).andReturn(HDP_21).anyTimes(); EasyMock.expect(cluster.getDesiredStackVersion()).andReturn(HDP_21).anyTimes(); RepositoryVersionEntity repoVersionEntity = createNiceMock(RepositoryVersionEntity.class); @@ -100,13 +105,16 @@ public class StageWrapperBuilderTest extends EasyMockSupport { EasyMock.expect(repoVersionDAO.findByStackNameAndVersion(EasyMock.anyString(), EasyMock.anyString())).andReturn(repoVersionEntity).anyTimes(); - replayAll(); + UpgradeContext upgradeContext = createNiceMock(UpgradeContext.class); + EasyMock.expect(upgradeContext.getCluster()).andReturn(cluster).anyTimes(); + EasyMock.expect(upgradeContext.getType()).andReturn(UpgradeType.ROLLING).anyTimes(); + EasyMock.expect(upgradeContext.getDirection()).andReturn(Direction.UPGRADE).anyTimes(); + EasyMock.expect(upgradeContext.getSourceRepositoryVersion()).andReturn(repoVersionEntity).anyTimes(); + EasyMock.expect(upgradeContext.getTargetRepositoryVersion()).andReturn(repoVersionEntity).anyTimes(); + EasyMock.expect(upgradeContext.isComponentFailureAutoSkipped()).andReturn(true).anyTimes(); + EasyMock.expect(upgradeContext.isServiceCheckFailureAutoSkipped()).andReturn(true).anyTimes(); - UpgradeContext upgradeContext = new UpgradeContext(cluster, UpgradeType.ROLLING, - Direction.UPGRADE, HDP_21.toString(), new HashMap<String, Object>(), repoVersionDAO); - - upgradeContext.setAutoSkipComponentFailures(true); - upgradeContext.setAutoSkipServiceCheckFailures(true); + replayAll(); Grouping grouping = new Grouping(); grouping.skippable = true;
