### Question:
MetaTagsValidationEngine implements ValidationEngine<Elements> { @Override public ValidationResult run(Elements subject) { final ValidationResult validationResult = new ValidationResult(); for (ValidationRule rule : rules) { rule.check(validationResult, subject); } return validationResult; } MetaTagsValidationEngine(); @Override ValidationResult run(Elements subject);  }### Answer:
@Test public void shouldReturnValidationResultWithNoErrorsIfSubjectPassesAllChecks() throws Exception { Elements elements = new Elements(charsetElement, dublinElement); MetaTagsValidationEngine validationEngine = new MetaTagsValidationEngine(); ValidationResult validationResult = validationEngine.run(elements); assertFalse(validationResult.hasErrors()); }
@Test public void shouldReturnValidationResultWithErrorForMetaElementCharsetAttributeIfNotPresentInSubject() throws Exception { Elements elements = new Elements(dublinElement); MetaTagsValidationEngine validationEngine = new MetaTagsValidationEngine(); ValidationResult validationResult = validationEngine.run(elements); assertTrue(validationResult.hasErrors()); assertThat(validationResult.getErrors() .get(0) .getMessageCode(), is("radiology.MrrtReportTemplate.validation.error.meta.charset.occurence")); }
@Test public void shouldReturnValidationResultWithErrorForMetaElementCharsetAttributeIfPresentMoreThanOnceInSubject() throws Exception { Element otherCharsetElement = new Element(Tag.valueOf("meta"), "", charsetAttributes); Elements elements = new Elements(charsetElement, otherCharsetElement, dublinElement); MetaTagsValidationEngine validationEngine = new MetaTagsValidationEngine(); ValidationResult validationResult = validationEngine.run(elements); assertTrue(validationResult.hasErrors()); assertThat(validationResult.getErrors() .get(0) .getMessageCode(), is("radiology.MrrtReportTemplate.validation.error.meta.charset.occurence")); }
@Test public void run_shouldReturnValidationResultWithErrorForMetaElementDublinCoreIfNoMetaElementWithNameAttributeIsPresentInSubject() throws Exception { Elements elements = new Elements(charsetElement); MetaTagsValidationEngine validationEngine = new MetaTagsValidationEngine(); ValidationResult validationResult = validationEngine.run(elements); assertTrue(validationResult.hasErrors()); assertThat(validationResult.getErrors() .get(0) .getMessageCode(), is("radiology.MrrtReportTemplate.validation.error.meta.dublinCore.missing")); }