@Test
  public void testAutoSkipCheckInserted() throws Exception {
    Cluster cluster = createNiceMock(Cluster.class);

    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();

    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.getRepositoryVersion()).andReturn(repoVersionEntity).anyTimes();
    EasyMock.expect(upgradeContext.isComponentFailureAutoSkipped()).andReturn(true).anyTimes();
    EasyMock.expect(upgradeContext.isServiceCheckFailureAutoSkipped()).andReturn(true).anyTimes();

    replayAll();

    Grouping grouping = new Grouping();
    grouping.skippable = true;

    MockStageWrapperBuilder builder = new MockStageWrapperBuilder(grouping);

    List<StageWrapper> mockStageWrappers = new ArrayList<>();
    StageWrapper mockStageWrapper = EasyMock.createNiceMock(StageWrapper.class);
    mockStageWrappers.add(mockStageWrapper);

    builder.setMockStageWrappers(mockStageWrappers);

    List<StageWrapper> stageWrappers = builder.build(upgradeContext);
    Assert.assertEquals(2, stageWrappers.size());

    StageWrapper skipSummaryWrapper = stageWrappers.get(1);
    Assert.assertEquals(StageWrapper.Type.SERVER_SIDE_ACTION, skipSummaryWrapper.getType());

    ServerActionTask task = (ServerActionTask)(skipSummaryWrapper.getTasks().get(0).getTasks().get(0));
    Assert.assertEquals(AutoSkipFailedSummaryAction.class.getName(), task.implClass);
    Assert.assertEquals(1, task.messages.size());
    Assert.assertTrue(task.messages.get(0).contains("There are failures that were automatically skipped"));

    verifyAll();
  }
Tests that a new task was inserted into the upgrade which will check for
skipped failures and display a summary.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/state/stack/upgrade/StageWrapperBuilderTest.java