Search in sources :

Example 1 with ImageSettingsV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request in project cloudbreak by hortonworks.

the class StackToStackV4RequestConverter method prepareImage.

private void prepareImage(Stack source, StackV4Request stackV2Request) {
    try {
        Image image = componentConfigProviderService.getImage(source.getId());
        ImageSettingsV4Request is = new ImageSettingsV4Request();
        is.setId(Strings.isNullOrEmpty(image.getImageId()) ? "" : image.getImageId());
        is.setCatalog(Strings.isNullOrEmpty(image.getImageCatalogName()) ? "" : image.getImageCatalogName());
        stackV2Request.setImage(is);
    } catch (CloudbreakImageNotFoundException e) {
        LOGGER.info(e.toString());
    }
}
Also used : ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Image(com.sequenceiq.cloudbreak.cloud.model.Image)

Example 2 with ImageSettingsV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request in project cloudbreak by hortonworks.

the class SdxCustomTestDto method valid.

@Override
public SdxCustomTestDto valid() {
    ImageSettingsTestDto imageSettingsTestDto = getCloudProvider().imageSettings(getTestContext().init(ImageSettingsTestDto.class));
    ImageSettingsV4Request imageSettingsV4Request = imageSettingsTestDto.getRequest();
    ImageCatalogTestDto imageCatalogTestDto = getTestContext().get(ImageCatalogTestDto.class);
    withName(getResourcePropertyProvider().getName(getCloudPlatform())).withEnvironmentName(getTestContext().get(EnvironmentTestDto.class).getRequest().getName()).withClusterShape(getCloudProvider().getClusterShape()).withTags(getCloudProvider().getTags()).withImageCatalogNameAndImageId(imageCatalogTestDto.getName(), imageSettingsV4Request.getId());
    return getCloudProvider().sdxCustom(this);
}
Also used : ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) ImageSettingsTestDto(com.sequenceiq.it.cloudbreak.dto.ImageSettingsTestDto) ImageCatalogTestDto(com.sequenceiq.it.cloudbreak.dto.imagecatalog.ImageCatalogTestDto)

Example 3 with ImageSettingsV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request in project cloudbreak by hortonworks.

the class ImageServiceTest method testGivenBaseImageIdAndDisabledBaseImageShouldReturnError.

@Test
public void testGivenBaseImageIdAndDisabledBaseImageShouldReturnError() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    when(imageCatalogService.getImageByCatalogName(anyLong(), anyString(), anyString())).thenReturn(ImageTestUtil.getImageFromCatalog(false, "uuid", STACK_VERSION));
    CloudbreakImageCatalogException exception = assertThrows(CloudbreakImageCatalogException.class, () -> underTest.determineImageFromCatalog(WORKSPACE_ID, imageSettingsV4Request, PLATFORM, PLATFORM, TestUtil.blueprint(), false, false, TestUtil.user(USER_ID, USER_ID_STRING), image -> true));
    assertEquals("Inconsistent request, base images are disabled but image with id uuid is base image!", exception.getMessage());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Mock(org.mockito.Mock) TestUtil(com.sequenceiq.cloudbreak.TestUtil) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) ImageCatalogPlatform.imageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform) MockitoAnnotations(org.mockito.MockitoAnnotations) StackMatrixService(com.sequenceiq.cloudbreak.service.StackMatrixService) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) PLATFORM(com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM) MethodSource(org.junit.jupiter.params.provider.MethodSource) InjectMocks(org.mockito.InjectMocks) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) Mockito.when(org.mockito.Mockito.when) Arguments(org.junit.jupiter.params.provider.Arguments) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) CloudPlatformConnectors(com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors) Assert.assertFalse(org.junit.Assert.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BlueprintUtils(com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ImageSettingsV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request in project cloudbreak by hortonworks.

the class ImageServiceTest method testUseBaseImageAndDisabledBaseImageShouldReturnError.

@Test
public void testUseBaseImageAndDisabledBaseImageShouldReturnError() {
    imageSettingsV4Request.setId(null);
    CloudbreakImageCatalogException exception = assertThrows(CloudbreakImageCatalogException.class, () -> underTest.determineImageFromCatalog(WORKSPACE_ID, imageSettingsV4Request, PLATFORM, PLATFORM, TestUtil.blueprint(), true, false, TestUtil.user(USER_ID, USER_ID_STRING), image -> true));
    assertEquals("Inconsistent request, base images are disabled but custom repo information is submitted!", exception.getMessage());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Mock(org.mockito.Mock) TestUtil(com.sequenceiq.cloudbreak.TestUtil) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) ImageCatalogPlatform.imageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform) MockitoAnnotations(org.mockito.MockitoAnnotations) StackMatrixService(com.sequenceiq.cloudbreak.service.StackMatrixService) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) PLATFORM(com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM) MethodSource(org.junit.jupiter.params.provider.MethodSource) InjectMocks(org.mockito.InjectMocks) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) Mockito.when(org.mockito.Mockito.when) Arguments(org.junit.jupiter.params.provider.Arguments) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) CloudPlatformConnectors(com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors) Assert.assertFalse(org.junit.Assert.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BlueprintUtils(com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with ImageSettingsV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request in project cloudbreak by hortonworks.

the class DistroXImageToImageSettingsConverterTest method testConvertImageSettingsV4RequestToDistroXImageV1Request.

@Test
void testConvertImageSettingsV4RequestToDistroXImageV1Request() {
    ImageSettingsV4Request input = new ImageSettingsV4Request();
    input.setCatalog("someCatalog");
    input.setId("someId");
    DistroXImageV1Request result = underTest.convert(input);
    assertNotNull(result);
    assertEquals(input.getCatalog(), result.getCatalog());
    assertEquals(input.getId(), result.getId());
}
Also used : ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) DistroXImageV1Request(com.sequenceiq.distrox.api.v1.distrox.model.image.DistroXImageV1Request) Test(org.junit.jupiter.api.Test)

Aggregations

ImageSettingsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request)17 Test (org.junit.jupiter.api.Test)7 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 TestUtil (com.sequenceiq.cloudbreak.TestUtil)4 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)4 CloudPlatformConnectors (com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors)4 ClusterComponentConfigProvider (com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider)4 BlueprintUtils (com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils)4 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)4 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)4 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)4 ComponentConfigProviderService (com.sequenceiq.cloudbreak.service.ComponentConfigProviderService)4 StackMatrixService (com.sequenceiq.cloudbreak.service.StackMatrixService)4 PLATFORM (com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM)4 ImageCatalogPlatform.imageCatalogPlatform (com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform)4 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)4 Stream (java.util.stream.Stream)4 Assert.assertFalse (org.junit.Assert.assertFalse)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4