Search in sources :

Example 31 with ImageSettingsRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.

the class ImageServiceTest method testGetImageGivenIdInputNotFound.

@Test
public void testGetImageGivenIdInputNotFound() {
    ImageSettingsRequest imageSettings = new ImageSettingsRequest();
    imageSettings.setCatalog(IMAGE_CATALOG);
    imageSettings.setId(FAKE_ID);
    imageSettings.setOs(DEFAULT_OS);
    when(imageProviderFactory.getImageProvider(IMAGE_CATALOG)).thenReturn(imageProvider);
    when(imageProvider.getImage(imageSettings, DEFAULT_REGION, DEFAULT_PLATFORM)).thenReturn(Optional.empty());
    Exception exception = assertThrows(RuntimeException.class, () -> underTest.getImage(imageSettings, DEFAULT_REGION, DEFAULT_PLATFORM));
    String exceptionMessage = "Could not find any image with id: 'fake-ami-0a6931aea1415eb0e' in region 'eu-west-1' with OS 'redhat7'.";
    assertEquals(exceptionMessage, exception.getMessage());
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) Test(org.junit.jupiter.api.Test)

Example 32 with ImageSettingsRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.

the class CoreImageProviderTest method testGetImagesdReturnsEmptyListWhenExceptionThrown.

@Test
public void testGetImagesdReturnsEmptyListWhenExceptionThrown() throws Exception {
    when(imageCatalogV4Endpoint.getImagesByName(WORKSPACE_ID_DEFAULT, CATALOG_NAME, null, PLATFORM, null, null, false)).thenThrow(new Exception());
    ImageSettingsRequest imageSettings = new ImageSettingsRequest();
    imageSettings.setCatalog(CATALOG_NAME);
    List<ImageWrapper> result = victim.getImages(imageSettings, "", PLATFORM);
    assertTrue(result.isEmpty());
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.jupiter.api.Test)

Example 33 with ImageSettingsRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.

the class CoreImageProviderTest method testGetImages.

@Test
public void testGetImages() throws Exception {
    ImagesV4Response imagesV4Response = new ImagesV4Response();
    imagesV4Response.setFreeipaImages(List.of(anImageResponse()));
    when(imageCatalogV4Endpoint.getImagesByName(WORKSPACE_ID_DEFAULT, CATALOG_NAME, null, PLATFORM, null, null, false)).thenReturn(imagesV4Response);
    ImageSettingsRequest imageSettings = new ImageSettingsRequest();
    imageSettings.setCatalog(CATALOG_NAME);
    List<ImageWrapper> result = victim.getImages(imageSettings, "", PLATFORM);
    assertEquals(1, result.size());
    ImageWrapper imageWrapper = result.get(0);
    assertEquals(CATALOG_NAME, imageWrapper.getCatalogName());
    assertNull(imageWrapper.getCatalogUrl());
    Image image = imageWrapper.getImage();
    assertEquals(DATE, image.getDate());
    assertEquals(DESCRIPTION, image.getDescription());
    assertEquals(UUID, image.getUuid());
    assertEquals(OS_TYPE, image.getOsType());
    assertEquals(VM_IMAGE_REFERENCE, image.getImageSetsByProvider().get(PLATFORM).get(REGION));
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) ImagesV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image) Test(org.junit.jupiter.api.Test)

Example 34 with ImageSettingsRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.

the class FreeIpaImageProviderTest method doTestGetImageGivenNoInput.

private void doTestGetImageGivenNoInput() {
    ImageSettingsRequest is = setupImageSettingsRequest(null, null, null);
    Image image = underTest.getImage(is, DEFAULT_REGION, DEFAULT_PLATFORM).get().getImage();
    assertEquals(DEFAULT_OS, image.getOs());
    assertEquals(LATEST_DATE_NO_INPUT, image.getDate());
    assertEquals("71851893-8340-411d-afb7-e1b55107fb10", image.getUuid());
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) Image(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)

Example 35 with ImageSettingsRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest in project cloudbreak by hortonworks.

the class FreeIpaImageProviderTest method testGetImagesNoInput.

@Test
public void testGetImagesNoInput() {
    ImageSettingsRequest imageSettingsRequest = setupImageSettingsRequest(null, null, null);
    List<ImageWrapper> images = underTest.getImages(imageSettingsRequest, DEFAULT_REGION, DEFAULT_PLATFORM);
    assertEquals(2, images.size());
    assertThat(images, everyItem(allOf(hasProperty("image", hasProperty("os", is(DEFAULT_OS))), hasProperty("catalogUrl", is(DEFAULT_CATALOG_URL)), hasProperty("catalogName", is(nullValue())))));
    assertThat(images, hasItem(allOf(hasProperty("image", allOf(hasProperty("uuid", is(IMAGE_UUID)), hasProperty("date", is(LATEST_DATE)))))));
    assertThat(images, hasItem(allOf(hasProperty("image", allOf(hasProperty("uuid", is("71851893-8340-411d-afb7-e1b55107fb10")), hasProperty("date", is(LATEST_DATE_NO_INPUT)))))));
}
Also used : ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) ImageWrapper(com.sequenceiq.freeipa.dto.ImageWrapper) Test(org.junit.jupiter.api.Test)

Aggregations

ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)57 Test (org.junit.jupiter.api.Test)41 ImageWrapper (com.sequenceiq.freeipa.dto.ImageWrapper)28 Image (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.image.Image)23 Stack (com.sequenceiq.freeipa.entity.Stack)23 ImageInfoResponse (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.ImageInfoResponse)16 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)7 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)5 FreeIpaUpgradeRequest (com.sequenceiq.freeipa.api.v1.freeipa.upgrade.model.FreeIpaUpgradeRequest)4 ImageChangeEvent (com.sequenceiq.freeipa.flow.stack.image.change.event.ImageChangeEvent)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 ImagesV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImagesV4Response)3 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)3 FlowParameters (com.sequenceiq.flow.core.FlowParameters)3 Backup (com.sequenceiq.freeipa.api.model.Backup)3 UpgradeEvent (com.sequenceiq.freeipa.flow.freeipa.upgrade.UpgradeEvent)3 ImageV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.imagecatalog.responses.ImageV4Response)2 Acceptable (com.sequenceiq.cloudbreak.common.event.Acceptable)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)2 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)2