@Test public void testFilterUpgradeOptionsRuntimeValid() { UpgradeV4Request request = new UpgradeV4Request(); request.setRuntime(MATCHING_TARGET_RUNTIME); UpgradeV4Response response = new UpgradeV4Response(); ImageInfoV4Response imageInfo = new ImageInfoV4Response(); imageInfo.setImageId(IMAGE_ID); imageInfo.setCreated(1); imageInfo.setComponentVersions(creatExpectedPackageVersions()); ImageInfoV4Response lastImageInfo = new ImageInfoV4Response(); lastImageInfo.setImageId(IMAGE_ID_LAST); lastImageInfo.setCreated(2); lastImageInfo.setComponentVersions(creatExpectedPackageVersions()); response.setUpgradeCandidates(List.of(imageInfo, lastImageInfo)); underTest.filterUpgradeOptions(response, request); assertEquals(2, response.getUpgradeCandidates().size()); assertEquals(2, response.getUpgradeCandidates().stream().map(ImageInfoV4Response::getImageId).collect(Collectors.toSet()).size()); }
public void filterUpgradeOptions(UpgradeV4Response upgradeOptions, UpgradeV4Request upgradeRequest) { List<ImageInfoV4Response> upgradeCandidates = upgradeOptions.getUpgradeCandidates(); List<ImageInfoV4Response> filteredUpgradeCandidates; if (Objects.isNull(upgradeRequest) || upgradeRequest.isEmpty()) { filteredUpgradeCandidates = List.of(upgradeCandidates.stream().max(getComparator()).orElseThrow()); LOGGER.info("No request param, defaulting to latest image {}", filteredUpgradeCandidates); } else { String requestImageId = upgradeRequest.getImageId(); String runtime = upgradeRequest.getRuntime(); if (StringUtils.isNotEmpty(requestImageId)) { filteredUpgradeCandidates = validateImageId(upgradeCandidates, requestImageId); LOGGER.info("Image successfully validated by imageId {}", requestImageId); } else if (StringUtils.isNotEmpty(runtime)) { filteredUpgradeCandidates = validateRuntime(upgradeCandidates, runtime); LOGGER.info("Image successfully filtered by runtime ({}): {}", runtime, filteredUpgradeCandidates); } else { filteredUpgradeCandidates = upgradeCandidates; } } upgradeOptions.setUpgradeCandidates(filteredUpgradeCandidates); }
ClusterUpgradeAvailabilityService { public void filterUpgradeOptions(UpgradeV4Response upgradeOptions, UpgradeV4Request upgradeRequest) { List<ImageInfoV4Response> upgradeCandidates = upgradeOptions.getUpgradeCandidates(); List<ImageInfoV4Response> filteredUpgradeCandidates; if (Objects.isNull(upgradeRequest) || upgradeRequest.isEmpty()) { filteredUpgradeCandidates = List.of(upgradeCandidates.stream().max(getComparator()).orElseThrow()); LOGGER.info("No request param, defaulting to latest image {}", filteredUpgradeCandidates); } else { String requestImageId = upgradeRequest.getImageId(); String runtime = upgradeRequest.getRuntime(); if (StringUtils.isNotEmpty(requestImageId)) { filteredUpgradeCandidates = validateImageId(upgradeCandidates, requestImageId); LOGGER.info("Image successfully validated by imageId {}", requestImageId); } else if (StringUtils.isNotEmpty(runtime)) { filteredUpgradeCandidates = validateRuntime(upgradeCandidates, runtime); LOGGER.info("Image successfully filtered by runtime ({}): {}", runtime, filteredUpgradeCandidates); } else { filteredUpgradeCandidates = upgradeCandidates; } } upgradeOptions.setUpgradeCandidates(filteredUpgradeCandidates); } }
ClusterUpgradeAvailabilityService { public void filterUpgradeOptions(UpgradeV4Response upgradeOptions, UpgradeV4Request upgradeRequest) { List<ImageInfoV4Response> upgradeCandidates = upgradeOptions.getUpgradeCandidates(); List<ImageInfoV4Response> filteredUpgradeCandidates; if (Objects.isNull(upgradeRequest) || upgradeRequest.isEmpty()) { filteredUpgradeCandidates = List.of(upgradeCandidates.stream().max(getComparator()).orElseThrow()); LOGGER.info("No request param, defaulting to latest image {}", filteredUpgradeCandidates); } else { String requestImageId = upgradeRequest.getImageId(); String runtime = upgradeRequest.getRuntime(); if (StringUtils.isNotEmpty(requestImageId)) { filteredUpgradeCandidates = validateImageId(upgradeCandidates, requestImageId); LOGGER.info("Image successfully validated by imageId {}", requestImageId); } else if (StringUtils.isNotEmpty(runtime)) { filteredUpgradeCandidates = validateRuntime(upgradeCandidates, runtime); LOGGER.info("Image successfully filtered by runtime ({}): {}", runtime, filteredUpgradeCandidates); } else { filteredUpgradeCandidates = upgradeCandidates; } } upgradeOptions.setUpgradeCandidates(filteredUpgradeCandidates); }  }
ClusterUpgradeAvailabilityService { public void filterUpgradeOptions(UpgradeV4Response upgradeOptions, UpgradeV4Request upgradeRequest) { List<ImageInfoV4Response> upgradeCandidates = upgradeOptions.getUpgradeCandidates(); List<ImageInfoV4Response> filteredUpgradeCandidates; if (Objects.isNull(upgradeRequest) || upgradeRequest.isEmpty()) { filteredUpgradeCandidates = List.of(upgradeCandidates.stream().max(getComparator()).orElseThrow()); LOGGER.info("No request param, defaulting to latest image {}", filteredUpgradeCandidates); } else { String requestImageId = upgradeRequest.getImageId(); String runtime = upgradeRequest.getRuntime(); if (StringUtils.isNotEmpty(requestImageId)) { filteredUpgradeCandidates = validateImageId(upgradeCandidates, requestImageId); LOGGER.info("Image successfully validated by imageId {}", requestImageId); } else if (StringUtils.isNotEmpty(runtime)) { filteredUpgradeCandidates = validateRuntime(upgradeCandidates, runtime); LOGGER.info("Image successfully filtered by runtime ({}): {}", runtime, filteredUpgradeCandidates); } else { filteredUpgradeCandidates = upgradeCandidates; } } upgradeOptions.setUpgradeCandidates(filteredUpgradeCandidates); }  UpgradeV4Response checkForUpgradesByName(Long workspaceId, String stackName, boolean lockComponents); UpgradeV4Response checkForNotAttachedClusters(StackViewV4Responses stackViewV4Responses, UpgradeV4Response upgradeOptions); void filterUpgradeOptions(UpgradeV4Response upgradeOptions, UpgradeV4Request upgradeRequest); void checkUpgradeSupported(Stack stack); }
ClusterUpgradeAvailabilityService { public void filterUpgradeOptions(UpgradeV4Response upgradeOptions, UpgradeV4Request upgradeRequest) { List<ImageInfoV4Response> upgradeCandidates = upgradeOptions.getUpgradeCandidates(); List<ImageInfoV4Response> filteredUpgradeCandidates; if (Objects.isNull(upgradeRequest) || upgradeRequest.isEmpty()) { filteredUpgradeCandidates = List.of(upgradeCandidates.stream().max(getComparator()).orElseThrow()); LOGGER.info("No request param, defaulting to latest image {}", filteredUpgradeCandidates); } else { String requestImageId = upgradeRequest.getImageId(); String runtime = upgradeRequest.getRuntime(); if (StringUtils.isNotEmpty(requestImageId)) { filteredUpgradeCandidates = validateImageId(upgradeCandidates, requestImageId); LOGGER.info("Image successfully validated by imageId {}", requestImageId); } else if (StringUtils.isNotEmpty(runtime)) { filteredUpgradeCandidates = validateRuntime(upgradeCandidates, runtime); LOGGER.info("Image successfully filtered by runtime ({}): {}", runtime, filteredUpgradeCandidates); } else { filteredUpgradeCandidates = upgradeCandidates; } } upgradeOptions.setUpgradeCandidates(filteredUpgradeCandidates); }  UpgradeV4Response checkForUpgradesByName(Long workspaceId, String stackName, boolean lockComponents); UpgradeV4Response checkForNotAttachedClusters(StackViewV4Responses stackViewV4Responses, UpgradeV4Response upgradeOptions); void filterUpgradeOptions(UpgradeV4Response upgradeOptions, UpgradeV4Request upgradeRequest); void checkUpgradeSupported(Stack stack);  }