Skip to content

Instantly share code, notes, and snippets.

@compwron
Created December 7, 2016 00:31
Show Gist options
  • Save compwron/0c25cdf0a609f3957476da1215eac364 to your computer and use it in GitHub Desktop.
Save compwron/0c25cdf0a609f3957476da1215eac364 to your computer and use it in GitHub Desktop.
test that all spring db objects have timestamps
public class SanityDbComponentTest {
@Test
public void foo() throws Exception {
Reflections reflections = new Reflections("com.sonicdrivein");
Set<Class<?>> classes = reflections.getTypesAnnotatedWith(Entity.class);
for (Class<?> aClass : classes) {
validateEntity(aClass.getDeclaredMethods(), aClass.getName());
}
}
private void validateEntity(Method[] methods, String name) {
List<Method> collect = Arrays.stream(methods).filter(method -> {
System.out.println(method.getName());
return method.getName() == "getCreatedAt" || method.getName() == "getUpdatedAt";
})
.collect(Collectors.toList());
assertThat("Class " + name, collect.size(), is(2));
}
}
@compwron
Copy link
Author

compwron commented Dec 7, 2016

Osa wrote this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment