AnnotationEntityDataModelFactory implements EntityDataModelFactory { public AnnotationEntityDataModelFactory addClass(Class<?> cls) { EdmEntity entityAnnotation = cls.getAnnotation(EdmEntity.class); EdmComplex complexAnnotation = cls.getAnnotation(EdmComplex.class); EdmFunction functionAnnotation = cls.getAnnotation(EdmFunction.class); EdmFunctionImport functionImportAnnotation = cls.getAnnotation(EdmFunctionImport.class); EdmAction actionAnnotation = cls.getAnnotation(EdmAction.class); EdmActionImport actionImportAnnotation = cls.getAnnotation(EdmActionImport.class); EdmEnum enumAnnotation = cls.getAnnotation(EdmEnum.class); Set<Annotation> annotations = new HashSet<>(); annotations.add(entityAnnotation); annotations.add(complexAnnotation); annotations.add(functionAnnotation); annotations.add(functionImportAnnotation); annotations.add(actionAnnotation); annotations.add(actionImportAnnotation); annotations.add(enumAnnotation); checkClassPrecondition(annotations, cls); if (entityAnnotation != null) { entityClasses.add(cls); } else if (complexAnnotation != null) { complexClasses.add(cls); } else if (functionAnnotation != null) { functionClasses.add(cls); } else if (functionImportAnnotation != null) { functionImportClasses.add(cls); } else if (actionAnnotation != null) { actionClasses.add(cls); } else if (actionImportAnnotation != null) { actionImportClasses.add(cls); } else if (enumAnnotation != null) { if (!cls.isEnum()) { throw new IllegalArgumentException("The EdmEnum annotation must only be used on enum classes: " + cls.getName()); } enumClasses.add(cls); } return this; } AnnotationEntityDataModelFactory(); void setSchemaAlias(String namespace, String alias); AnnotationEntityDataModelFactory addClass(Class<?> cls); AnnotationEntityDataModelFactory addClasses(Iterable<Class<?>> classes); void addTypeDefinition(TypeDefinition typeDefinition); @Override EntityDataModel buildEntityDataModel();  }
@Test(expected = IllegalArgumentException.class) public void testIncorrectClassAdd() { factory.addClass(Object.class); }