@Test @DisplayName("when show latest images is requested and runtime upgrade is disabled it should set the lock components flag") public void testUpgradeClusterByNameWhenRequestIsShowLatestImagesAndRuntimeIsDisabledShouldSetLockComponent() { when(sdxRuntimeUpgradeService.isRuntimeUpgradeEnabled(USER_CRN)).thenReturn(false); SdxUpgradeRequest request = new SdxUpgradeRequest(); request.setShowAvailableImages(SdxUpgradeShowAvailableImages.LATEST_ONLY); SdxUpgradeResponse sdxUpgradeResponse = new SdxUpgradeResponse(); sdxUpgradeResponse.setReason("No image available to upgrade"); when(sdxRuntimeUpgradeService.checkForUpgradeByName(USER_CRN, CLUSTER_NAME, request, ACCOUNT_ID)).thenReturn(sdxUpgradeResponse); SdxUpgradeResponse response = doAs(USER_CRN, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request)); verify(sdxRuntimeUpgradeService, times(1)) .checkForUpgradeByName(any(), any(), upgradeRequestArgumentCaptor.capture(), anyString()); SdxUpgradeRequest capturedRequest = upgradeRequestArgumentCaptor.getValue(); assertTrue(capturedRequest.getLockComponents()); assertEquals("No image available to upgrade", response.getReason()); }
@Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.UPGRADE_DATALAKE) public SdxUpgradeResponse upgradeClusterByName(@ResourceName String clusterName, SdxUpgradeRequest request) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); lockComponentsIfRuntimeUpgradeIsDisabled(request, userCrn, clusterName); if (request.isDryRun() || request.isShowAvailableImagesSet()) { return sdxRuntimeUpgradeService.checkForUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } else { return sdxRuntimeUpgradeService.triggerUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } }
SdxUpgradeController implements SdxUpgradeEndpoint { @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.UPGRADE_DATALAKE) public SdxUpgradeResponse upgradeClusterByName(@ResourceName String clusterName, SdxUpgradeRequest request) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); lockComponentsIfRuntimeUpgradeIsDisabled(request, userCrn, clusterName); if (request.isDryRun() || request.isShowAvailableImagesSet()) { return sdxRuntimeUpgradeService.checkForUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } else { return sdxRuntimeUpgradeService.triggerUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } } }
SdxUpgradeController implements SdxUpgradeEndpoint { @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.UPGRADE_DATALAKE) public SdxUpgradeResponse upgradeClusterByName(@ResourceName String clusterName, SdxUpgradeRequest request) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); lockComponentsIfRuntimeUpgradeIsDisabled(request, userCrn, clusterName); if (request.isDryRun() || request.isShowAvailableImagesSet()) { return sdxRuntimeUpgradeService.checkForUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } else { return sdxRuntimeUpgradeService.triggerUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } }  }
SdxUpgradeController implements SdxUpgradeEndpoint { @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.UPGRADE_DATALAKE) public SdxUpgradeResponse upgradeClusterByName(@ResourceName String clusterName, SdxUpgradeRequest request) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); lockComponentsIfRuntimeUpgradeIsDisabled(request, userCrn, clusterName); if (request.isDryRun() || request.isShowAvailableImagesSet()) { return sdxRuntimeUpgradeService.checkForUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } else { return sdxRuntimeUpgradeService.triggerUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } }  @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.UPGRADE_DATALAKE) SdxUpgradeResponse upgradeClusterByName(@ResourceName String clusterName, SdxUpgradeRequest request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.UPGRADE_DATALAKE) SdxUpgradeResponse upgradeClusterByCrn(@ResourceCrn String clusterCrn, SdxUpgradeRequest request); }
SdxUpgradeController implements SdxUpgradeEndpoint { @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.UPGRADE_DATALAKE) public SdxUpgradeResponse upgradeClusterByName(@ResourceName String clusterName, SdxUpgradeRequest request) { String userCrn = ThreadBasedUserCrnProvider.getUserCrn(); lockComponentsIfRuntimeUpgradeIsDisabled(request, userCrn, clusterName); if (request.isDryRun() || request.isShowAvailableImagesSet()) { return sdxRuntimeUpgradeService.checkForUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } else { return sdxRuntimeUpgradeService.triggerUpgradeByName(userCrn, clusterName, request, ThreadBasedUserCrnProvider.getAccountId()); } }  @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.UPGRADE_DATALAKE) SdxUpgradeResponse upgradeClusterByName(@ResourceName String clusterName, SdxUpgradeRequest request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.UPGRADE_DATALAKE) SdxUpgradeResponse upgradeClusterByCrn(@ResourceCrn String clusterCrn, SdxUpgradeRequest request);  }