@Test public void testUpdateRuntimeVersionFromStackResponse() { SdxCluster sdxCluster = getSdxCluster(); StackV4Response stackV4Response = new StackV4Response(); ClusterV4Response clusterV4Response = new ClusterV4Response(); ClouderaManagerV4Response cm = new ClouderaManagerV4Response(); ClouderaManagerProductV4Response cdpResponse = new ClouderaManagerProductV4Response(); cdpResponse.setName("CDH"); cdpResponse.setVersion("7.2.1-1.32.123-123"); cm.setProducts(Collections.singletonList(cdpResponse)); clusterV4Response.setCm(cm); stackV4Response.setCluster(clusterV4Response); underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response); ArgumentCaptor<SdxCluster> sdxClusterArgumentCaptor = ArgumentCaptor.forClass(SdxCluster.class); verify(sdxClusterRepository, times(1)).save(sdxClusterArgumentCaptor.capture()); Assert.assertEquals("7.2.1", sdxClusterArgumentCaptor.getValue().getRuntime()); cdpResponse.setVersion("7.1.0"); underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response); verify(sdxClusterRepository, times(2)).save(sdxClusterArgumentCaptor.capture()); Assert.assertEquals("7.1.0", sdxClusterArgumentCaptor.getValue().getRuntime()); cdpResponse.setVersion("7.0.2-valami"); underTest.updateRuntimeVersionFromStackResponse(sdxCluster, stackV4Response); verify(sdxClusterRepository, times(3)).save(sdxClusterArgumentCaptor.capture()); Assert.assertEquals("7.0.2", sdxClusterArgumentCaptor.getValue().getRuntime()); }
public void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response) { String clusterName = sdxCluster.getClusterName(); Optional<String> cdpVersionOpt = getCdpVersion(stackV4Response); LOGGER.info("Update '{}' runtime version from stackV4Response", clusterName); if (cdpVersionOpt.isPresent()) { String version = cdpVersionOpt.get(); LOGGER.info("Update Sdx runtime version of {} to {}, previous version: {}", clusterName, version, sdxCluster.getRuntime()); sdxCluster.setRuntime(version); sdxClusterRepository.save(sdxCluster); } else { LOGGER.warn("Cannot update the Sdx runtime version for cluster: {}", clusterName); } }
SdxService implements ResourceIdProvider, ResourceBasedCrnProvider { public void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response) { String clusterName = sdxCluster.getClusterName(); Optional<String> cdpVersionOpt = getCdpVersion(stackV4Response); LOGGER.info("Update '{}' runtime version from stackV4Response", clusterName); if (cdpVersionOpt.isPresent()) { String version = cdpVersionOpt.get(); LOGGER.info("Update Sdx runtime version of {} to {}, previous version: {}", clusterName, version, sdxCluster.getRuntime()); sdxCluster.setRuntime(version); sdxClusterRepository.save(sdxCluster); } else { LOGGER.warn("Cannot update the Sdx runtime version for cluster: {}", clusterName); } } }
SdxService implements ResourceIdProvider, ResourceBasedCrnProvider { public void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response) { String clusterName = sdxCluster.getClusterName(); Optional<String> cdpVersionOpt = getCdpVersion(stackV4Response); LOGGER.info("Update '{}' runtime version from stackV4Response", clusterName); if (cdpVersionOpt.isPresent()) { String version = cdpVersionOpt.get(); LOGGER.info("Update Sdx runtime version of {} to {}, previous version: {}", clusterName, version, sdxCluster.getRuntime()); sdxCluster.setRuntime(version); sdxClusterRepository.save(sdxCluster); } else { LOGGER.warn("Cannot update the Sdx runtime version for cluster: {}", clusterName); } }  }
SdxService implements ResourceIdProvider, ResourceBasedCrnProvider { public void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response) { String clusterName = sdxCluster.getClusterName(); Optional<String> cdpVersionOpt = getCdpVersion(stackV4Response); LOGGER.info("Update '{}' runtime version from stackV4Response", clusterName); if (cdpVersionOpt.isPresent()) { String version = cdpVersionOpt.get(); LOGGER.info("Update Sdx runtime version of {} to {}, previous version: {}", clusterName, version, sdxCluster.getRuntime()); sdxCluster.setRuntime(version); sdxClusterRepository.save(sdxCluster); } else { LOGGER.warn("Cannot update the Sdx runtime version for cluster: {}", clusterName); } }  String getStackCrnByClusterCrn(String crn); Set<Long> findByResourceIdsAndStatuses(Set<Long> resourceIds, Set<DatalakeStatusEnum> statuses); SdxCluster getById(Long id); StackV4Response getDetail(String name, Set<String> entries, String accountId); SdxCluster getByCrn(String userCrn, String clusterCrn); SdxCluster getByNameInAccount(String userCrn, String name); Pair<SdxCluster, FlowIdentifier> createSdx(final String userCrn, final String name, final SdxClusterRequest sdxClusterRequest,
            final StackV4Request internalStackV4Request); FlowIdentifier sync(String name, String accountId); void syncByCrn(String userCrn, String crn); @Override Long getResourceIdByResourceCrn(String resourceCrn); @Override Long getResourceIdByResourceName(String resourceName); List<SdxCluster> listSdxByEnvCrn(String userCrn, String envCrn); List<SdxCluster> listSdxByEnvCrn(String envCrn); List<SdxCluster> listSdx(String userCrn, String envName); FlowIdentifier deleteSdxByClusterCrn(String userCrn, String clusterCrn, boolean forced); FlowIdentifier deleteSdx(String userCrn, String name, boolean forced); void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response); String getAccountIdFromCrn(String crnStr); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); @Override Optional<String> getEnvironmentCrnByResourceCrn(String resourceCrn); @Override AuthorizationResourceType getResourceType(); SdxCluster save(SdxCluster sdxCluster); }
SdxService implements ResourceIdProvider, ResourceBasedCrnProvider { public void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response) { String clusterName = sdxCluster.getClusterName(); Optional<String> cdpVersionOpt = getCdpVersion(stackV4Response); LOGGER.info("Update '{}' runtime version from stackV4Response", clusterName); if (cdpVersionOpt.isPresent()) { String version = cdpVersionOpt.get(); LOGGER.info("Update Sdx runtime version of {} to {}, previous version: {}", clusterName, version, sdxCluster.getRuntime()); sdxCluster.setRuntime(version); sdxClusterRepository.save(sdxCluster); } else { LOGGER.warn("Cannot update the Sdx runtime version for cluster: {}", clusterName); } }  String getStackCrnByClusterCrn(String crn); Set<Long> findByResourceIdsAndStatuses(Set<Long> resourceIds, Set<DatalakeStatusEnum> statuses); SdxCluster getById(Long id); StackV4Response getDetail(String name, Set<String> entries, String accountId); SdxCluster getByCrn(String userCrn, String clusterCrn); SdxCluster getByNameInAccount(String userCrn, String name); Pair<SdxCluster, FlowIdentifier> createSdx(final String userCrn, final String name, final SdxClusterRequest sdxClusterRequest,
            final StackV4Request internalStackV4Request); FlowIdentifier sync(String name, String accountId); void syncByCrn(String userCrn, String crn); @Override Long getResourceIdByResourceCrn(String resourceCrn); @Override Long getResourceIdByResourceName(String resourceName); List<SdxCluster> listSdxByEnvCrn(String userCrn, String envCrn); List<SdxCluster> listSdxByEnvCrn(String envCrn); List<SdxCluster> listSdx(String userCrn, String envName); FlowIdentifier deleteSdxByClusterCrn(String userCrn, String clusterCrn, boolean forced); FlowIdentifier deleteSdx(String userCrn, String name, boolean forced); void updateRuntimeVersionFromStackResponse(SdxCluster sdxCluster, StackV4Response stackV4Response); String getAccountIdFromCrn(String crnStr); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceNames); @Override List<String> getResourceCrnsInAccount(); @Override Optional<String> getEnvironmentCrnByResourceCrn(String resourceCrn); @Override AuthorizationResourceType getResourceType(); SdxCluster save(SdxCluster sdxCluster);  }