use of com.sequenceiq.freeipa.api.v1.util.model.UsedImagesListV1Response in project cloudbreak by hortonworks.
the class UsedImagesProvider method getUsedImages.
public UsedImagesListV1Response getUsedImages(Integer thresholdInDays) {
final UsedImagesListV1Response usedImages = new UsedImagesListV1Response();
stackService.getImagesOfAliveStacks(thresholdInDays).stream().map(ImageEntity::getImageId).forEach(usedImages::addImage);
return usedImages;
}
use of com.sequenceiq.freeipa.api.v1.util.model.UsedImagesListV1Response in project cloudbreak by hortonworks.
the class UsedImagesProviderTest method testMultipleImages.
@Test
void testMultipleImages() {
when(stackService.getImagesOfAliveStacks(THRESHOLD_IN_DAYS)).thenReturn(List.of(createImage("aws-image"), createImage("aws-image"), createImage("azure-image")));
final UsedImagesListV1Response result = underTest.getUsedImages(THRESHOLD_IN_DAYS);
assertThat(result.getUsedImages()).hasSize(2).anyMatch(usedImage -> usedImage.getImage().getImageId().equals("aws-image") && usedImage.getNumberOfStacks() == 2).anyMatch(usedImage -> usedImage.getImage().getImageId().equals("azure-image") && usedImage.getNumberOfStacks() == 1);
}
use of com.sequenceiq.freeipa.api.v1.util.model.UsedImagesListV1Response in project cloudbreak by hortonworks.
the class UsedImagesProviderTest method testSingleImage.
@Test
void testSingleImage() {
when(stackService.getImagesOfAliveStacks(THRESHOLD_IN_DAYS)).thenReturn(List.of(createImage("aws-image")));
final UsedImagesListV1Response result = underTest.getUsedImages(THRESHOLD_IN_DAYS);
assertThat(result.getUsedImages()).hasSize(1);
assertThat(result.getUsedImages().get(0).getNumberOfStacks()).isEqualTo(1);
}
use of com.sequenceiq.freeipa.api.v1.util.model.UsedImagesListV1Response in project cloudbreak by hortonworks.
the class UsedImagesProviderTest method testEmpty.
@Test
void testEmpty() {
when(stackService.getImagesOfAliveStacks(THRESHOLD_IN_DAYS)).thenReturn(List.of());
final UsedImagesListV1Response result = underTest.getUsedImages(THRESHOLD_IN_DAYS);
assertThat(result.getUsedImages()).isEmpty();
}
use of com.sequenceiq.freeipa.api.v1.util.model.UsedImagesListV1Response in project cloudbreak by hortonworks.
the class FreeipaUsedImagesAction method action.
@Override
public FreeipaUsedImagesTestDto action(TestContext testContext, FreeipaUsedImagesTestDto testDto, FreeIpaClient client) throws Exception {
final UsedImagesListV1Response usedImages = client.getInternalClient(testContext).utilV1Endpoint().usedImages(null);
testDto.setResponse(usedImages);
return testDto;
}
Aggregations