MultipleVersions implements ClassConstraint { public void check(MappedClass mc, Set<ConstraintViolation> ve) { List<MappedField> versionFields = mc.getFieldsAnnotatedWith(Version.class); if (versionFields.size() > 1) ve.add(new ConstraintViolation(Level.FATAL, mc, this.getClass(), "Multiple @" + Version.class + " annotations are not allowed. (" + new FieldEnumString(versionFields))); }  void check(MappedClass mc, Set<ConstraintViolation> ve);  }
@Test public void testCheck() { new AssertedFailure(ConstraintViolationException.class) { public void thisMustFail() throws Throwable { morphia.map(Fail1.class); } }; morphia.map(OK1.class); }