Search in sources :

Example 1 with ChangeImageCatalogV4Request

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

the class StackV4ControllerTest method changeImageCatalogInternalTest.

@Test
void changeImageCatalogInternalTest() {
    when(restRequestThreadLocalService.getRequestedWorkspaceId()).thenReturn(WORKSPACE_ID);
    String imageCatalog = "image-catalog";
    ChangeImageCatalogV4Request request = new ChangeImageCatalogV4Request();
    request.setImageCatalog(imageCatalog);
    underTest.changeImageCatalogInternal(WORKSPACE_ID, STACK_NAME, USER_CRN, request);
    verify(stackOperations).changeImageCatalog(NameOrCrn.ofName(STACK_NAME), WORKSPACE_ID, imageCatalog);
}
Also used : ChangeImageCatalogV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.ChangeImageCatalogV4Request) Test(org.junit.jupiter.api.Test)

Example 2 with ChangeImageCatalogV4Request

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

the class DistroXV1ControllerTest method testChangeImageCatalog.

@Test
void testChangeImageCatalog() {
    ChangeImageCatalogV4Request request = new ChangeImageCatalogV4Request();
    request.setImageCatalog(IMAGE_CATALOG);
    when(workspaceService.getForCurrentUser()).thenReturn(workspace);
    when(workspace.getId()).thenReturn(WORKSPACE_ID);
    distroXV1Controller.changeImageCatalog(NAME, request);
    verify(stackOperations).changeImageCatalog(nameOrCrnArgumentCaptor.capture(), Mockito.eq(WORKSPACE_ID), Mockito.eq(IMAGE_CATALOG));
    assertEquals(NAME, nameOrCrnArgumentCaptor.getValue().getName());
}
Also used : ChangeImageCatalogV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.ChangeImageCatalogV4Request) Test(org.junit.jupiter.api.Test)

Example 3 with ChangeImageCatalogV4Request

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

the class SdxImageCatalogService method changeImageCatalog.

public void changeImageCatalog(SdxCluster sdxCluster, String imageCatalog) {
    if (flowLogService.isOtherFlowRunning(sdxCluster.getId())) {
        throw new CloudbreakApiException(String.format("Operation is running for cluster '%s'. Please try again later.", sdxCluster.getName()));
    }
    try {
        ChangeImageCatalogV4Request changeImageCatalogRequest = new ChangeImageCatalogV4Request();
        changeImageCatalogRequest.setImageCatalog(imageCatalog);
        String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
        ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.changeImageCatalogInternal(WORKSPACE_ID_DEFAULT, sdxCluster.getClusterName(), initiatorUserCrn, changeImageCatalogRequest));
    } catch (CloudbreakServiceException e) {
        throw new CloudbreakApiException(e.getMessage(), e);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) ChangeImageCatalogV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.ChangeImageCatalogV4Request) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException)

Aggregations

ChangeImageCatalogV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.ChangeImageCatalogV4Request)3 Test (org.junit.jupiter.api.Test)2 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)1