Created
December 7, 2016 00:31
-
-
Save compwron/0c25cdf0a609f3957476da1215eac364 to your computer and use it in GitHub Desktop.
test that all spring db objects have timestamps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Osa wrote this :)