use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class CmSyncResultMergerServiceTest method componentWithName.
private Component componentWithName(String name) {
Component component = new Component();
component.setName(name);
return component;
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class StackImageServiceTest method testRemoveTargetImageShouldRemoveImageWhenTheImagePresent.
@Test
void testRemoveTargetImageShouldRemoveImageWhenTheImagePresent() {
Component targetImageComponent = createImageComponent();
when(componentConfigProviderService.getComponent(stack.getId(), ComponentType.IMAGE, TARGET_IMAGE)).thenReturn(targetImageComponent);
victim.removeImageByComponentName(stack.getId(), TARGET_IMAGE);
verify(componentConfigProviderService).getComponent(stack.getId(), ComponentType.IMAGE, TARGET_IMAGE);
verify(componentConfigProviderService).deleteComponents(Collections.singleton(targetImageComponent));
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ClusterUpgradeTargetImageServiceTest method testSaveImageShouldSaveTheTargetImageWhenIsNotPresent.
@Test
void testSaveImageShouldSaveTheTargetImageWhenIsNotPresent() throws IOException, CloudbreakImageNotFoundException {
Image targetModelImage = createTargetModelImage(IMAGE_ID, IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME);
when(stackImageService.findImageComponentByName(STACK_ID, TARGET_IMAGE)).thenReturn(Optional.empty());
when(stackService.getById(STACK_ID)).thenReturn(stack);
when(stackImageService.getCurrentImage(stack)).thenReturn(currentImage);
when(stackImageService.getImageModelFromStatedImage(stack, currentImage, targetStatedImage)).thenReturn(targetModelImage);
underTest.saveImage(STACK_ID, targetStatedImage);
verify(stackImageService).findImageComponentByName(STACK_ID, TARGET_IMAGE);
verify(stackService).getById(STACK_ID);
ArgumentCaptor<Component> targetComponentCaptor = ArgumentCaptor.forClass(Component.class);
verify(componentConfigProviderService).store(targetComponentCaptor.capture());
Component targetComponent = targetComponentCaptor.getValue();
assertEquals(ComponentType.IMAGE, targetComponent.getComponentType());
assertEquals(TARGET_IMAGE, targetComponent.getName());
assertEquals(stack, targetComponent.getStack());
assertEquals(targetModelImage.getImageId(), targetComponent.getAttributes().get(Image.class).getImageId());
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ClusterUpgradeTargetImageServiceTest method testSaveImageShouldRemoveTheOldTargetImageAndSaveTheTargetImageWhenAnOldImageIsPresentAndTheImageCatalogNameIsNotTheSame.
@Test
void testSaveImageShouldRemoveTheOldTargetImageAndSaveTheTargetImageWhenAnOldImageIsPresentAndTheImageCatalogNameIsNotTheSame() throws IOException, CloudbreakImageNotFoundException {
StatedImage targetImage = ImageTestUtil.getImageFromCatalog(true, IMAGE_ID, STACK_VERSION, IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME);
Image targetModelImage = createTargetModelImage(IMAGE_ID, IMAGE_CATALOG_URL, IMAGE_CATALOG_NAME);
Image oldTargetImage = createTargetModelImage(IMAGE_ID, "old-image-catalog-url", IMAGE_CATALOG_NAME);
Optional<Component> existingTargetImageComponent = createExistingTargetImageComponent(oldTargetImage);
when(imageProvider.convertJsonToImage(existingTargetImageComponent.get().getAttributes())).thenReturn(oldTargetImage);
when(stackImageService.findImageComponentByName(STACK_ID, TARGET_IMAGE)).thenReturn(existingTargetImageComponent);
when(stackService.getById(STACK_ID)).thenReturn(stack);
when(stackImageService.getCurrentImage(stack)).thenReturn(currentImage);
when(stackImageService.getImageModelFromStatedImage(stack, currentImage, targetImage)).thenReturn(targetModelImage);
underTest.saveImage(STACK_ID, targetImage);
verify(stackImageService).getCurrentImage(stack);
verify(stackImageService).findImageComponentByName(STACK_ID, TARGET_IMAGE);
verify(stackService).getById(STACK_ID);
ArgumentCaptor<Component> targetComponentCaptor = ArgumentCaptor.forClass(Component.class);
verify(componentConfigProviderService).store(targetComponentCaptor.capture());
Component targetComponent = targetComponentCaptor.getValue();
assertEquals(ComponentType.IMAGE, targetComponent.getComponentType());
assertEquals(TARGET_IMAGE, targetComponent.getName());
assertEquals(stack, targetComponent.getStack());
assertEquals(targetModelImage.getImageId(), targetComponent.getAttributes().get(Image.class).getImageId());
}
use of com.sequenceiq.cloudbreak.domain.stack.Component in project cloudbreak by hortonworks.
the class ImageService method addStackRepo.
private void addStackRepo(Stack stack, Set<Component> components, com.sequenceiq.cloudbreak.cloud.model.catalog.Image catalogBasedImage) throws CloudbreakImageCatalogException {
if (catalogBasedImage.getStackDetails() != null) {
ImageStackDetails stackDetails = catalogBasedImage.getStackDetails();
StackType stackType = determineStackType(stackDetails);
Component stackRepoComponent = getStackComponent(stack, stackDetails, stackType, catalogBasedImage.getOsType());
components.add(stackRepoComponent);
}
}
Aggregations