@Test public void testUpgradeClusterByNameWhenRequestIsDryRunAndRuntimeAndRuntimeIsDisabled() { SdxUpgradeRequest request = new SdxUpgradeRequest(); request.setDryRun(true); request.setRuntime("7.1.0"); doThrow(new BadRequestException("Runtime upgrade feature is not enabled")) .when(sdxRuntimeUpgradeService).checkForUpgradeByName(eq(USER_CRN), eq(CLUSTER_NAME), eq(request), anyString()); BadRequestException exception = doAs(USER_CRN, () -> Assertions.assertThrows(BadRequestException.class, () -> underTest.upgradeClusterByName(CLUSTER_NAME, request))); Assertions.assertEquals("Runtime upgrade feature is not enabled", exception.getMessage()); }
@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);  }