SchematronValidator extends AbstractSchematronValidator { public ApplicableSchematron getApplicableSchematron(final int metadataId, final Element md, final MetadataSchema metadataSchema, final Schematron schematron) { final ConfigurableApplicationContext applicationContext = ApplicationContextHolder.get(); SchematronCriteriaGroupRepository criteriaGroupRepository = applicationContext.getBean(SchematronCriteriaGroupRepository.class); List<SchematronCriteriaGroup> criteriaGroups = criteriaGroupRepository.findAllById_SchematronId(schematron.getId()); SchematronRequirement requirement = SchematronRequirement.DISABLED; for (SchematronCriteriaGroup criteriaGroup : criteriaGroups) { List<SchematronCriteria> criteriaList = criteriaGroup.getCriteria(); boolean apply = false; for (SchematronCriteria criteria : criteriaList) { apply = criteria.accepts(applicationContext, metadataId, md, metadataSchema.getSchemaNS()); if (!apply) { break; } } if (apply) { if (Log.isDebugEnabled(Geonet.DATA_MANAGER)) { Log.debug(Geonet.DATA_MANAGER, " - Schematron group is accepted:" + criteriaGroup.getId().getName() + " for schematron: " + schematron.getRuleName()); } requirement = requirement.highestRequirement(criteriaGroup.getRequirement()); } else { requirement = requirement.highestRequirement(SchematronRequirement.DISABLED); } } return new ApplicableSchematron(requirement, schematron); }  Element applyCustomSchematronRules(String schema, int metadataId, Element md,
                                              String lang, List<MetadataValidation> validations); List<ApplicableSchematron> getApplicableSchematronList(final int metadataId,
                                                           final Element md,
                                                           final MetadataSchema metadataSchema); ApplicableSchematron getApplicableSchematron(final int metadataId,
                                                 final Element md,
                                                 final MetadataSchema metadataSchema,
                                                 final Schematron schematron);  }
@Test public void testGetApplicableSchematron() throws Exception { ApplicableSchematron applicableSchematron = schematronValidator.getApplicableSchematron(id, metadata, schema, schematron); assertEquals(SchematronRequirement.REQUIRED, applicableSchematron.requirement); }