Skip to content

Commit c834d2f

Browse files
Merge pull request #3543 from DataDog/datadog-api-spec/test/archana.asokan/DASHB-589-group-by-fields-v2
Fix BDD test lookup to handle oneOf wrappers for array indexing
2 parents 97093fc + 18a68b1 commit c834d2f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/test/java/com/datadog/api/World.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,17 @@ public static Object lookup(Object data, String path)
681681
}
682682
if (part.contains("]")) {
683683
int index = Integer.parseInt(part.replaceAll("]", ""));
684-
result = List.class.cast(result).get(index);
684+
// Unwrap oneOf wrapper before indexing into array
685+
try {
686+
result = List.class.cast(result).get(index);
687+
} catch (ClassCastException e) {
688+
try {
689+
Object unwrapped = result.getClass().getMethod("getActualInstance").invoke(result);
690+
result = List.class.cast(unwrapped).get(index);
691+
} catch (Exception ex) {
692+
throw e;
693+
}
694+
}
685695
} else {
686696
try {
687697
result = HashMap.class.cast(result).get(part);

0 commit comments

Comments
 (0)