class CmTemplateValidator implements BlueprintValidator {

    @Override
    public void validateHostGroupScalingRequest(String userCrn, String accountId, Blueprint blueprint, HostGroup hostGroup, Integer adjustment) {
        CmTemplateProcessor templateProcessor = processorFactory.get(blueprint.getBlueprintText());
        Set<String> services = templateProcessor.getComponentsByHostGroup().get(hostGroup.getName());
        for (BlackListedDownScaleRole role : BlackListedDownScaleRole.values()) {
            if (services.contains(role.name()) && adjustment < 0) {
                if (!entitlementService.scalingServiceEnabled(userCrn, accountId, role.getEntitledFor())) {
                    throw new BadRequestException(String.format("'%s' service is not enabled to scale",
                            role.name()));
                } else {
                    LOGGER.info("Account is entitled for {} so scaling is enabled.", role.getEntitledFor());
                }
            }
        }
        for (BlackListedUpScaleRole role : BlackListedUpScaleRole.values()) {
            if (services.contains(role.name()) && adjustment > 0) {
                if (!entitlementService.scalingServiceEnabled(userCrn, accountId, role.getEntitledFor())) {
                    throw new BadRequestException(String.format("'%s' service is not enabled to scale",
                            role.name()));
                } else {
                    LOGGER.info("Account is entitled for {} so scaling is enabled.", role.getEntitledFor());
                }
            }
        }
    }

}