@Test public void testValidateImageCatalogNok() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException { com.sequenceiq.cloudbreak.cloud.model.Image imageInComponent = new com.sequenceiq.cloudbreak.cloud.model.Image( "imageName", Collections.emptyMap(), image.getOs(), image.getOsType(), statedImage.getImageCatalogUrl(), statedImage.getImageCatalogName(), "uuid", packageVersions); when(componentConfigProviderService.getImage(anyLong())).thenReturn(imageInComponent); when(imageCatalogService.getImage(anyString(), anyString(), anyString())).thenReturn(statedImage); when(imageUpdateService.checkPackageVersions(any(Stack.class), any(StatedImage.class))).thenReturn(CheckResult.failed("Failure")); warnings.addAll(underTest.validateImageCatalog(stack)); assertEquals(1, warnings.size()); }
public List<Warning> validateImageCatalog(Stack stack) { List<Warning> warnings = new ArrayList<>(); try { Image image = componentConfigProviderService.getImage(stack.getId()); StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId()); if (!image.getPackageVersions().isEmpty()) { CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage); if (checkResult.getStatus().equals(EventStatus.FAILED)) { warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage())); } } } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { throw new CloudbreakServiceException("Image info could not be validated!", e); } return warnings; }
MaintenanceModeValidationService { public List<Warning> validateImageCatalog(Stack stack) { List<Warning> warnings = new ArrayList<>(); try { Image image = componentConfigProviderService.getImage(stack.getId()); StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId()); if (!image.getPackageVersions().isEmpty()) { CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage); if (checkResult.getStatus().equals(EventStatus.FAILED)) { warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage())); } } } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { throw new CloudbreakServiceException("Image info could not be validated!", e); } return warnings; } }
MaintenanceModeValidationService { public List<Warning> validateImageCatalog(Stack stack) { List<Warning> warnings = new ArrayList<>(); try { Image image = componentConfigProviderService.getImage(stack.getId()); StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId()); if (!image.getPackageVersions().isEmpty()) { CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage); if (checkResult.getStatus().equals(EventStatus.FAILED)) { warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage())); } } } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { throw new CloudbreakServiceException("Image info could not be validated!", e); } return warnings; }  }
MaintenanceModeValidationService { public List<Warning> validateImageCatalog(Stack stack) { List<Warning> warnings = new ArrayList<>(); try { Image image = componentConfigProviderService.getImage(stack.getId()); StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId()); if (!image.getPackageVersions().isEmpty()) { CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage); if (checkResult.getStatus().equals(EventStatus.FAILED)) { warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage())); } } } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { throw new CloudbreakServiceException("Image info could not be validated!", e); } return warnings; }  String fetchStackRepository(Long stackId); void setUpValidationFlow(Long stackId); List<Warning> validateStackRepository(Long clusterId, String stackRepo); List<Warning> validateImageCatalog(Stack stack); void handleValidationSuccess(Long stackId, List<Warning> warnings); void handleValidationFailure(Long stackId, Exception error); }
MaintenanceModeValidationService { public List<Warning> validateImageCatalog(Stack stack) { List<Warning> warnings = new ArrayList<>(); try { Image image = componentConfigProviderService.getImage(stack.getId()); StatedImage statedImage = imageCatalogService.getImage(image.getImageCatalogUrl(), image.getImageCatalogName(), image.getImageId()); if (!image.getPackageVersions().isEmpty()) { CheckResult checkResult = stackImageUpdateService.checkPackageVersions(stack, statedImage); if (checkResult.getStatus().equals(EventStatus.FAILED)) { warnings.add(new Warning(WarningType.IMAGE_INCOMPATIBILITY_WARNING, checkResult.getMessage())); } } } catch (CloudbreakImageNotFoundException | CloudbreakImageCatalogException e) { throw new CloudbreakServiceException("Image info could not be validated!", e); } return warnings; }  String fetchStackRepository(Long stackId); void setUpValidationFlow(Long stackId); List<Warning> validateStackRepository(Long clusterId, String stackRepo); List<Warning> validateImageCatalog(Stack stack); void handleValidationSuccess(Long stackId, List<Warning> warnings); void handleValidationFailure(Long stackId, Exception error);  }