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());
}
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());
}
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));
}
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());
}
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)))))));
}
Aggregations