### Question:
ClusterUpgradeService { public void handleUpgradeClusterFailure(long stackId, String errorReason, DetailedStackStatus detailedStatus) { clusterService.updateClusterStatusByStackId(stackId, Status.UPDATE_FAILED, errorReason); stackUpdater.updateStackStatus(stackId, detailedStatus); switch (detailedStatus) { case CLUSTER_MANAGER_UPGRADE_FAILED: flowMessageService.fireEventAndLog(stackId, Status.UPDATE_FAILED.name(), CLUSTER_MANAGER_UPGRADE_FAILED, errorReason); break; case CLUSTER_UPGRADE_FAILED: default: flowMessageService.fireEventAndLog(stackId, Status.UPDATE_FAILED.name(), CLUSTER_UPGRADE_FAILED, errorReason); } }  void initUpgradeCluster(long stackId, StatedImage targetImage); boolean upgradeClusterManager(long stackId, StatedImage currentImage, StatedImage targetImage); boolean upgradeCluster(long stackId, Image currentImage, Image targetImage); void clusterUpgradeFinished(long stackId, StatedImage currentImage, StatedImage targetImage); void handleUpgradeClusterFailure(long stackId, String errorReason, DetailedStackStatus detailedStatus);  }### Answer:
@Test public void testClusterManagerUpgradeFailure() { ArgumentCaptor<ResourceEvent> captor = ArgumentCaptor.forClass(ResourceEvent.class); underTest.handleUpgradeClusterFailure(STACK_ID, ERROR_MESSAGE, DetailedStackStatus.CLUSTER_MANAGER_UPGRADE_FAILED); verify(flowMessageService).fireEventAndLog(eq(STACK_ID), eq(Status.UPDATE_FAILED.name()), captor.capture(), eq(ERROR_MESSAGE)); assertEquals(CLUSTER_MANAGER_UPGRADE_FAILED, captor.getValue()); }
@Test public void testClusterUpgradeFailure() { ArgumentCaptor<ResourceEvent> captor = ArgumentCaptor.forClass(ResourceEvent.class); underTest.handleUpgradeClusterFailure(STACK_ID, ERROR_MESSAGE, DetailedStackStatus.CLUSTER_UPGRADE_FAILED); verify(flowMessageService).fireEventAndLog(eq(STACK_ID), eq(Status.UPDATE_FAILED.name()), captor.capture(), eq(ERROR_MESSAGE)); assertEquals(CLUSTER_UPGRADE_FAILED, captor.getValue()); }