diff --git a/core/src/test/java/dev/morphia/test/query/TestQuery.java b/core/src/test/java/dev/morphia/test/query/TestQuery.java index bb0b8876221..04d40fdf8bf 100644 --- a/core/src/test/java/dev/morphia/test/query/TestQuery.java +++ b/core/src/test/java/dev/morphia/test/query/TestQuery.java @@ -836,7 +836,7 @@ public void testMultipleConstraintsOnOneField() { lt("size", 100)); Map explain = query.explain(); - Map inputStage = null; + Map inputStage; if (explain.get("explainVersion").equals("1")) { inputStage = walk(explain, List.of("queryPlanner", "winningPlan", "inputStage")); diff --git a/core/src/test/java/dev/morphia/test/query/legacy/TestLegacyQuery.java b/core/src/test/java/dev/morphia/test/query/legacy/TestLegacyQuery.java index 0ddb57cb040..b17b68ef3bc 100644 --- a/core/src/test/java/dev/morphia/test/query/legacy/TestLegacyQuery.java +++ b/core/src/test/java/dev/morphia/test/query/legacy/TestLegacyQuery.java @@ -759,9 +759,13 @@ public void testMultipleConstraintsOnOneField() { query.field("size").lessThan(100); Map explain = query.explain(); - Map queryPlanner = (Map) explain.get("queryPlanner"); - Map winningPlan = (Map) queryPlanner.get("winningPlan"); - Map inputStage = (Map) winningPlan.get("inputStage"); + Map inputStage; + + if (explain.get("explainVersion").equals("1")) { + inputStage = walk(explain, List.of("queryPlanner", "winningPlan", "inputStage")); + } else { + inputStage = walk(explain, List.of("queryPlanner", "winningPlan", "queryPlan", "inputStage")); + } assertEquals(inputStage.get("stage"), "IXSCAN"); }