Describe the river placement, routing and grotto pool enums for the schema

This commit is contained in:
Brian Neumann-Fopiano committed 2026-09-02 11:46:29 -04:00
1 parent 1c577fc580
commit e63fd9c448
5 files changed
+70 -2

No files matched your search

@@ -248,8 +248,17 @@ public class IrisRiverSchemaTest {
private static List<String> enumValues(JSONObject definitions, JSONObject reference) {
String key = reference.getString("$ref").substring("#/definitions/".length());
JSONArray values = definitions.getJSONObject(key).getJSONArray("enum");
List<String> names = new ArrayList<>(values.length());
JSONObject definition = definitions.getJSONObject(key);
List<String> names = new ArrayList<>();
if (definition.has("oneOf")) {
// A described enum lists one {const, description} entry per value.
JSONArray options = definition.getJSONArray("oneOf");
for (int index = 0; index < options.length(); index++) {
names.add(options.getJSONObject(index).getString("const"));
}
return names;
}
JSONArray values = definition.getJSONArray("enum");
for (int index = 0; index < values.length(); index++) {
names.add(values.getString(index));
}
@@ -0,0 +1,40 @@
package art.arcane.iris.engine.object;
import art.arcane.iris.engine.object.annotations.Desc;
import org.junit.Test;
import java.lang.reflect.Field;
import java.util.List;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
public class HydrologyEnumDescriptionsTest {
private static final List<Class<? extends Enum<?>>> HYDROLOGY_ENUMS = List.of(
IrisRiverPlacementMode.class,
IrisRiverRoutingMode.class,
IrisGrottoPoolLevel.class
);
@Test
public void hydrologyEnumsDescribeThemselvesForTheSchema() {
for (Class<? extends Enum<?>> type : HYDROLOGY_ENUMS) {
Desc description = type.getAnnotation(Desc.class);
assertNotNull(type.getSimpleName() + " needs a @Desc", description);
assertFalse(type.getSimpleName() + " has a blank @Desc", description.value().isBlank());
}
}
@Test
public void everyHydrologyEnumConstantDescribesItselfForTheSchema() throws NoSuchFieldException {
for (Class<? extends Enum<?>> type : HYDROLOGY_ENUMS) {
for (Enum<?> constant : type.getEnumConstants()) {
Field field = type.getField(constant.name());
Desc description = field.getAnnotation(Desc.class);
String label = type.getSimpleName() + "." + constant.name();
assertNotNull(label + " needs a @Desc", description);
assertFalse(label + " has a blank @Desc", description.value().isBlank());
}
}
}
}