Search in sources :

Example 1 with UsedImagesListV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response in project cloudbreak by hortonworks.

the class UsedImagesProvider method getUsedImages.

public UsedImagesListV4Response getUsedImages(Integer thresholdInDays) {
    final UsedImagesListV4Response usedImages = new UsedImagesListV4Response();
    stackService.getImagesOfAliveStacks(thresholdInDays).forEach(usedImages::addImage);
    return usedImages;
}
Also used : UsedImagesListV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response)

Example 2 with UsedImagesListV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response in project cloudbreak by hortonworks.

the class UsedImagesAction method action.

@Override
public UsedImagesTestDto action(TestContext testContext, UsedImagesTestDto testDto, CloudbreakClient client) throws Exception {
    final UsedImagesListV4Response usedImages = client.getInternalClient(testContext).utilV4Endpoint().usedImages(null);
    testDto.setResponse(usedImages);
    return testDto;
}
Also used : UsedImagesListV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response)

Example 3 with UsedImagesListV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response in project cloudbreak by hortonworks.

the class UsedImagesProviderTest method testEmpty.

@Test
void testEmpty() {
    when(stackService.getImagesOfAliveStacks(THRESHOLD_IN_DAYS)).thenReturn(List.of());
    final UsedImagesListV4Response result = underTest.getUsedImages(THRESHOLD_IN_DAYS);
    assertThat(result.getUsedImages()).isEmpty();
}
Also used : UsedImagesListV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response) Test(org.junit.jupiter.api.Test)

Example 4 with UsedImagesListV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response 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 UsedImagesListV4Response 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);
}
Also used : Test(org.junit.jupiter.api.Test) InjectMocks(org.mockito.InjectMocks) List(java.util.List) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) UsedImagesListV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) Mock(org.mockito.Mock) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Map(java.util.Map) Mockito.when(org.mockito.Mockito.when) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) UsedImagesListV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response) Test(org.junit.jupiter.api.Test)

Example 5 with UsedImagesListV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response 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 UsedImagesListV4Response result = underTest.getUsedImages(THRESHOLD_IN_DAYS);
    assertThat(result.getUsedImages()).hasSize(1).first().matches(usedImage -> usedImage.getNumberOfStacks() == 1);
}
Also used : UsedImagesListV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response) Test(org.junit.jupiter.api.Test)

Aggregations

UsedImagesListV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.util.responses.UsedImagesListV4Response)5 Test (org.junit.jupiter.api.Test)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)1 List (java.util.List)1 Map (java.util.Map)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1 InjectMocks (org.mockito.InjectMocks)1 Mock (org.mockito.Mock)1 Mockito.when (org.mockito.Mockito.when)1 MockitoExtension (org.mockito.junit.jupiter.MockitoExtension)1