@Test public void testValidateEntitlementAndDisableIfNotEntitledWhenAccountNotEntitledThenDisableAutoscaling() { aCluster.setCloudPlatform("AWS"); when(entitlementValidationService.autoscalingEntitlementEnabled(ThreadBasedUserCrnProvider.getUserCrn(), ThreadBasedUserCrnProvider.getAccountId(), "AWS")).thenReturn(false); when(messagesService.getMessage(AUTOSCALING_ENTITLEMENT_NOT_ENABLED, List.of(aCluster.getCloudPlatform(), aCluster.getStackName()))).thenReturn("account.not.entitled.for.platform"); expectedException.expect(BadRequestException.class); expectedException.expectMessage("account.not.entitled.for.platform"); underTest.validateEntitlementAndDisableIfNotEntitled(aCluster); verify(asClusterCommonService, times(1)).setAutoscaleState(aCluster.getId(), false); }
public void validateEntitlementAndDisableIfNotEntitled(Cluster cluster) { if (!entitlementValidationService.autoscalingEntitlementEnabled( ThreadBasedUserCrnProvider.getUserCrn(), ThreadBasedUserCrnProvider.getAccountId(), cluster.getCloudPlatform())) { if (cluster.getAutoscalingEnabled()) { asClusterCommonService.setAutoscaleState(cluster.getId(), false); } throw new BadRequestException(messagesService.getMessage(MessageCode.AUTOSCALING_ENTITLEMENT_NOT_ENABLED, List.of(cluster.getCloudPlatform(), cluster.getStackName()))); } }
AlertValidator { public void validateEntitlementAndDisableIfNotEntitled(Cluster cluster) { if (!entitlementValidationService.autoscalingEntitlementEnabled( ThreadBasedUserCrnProvider.getUserCrn(), ThreadBasedUserCrnProvider.getAccountId(), cluster.getCloudPlatform())) { if (cluster.getAutoscalingEnabled()) { asClusterCommonService.setAutoscaleState(cluster.getId(), false); } throw new BadRequestException(messagesService.getMessage(MessageCode.AUTOSCALING_ENTITLEMENT_NOT_ENABLED, List.of(cluster.getCloudPlatform(), cluster.getStackName()))); } } }
AlertValidator { public void validateEntitlementAndDisableIfNotEntitled(Cluster cluster) { if (!entitlementValidationService.autoscalingEntitlementEnabled( ThreadBasedUserCrnProvider.getUserCrn(), ThreadBasedUserCrnProvider.getAccountId(), cluster.getCloudPlatform())) { if (cluster.getAutoscalingEnabled()) { asClusterCommonService.setAutoscaleState(cluster.getId(), false); } throw new BadRequestException(messagesService.getMessage(MessageCode.AUTOSCALING_ENTITLEMENT_NOT_ENABLED, List.of(cluster.getCloudPlatform(), cluster.getStackName()))); } }  }
AlertValidator { public void validateEntitlementAndDisableIfNotEntitled(Cluster cluster) { if (!entitlementValidationService.autoscalingEntitlementEnabled( ThreadBasedUserCrnProvider.getUserCrn(), ThreadBasedUserCrnProvider.getAccountId(), cluster.getCloudPlatform())) { if (cluster.getAutoscalingEnabled()) { asClusterCommonService.setAutoscaleState(cluster.getId(), false); } throw new BadRequestException(messagesService.getMessage(MessageCode.AUTOSCALING_ENTITLEMENT_NOT_ENABLED, List.of(cluster.getCloudPlatform(), cluster.getStackName()))); } }  void validateEntitlementAndDisableIfNotEntitled(Cluster cluster); void validateSupportedHostGroup(Cluster cluster, Set<String> requestHostGroups, AlertType alertType); void validateDistroXAutoscaleClusterRequest(Cluster cluster,
            DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest); void validateSchedule(TimeAlertRequest json); }
AlertValidator { public void validateEntitlementAndDisableIfNotEntitled(Cluster cluster) { if (!entitlementValidationService.autoscalingEntitlementEnabled( ThreadBasedUserCrnProvider.getUserCrn(), ThreadBasedUserCrnProvider.getAccountId(), cluster.getCloudPlatform())) { if (cluster.getAutoscalingEnabled()) { asClusterCommonService.setAutoscaleState(cluster.getId(), false); } throw new BadRequestException(messagesService.getMessage(MessageCode.AUTOSCALING_ENTITLEMENT_NOT_ENABLED, List.of(cluster.getCloudPlatform(), cluster.getStackName()))); } }  void validateEntitlementAndDisableIfNotEntitled(Cluster cluster); void validateSupportedHostGroup(Cluster cluster, Set<String> requestHostGroups, AlertType alertType); void validateDistroXAutoscaleClusterRequest(Cluster cluster,
            DistroXAutoscaleClusterRequest distroXAutoscaleClusterRequest); void validateSchedule(TimeAlertRequest json);  }