@Test
public void testIsInvalidAndRequiredForMetadata() throws Exception {

    MetadataValidation md1 =  _metadataValidationRepo.save(newMetadataValidation());
    md1.setValid(true);
    _metadataValidationRepo.save(md1);
    MetadataValidation md2 =  _metadataValidationRepo.save(newMetadataValidation());
    md2.setValid(false);
    _metadataValidationRepo.save(md2);
    List<MetadataValidation> found = _metadataValidationRepo.findAll(isInvalidAndRequiredForMetadata(md1.getId().getMetadataId()));
    assertEquals(0, found.size());
    found = _metadataValidationRepo.findAll(isInvalidAndRequiredForMetadata(md2.getId().getMetadataId()));
    assertEquals(1, found.size());
}