test_class.file: wraith-engine/src/test/java/io/symcpe/wraith/rules/validator/TestAlertTemplateValidator.java
test_class.identifier: TestAlertTemplateValidator
test_case.body: @Test
  	public void testMailAlertTemplateNegative() {
  		AlertTemplateValidator validator = new AlertTemplateValidator();
  		AlertTemplate template = new AlertTemplate((short)2);
  		try{
  			validator.validate(template);
  			fail("Invalid template, can't pass test");
  		}catch(ValidationException e) {
  		}
  		template.setSubject("hello");
  		template.setBody("hello $x");
  		template.setTemplateName("Template");
  		template.setDestination("abc@xyz.com, efg@xyz.com");
  		template.setMedia("test");
  		try{
  			validator.validate(template);
  			fail("Invalid template, can't pass test");
  		}catch(ValidationException e) {
  		}
  		template.setDestination("abc@xyz.com, efg@xy.c");
  		try{
  			validator.validate(template);
  			fail("Invalid template, can't pass test");
  		}catch(ValidationException e) {
  		}
  		template.setDestination("abc@xyz.com,efg@xy.c");
  		try{
  			validator.validate(template);
  			fail("Invalid template, can't pass test");
  		}catch(ValidationException e) {
  		}
  		template.setDestination("hello924jwjaksfsduufasidjfhkasdjfadsf9asfijklsdfoasdljfo9sdfpiojkasdfoasjdifaisdpfjasdl;fiaosdf9posdjklfasdfhaosdif9paidsujklfasdfa09wrjiwqjrwfjoifjlas@xyz.com");
  		try{
  			validator.validate(template);
  			fail("Invalid template, can't pass test");
  		}catch(ValidationException e) {
  		}
  	}
test_case.class_method_signature: TestAlertTemplateValidator.testMailAlertTemplateNegative()
test_case.full_signature: @Test public void testMailAlertTemplateNegative()
test_case.identifier: testMailAlertTemplateNegative
test_case.invocations: validate fail setSubject setBody setTemplateName setDestination setMedia validate fail setDestination validate fail setDestination validate fail setDestination validate fail
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMailAlertTemplateNegative()
focal_class.declarator: MAX_LENGTH_ALERT_DESTINATION = 200
focal_class.modifier: private static final
focal_class.original_string: private static final int MAX_LENGTH_ALERT_DESTINATION = 200;
focal_class.type: int
focal_class.var_name: MAX_LENGTH_ALERT_DESTINATION
focal_class.declarator: MAX_LENGTH_ALERT_MEDIA = 50
focal_class.modifier: private static final
focal_class.original_string: private static final int MAX_LENGTH_ALERT_MEDIA = 50;
focal_class.type: int
focal_class.var_name: MAX_LENGTH_ALERT_MEDIA
focal_class.declarator: EMAIL_PATTERN = Pattern
  			.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern EMAIL_PATTERN = Pattern
  			.compile("^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
focal_class.type: Pattern
focal_class.var_name: EMAIL_PATTERN
focal_class.declarator: HTTP_PATTERN = Pattern.compile("^https?\\://.*")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern HTTP_PATTERN = Pattern.compile("^https?\\://.*");
focal_class.type: Pattern
focal_class.var_name: HTTP_PATTERN
focal_class.declarator: SLACK_PATTERN = Pattern.compile("[a-zA-Z0-9/]{10,}@[a-z0-9\\_\\-]{1,21}")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern SLACK_PATTERN = Pattern.compile("[a-zA-Z0-9/]{10,}@[a-z0-9\\_\\-]{1,21}");
focal_class.type: Pattern
focal_class.var_name: SLACK_PATTERN
focal_class.declarator: alertTemplateValidator
focal_class.modifier: private
focal_class.original_string: private List<Validator<AlertTemplate>> alertTemplateValidator;
focal_class.type: List<Validator<AlertTemplate>>
focal_class.var_name: alertTemplateValidator
focal_class.file: wraith-engine/src/main/java/io/symcpe/wraith/rules/validator/AlertTemplateValidator.java
focal_class.identifier: AlertTemplateValidator
focal_class.interfaces: implements Validator<AlertTemplate>
focal_class.class_method_signature: AlertTemplateValidator.AlertTemplateValidator()
focal_class.full_signature: public  AlertTemplateValidator()
focal_class.identifier: AlertTemplateValidator
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  AlertTemplateValidator()
focal_class.class_method_signature: AlertTemplateValidator.configure(List<Validator<?>> validators)
focal_class.full_signature: @SuppressWarnings("unchecked") @Override public void configure(List<Validator<?>> validators)
focal_class.identifier: configure
focal_class.modifiers: @SuppressWarnings("unchecked") @Override public
focal_class.parameters: (List<Validator<?>> validators)
focal_class.return: void
focal_class.signature: void configure(List<Validator<?>> validators)
focal_class.class_method_signature: AlertTemplateValidator.validate(AlertTemplate template)
focal_class.full_signature: @Override public void validate(AlertTemplate template)
focal_class.identifier: validate
focal_class.modifiers: @Override public
focal_class.parameters: (AlertTemplate template)
focal_class.return: void
focal_class.signature: void validate(AlertTemplate template)
focal_method.body: @Override
  	public void validate(AlertTemplate template) throws ValidationException {
  		if (template.getDestination() == null || template.getDestination().trim().isEmpty()) {
  			throw new ValidationException("Alert target can't be empty");
  		}
  		if (template.getDestination().length() > MAX_LENGTH_ALERT_DESTINATION) {
  			throw new ValidationException(
  					"Alert target must be less than " + MAX_LENGTH_ALERT_DESTINATION + " characters");
  		}
  		if (template.getMedia() == null || template.getMedia().trim().isEmpty()) {
  			throw new ValidationException("Alert media can't be empty");
  		}
  		if (template.getMedia().length() > MAX_LENGTH_ALERT_MEDIA) {
  			throw new ValidationException("Alert media must be less than " + MAX_LENGTH_ALERT_MEDIA + " characters");
  		}
  		if (template.getBody() == null || template.getBody().trim().isEmpty()) {
  			throw new ValidationException("Template body can't be empty");
  		}
  		if (template.getTemplateName() == null || template.getTemplateName().trim().isEmpty()) {
  			throw new ValidationException("Template name can't be empty");
  		}
  		if (template.getThrottleDuration() < 1) {
  			throw new ValidationException("Throttle duration can't be less than 1");
  		}
  		if (template.getThrottleLimit() < 1) {
  			throw new ValidationException("Throttle limit can't be less than 1");
  		}
  		switch (template.getMedia()) {
  		case "mail":
  		case "http":
  		case "slack":
  			break;
  		default:
  			throw new ValidationException("Bad media type, only mail and http are allowed");
  		}
  		if (template.getMedia().contains("mail")) {
  			String[] emails = template.getDestination().split("\\s{0,1},");
  			for (String email : emails) {
  				if (!EMAIL_PATTERN.matcher(email.trim()).matches()) {
  					throw new ValidationException("Not a valid email address:" + email);
  				}
  			}
  		} else if (template.getMedia().contains("http")) {
  			if (!HTTP_PATTERN.matcher(template.getDestination()).matches()) {
  				throw new ValidationException("Not a valid http address:" + template.getDestination());
  			}
  		} else if (template.getMedia().contains("slack")) {
  			if (!SLACK_PATTERN.matcher(template.getDestination()).matches()) {
  				throw new ValidationException("Not a valid slack address:" + template.getDestination());
  			}
  		}
  		for (Validator<AlertTemplate> validator : alertTemplateValidator) {
  			validator.validate(template);
  		}
  	}
focal_method.class_method_signature: AlertTemplateValidator.validate(AlertTemplate template)
focal_method.full_signature: @Override public void validate(AlertTemplate template)
focal_method.identifier: validate
focal_method.invocations: getDestination isEmpty trim getDestination length getDestination getMedia isEmpty trim getMedia length getMedia getBody isEmpty trim getBody getTemplateName isEmpty trim getTemplateName getThrottleDuration getThrottleLimit getMedia contains getMedia split getDestination matches matcher trim contains getMedia matches matcher getDestination getDestination contains getMedia matches matcher getDestination getDestination validate
focal_method.modifiers: @Override public
focal_method.parameters: (AlertTemplate template)
focal_method.return: void
focal_method.signature: void validate(AlertTemplate template)