### Question:
EventTypeValidator implements Validator { @Override public ValidationResult validate(String subject, String input, ValidationContext context) { final String explanation = isValidEventType(input); return new ValidationResult.Builder() .subject(subject) .input(input) .valid(explanation == null) .explanation(explanation) .build(); }  @Override ValidationResult validate(String subject, String input, ValidationContext context);  }### Answer:
@Test public void nullInputShouldProperlyFail() throws Exception { String subject = "subject"; String input = null; ValidationResult result = eventTypeValidator.validate(subject, input, context); assertEquals("subject", result.getSubject()); assertEquals(null, result.getInput()); assertEquals("Empty event types are not allowed.", result.getExplanation()); assertFalse(result.isValid()); }
@Test public void emptyInputShouldProperlyFail() throws Exception { String subject = "subject"; String input = ""; ValidationResult result = eventTypeValidator.validate(subject, input, context); assertEquals("subject", result.getSubject()); assertEquals("", result.getInput()); assertEquals("Empty event types are not allowed.", result.getExplanation()); assertFalse(result.isValid()); }
@Test public void validEventTypesShouldProperlyValidate() throws Exception { String input = " append, Create, CLOSE"; String subject = "subject"; ValidationResult result = eventTypeValidator.validate(subject, input, context); assertEquals("subject", result.getSubject()); assertEquals(" append, Create, CLOSE", result.getInput()); assertEquals("", result.getExplanation()); assertTrue(result.isValid()); }
@Test public void inputWithInvalidEventTypeShouldProperlyDisplayEventsInExplanation() throws Exception { String subject = "subject"; String input = "append, CREATE, invalidValue1, rename, metadata, unlink"; ValidationResult result = eventTypeValidator.validate(subject, input, context); assertEquals("subject", result.getSubject()); assertEquals("append, CREATE, invalidValue1, rename, metadata, unlink", result.getInput()); assertEquals("The following are not valid event types: [invalidValue1]", result.getExplanation()); assertFalse(result.isValid()); }
@Test public void inputWithMultipleInvalidEventTypeShouldProperlyDisplayEventsInExplanation() throws Exception { String subject = "subject"; String input = "append, CREATE, invalidValue1, rename, metadata, unlink, invalidValue2"; ValidationResult result = eventTypeValidator.validate(subject, input, context); assertEquals("subject", result.getSubject()); assertEquals("append, CREATE, invalidValue1, rename, metadata, unlink, invalidValue2", result.getInput()); assertEquals("The following are not valid event types: [invalidValue1, invalidValue2]", result.getExplanation()); assertFalse(result.isValid()); }