MClassRegistry { public void validateRequiredMProperties(Entity en) { Object value; boolean b; for (MPropertyEntry prop : getProperties(en.getClass())) { if (prop.required()) { value = prop.getValue(en); if (value instanceof String) { b = StringUtils.isNotEmpty((String)value); } else if (value instanceof Collection) { b = CollectionUtils.isNotEmpty((Collection)value); } else { b = value != null; } Preconditions.checkArgument(b, String.format("Value of required " + "property %s null or empty", prop.getField().getName())); } } for (MRelationEntry prop : getRelations(en.getClass())) { if (prop.required()) { Preconditions.checkArgument(CollectionUtils.isNotEmpty(prop .getConnectedEntities(en)), String.format("Value of required relation %s null or empty", prop.getName())); } } } MClassRegistry(String namespace); Collection<MPropertyEntry> getProperties(Class<?> aClass); Collection<MRelationEntry> getRelations(
      Class<? extends Entity> aClass); void reset(); void validateRequiredMProperties(Entity en); String getNamespace();  }
@Test public void testBasic() { registry.validateRequiredMProperties(mclassObj); }
@Test(expected = IllegalArgumentException.class) public void testBadColl() { mclassObj.setColl(null); registry.validateRequiredMProperties(mclassObj); }
@Test(expected = IllegalArgumentException.class) public void testBadStr() { mclassObj.setStrField(null); registry.validateRequiredMProperties(mclassObj); }
@Test(expected = IllegalArgumentException.class) public void testBadObj() { mclassObj.setLongField(null); registry.validateRequiredMProperties(mclassObj); }