### Question:
SdxRepairService { protected AttemptResult<StackV4Response> checkClusterStatusDuringRepair(SdxCluster sdxCluster) throws JsonProcessingException { LOGGER.info("Repair polling cloudbreak for stack status: '{}' in '{}' env", sdxCluster.getClusterName(), sdxCluster.getEnvName()); try { if (PollGroup.CANCELLED.equals(DatalakeInMemoryStateStore.get(sdxCluster.getId()))) { LOGGER.info("Repair polling cancelled in inmemory store, id: " + sdxCluster.getId()); return AttemptResults.breakFor("Repair polling cancelled in inmemory store, id: " + sdxCluster.getId()); } FlowState flowState = cloudbreakFlowService.getLastKnownFlowState(sdxCluster); if (RUNNING.equals(flowState)) { LOGGER.info("Repair polling will continue, cluster has an active flow in Cloudbreak, id: " + sdxCluster.getId()); return AttemptResults.justContinue(); } else { return getStackResponseAttemptResult(sdxCluster, flowState); } } catch (NotFoundException e) { LOGGER.debug("Stack not found on CB side " + sdxCluster.getClusterName(), e); return AttemptResults.breakFor("Stack not found on CB side " + sdxCluster.getClusterName()); } }  FlowIdentifier triggerRepairByCrn(String userCrn, String clusterCrn, SdxRepairRequest clusterRepairRequest); FlowIdentifier triggerRepairByName(String userCrn, String clusterName, SdxRepairRequest clusterRepairRequest); void startSdxRepair(Long id, SdxRepairSettings repairRequest); void waitCloudbreakClusterRepair(Long id, PollingConfig pollingConfig);  }### Answer:
@Test public void waitCloudbreakClusterRepairWhenThereIsNoActiveFlow() throws JsonProcessingException { SdxCluster cluster = new SdxCluster(); cluster.setId(CLUSTER_ID.incrementAndGet()); cluster.setInitiatorUserCrn(USER_CRN); cluster.setClusterName(CLUSTER_NAME); cluster.setAccountId("accountid"); StackV4Response resp = new StackV4Response(); resp.setStatus(Status.UPDATE_FAILED); when(cloudbreakFlowService.getLastKnownFlowState(any())).thenReturn(FlowState.FINISHED); when(stackV4Endpoint.get(eq(0L), eq("dummyCluster"), any(), anyString())).thenReturn(resp); AttemptResult<StackV4Response> attempt = underTest.checkClusterStatusDuringRepair(cluster); assertEquals(AttemptState.BREAK, attempt.getState()); }
@Test public void waitCloudbreakClusterRepairWhenThereIsActiveFlow() throws JsonProcessingException { SdxCluster cluster = new SdxCluster(); cluster.setId(CLUSTER_ID.incrementAndGet()); cluster.setInitiatorUserCrn(USER_CRN); cluster.setClusterName(CLUSTER_NAME); when(cloudbreakFlowService.getLastKnownFlowState(any())).thenReturn(FlowState.RUNNING); AttemptResult<StackV4Response> attempt = underTest.checkClusterStatusDuringRepair(cluster); assertEquals(AttemptState.CONTINUE, attempt.getState()); verifyZeroInteractions(stackV4Endpoint); }