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