Schematron extends Localized { @Transient public SchematronRequirement getDefaultRequirement() { final String lowerCaseFile = getFile().toLowerCase(); for (SchematronRequirement requirement : SchematronRequirement.values()) { if (lowerCaseFile.endsWith("." + requirement.name().toLowerCase() + ".xsl")) { return requirement; } } return SchematronRequirement.REQUIRED; }  @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = ID_SEQ_NAME) @Column(nullable = false) int getId(); Schematron setId(int id); @Override String toString(); @Column(nullable = false, name = "schemaName") String getSchemaName(); void setSchemaName(String schemaName); @Column(nullable = false, name = "filename") String getFile(); void setFile(String file); @Override @ElementCollection(fetch = FetchType.LAZY, targetClass = String.class) @CollectionTable(joinColumns = @JoinColumn(name = "idDes"), name = "SchematronDes") @MapKeyColumn(name = "langId", length = 5) @Column(name = "label", nullable = false, length = 255) Map<String, String> getLabelTranslations(); int getDisplayPriority(); void setDisplayPriority(int displayPriority); @Transient String getRuleName(); @Transient SchematronRequirement getDefaultRequirement(); @Override boolean equals(Object o); @Override int hashCode(); static final Comparator<? super Schematron> DISPLAY_PRIORITY_COMPARATOR; }
@Test public void testGetDefaultRequirement() throws Exception { final Schematron schematron = new Schematron(); schematron.setFile("xyz/bcd/abc.report_only.xsl"); assertEquals(SchematronRequirement.REPORT_ONLY, schematron.getDefaultRequirement()); schematron.setFile("xyz/bcd/abc.REPORT_ONLY.xsl"); assertEquals(SchematronRequirement.REPORT_ONLY, schematron.getDefaultRequirement()); schematron.setFile("xyz/bcd/abc.xsl"); assertEquals(SchematronRequirement.REQUIRED, schematron.getDefaultRequirement()); schematron.setFile("xyz/bcd/abc.required.xsl"); assertEquals(SchematronRequirement.REQUIRED, schematron.getDefaultRequirement()); schematron.setFile("xyz/bcd/abc.REQUIRED.xsl"); assertEquals(SchematronRequirement.REQUIRED, schematron.getDefaultRequirement()); schematron.setFile("xyz/bcd/abc.disabled.xsl"); assertEquals(SchematronRequirement.DISABLED, schematron.getDefaultRequirement()); schematron.setFile("xyz/bcd/abc.DISABLED.xsl"); assertEquals(SchematronRequirement.DISABLED, schematron.getDefaultRequirement()); }