-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathTypeTester.java
More file actions
30 lines (25 loc) · 1.02 KB
/
TypeTester.java
File metadata and controls
30 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package bwapi;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
class TypeTester {
private TypeTester() {
// Utility class
}
static void ensureSimpleGettersReturnNonNullAndDontFail(Class<? extends Enum<?>> typeEnumClass) throws InvocationTargetException, IllegalAccessException {
List<Method> simpleGetters = Arrays.stream(typeEnumClass.getMethods())
.filter(it -> it.getParameterCount() == 0 && it.getReturnType() != Void.TYPE)
.collect(Collectors.toList());
for (Enum<?> type : typeEnumClass.getEnumConstants()) {
for (Method getter : simpleGetters) {
// WHEN
Object result = getter.invoke(type);
// THEN
assertThat(result).describedAs("When calling " + getter.getName()).isNotNull();
}
}
}
}