@Test public void testClusterUpgradeFinishedWhenNotNeeded() { Image currentImmage = createImage(CURRENT_BUILD_NUMBER, CURRENT_BUILD_NUMBER); StatedImage currentImage = StatedImage.statedImage(currentImmage, null, null); Image targetImmage = createImage(CURRENT_BUILD_NUMBER, CURRENT_BUILD_NUMBER); StatedImage targetImage = StatedImage.statedImage(targetImmage, null, null); underTest.clusterUpgradeFinished(STACK_ID, currentImage, targetImage); verify(flowMessageService).fireEventAndLog(STACK_ID, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED_NOVERSION); }
public void clusterUpgradeFinished(long stackId, StatedImage currentImage, StatedImage targetImage) { Image targetIm = targetImage.getImage(); Image currentIm = currentImage.getImage(); String clusterStackVersion = NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getVersion); String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentIm.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getStackBuildNumber)); clusterService.updateClusterStatusByStackId(stackId, Status.AVAILABLE); stackUpdater.updateStackStatus(stackId, DetailedStackStatus.CLUSTER_UPGRADE_FINISHED, "Cluster stack was successfully upgraded."); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED, clusterStackVersion); } else { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED_NOVERSION); } }
ClusterUpgradeService { public void clusterUpgradeFinished(long stackId, StatedImage currentImage, StatedImage targetImage) { Image targetIm = targetImage.getImage(); Image currentIm = currentImage.getImage(); String clusterStackVersion = NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getVersion); String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentIm.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getStackBuildNumber)); clusterService.updateClusterStatusByStackId(stackId, Status.AVAILABLE); stackUpdater.updateStackStatus(stackId, DetailedStackStatus.CLUSTER_UPGRADE_FINISHED, "Cluster stack was successfully upgraded."); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED, clusterStackVersion); } else { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED_NOVERSION); } } }
ClusterUpgradeService { public void clusterUpgradeFinished(long stackId, StatedImage currentImage, StatedImage targetImage) { Image targetIm = targetImage.getImage(); Image currentIm = currentImage.getImage(); String clusterStackVersion = NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getVersion); String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentIm.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getStackBuildNumber)); clusterService.updateClusterStatusByStackId(stackId, Status.AVAILABLE); stackUpdater.updateStackStatus(stackId, DetailedStackStatus.CLUSTER_UPGRADE_FINISHED, "Cluster stack was successfully upgraded."); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED, clusterStackVersion); } else { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED_NOVERSION); } }  }
ClusterUpgradeService { public void clusterUpgradeFinished(long stackId, StatedImage currentImage, StatedImage targetImage) { Image targetIm = targetImage.getImage(); Image currentIm = currentImage.getImage(); String clusterStackVersion = NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getVersion); String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentIm.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getStackBuildNumber)); clusterService.updateClusterStatusByStackId(stackId, Status.AVAILABLE); stackUpdater.updateStackStatus(stackId, DetailedStackStatus.CLUSTER_UPGRADE_FINISHED, "Cluster stack was successfully upgraded."); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED, clusterStackVersion); } else { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED_NOVERSION); } }  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); }
ClusterUpgradeService { public void clusterUpgradeFinished(long stackId, StatedImage currentImage, StatedImage targetImage) { Image targetIm = targetImage.getImage(); Image currentIm = currentImage.getImage(); String clusterStackVersion = NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getVersion); String currentRuntimeBuildNumber = NullUtil.getIfNotNull(currentIm.getStackDetails(), StackDetails::getStackBuildNumber); boolean clusterRuntimeUpgradeNeeded = isUpdateNeeded(currentRuntimeBuildNumber, NullUtil.getIfNotNull(targetIm.getStackDetails(), StackDetails::getStackBuildNumber)); clusterService.updateClusterStatusByStackId(stackId, Status.AVAILABLE); stackUpdater.updateStackStatus(stackId, DetailedStackStatus.CLUSTER_UPGRADE_FINISHED, "Cluster stack was successfully upgraded."); if (clusterRuntimeUpgradeNeeded) { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED, clusterStackVersion); } else { flowMessageService.fireEventAndLog(stackId, Status.AVAILABLE.name(), CLUSTER_UPGRADE_FINISHED_NOVERSION); } }  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);  }