### Question:
Mammal extends AbstractOpenApiSchema { @Override public void setActualInstance(Object instance) { if (JSON.isInstanceOf(Pig.class, instance, new HashSet<Class<?>>())) { super.setActualInstance(instance); return; } if (JSON.isInstanceOf(Whale.class, instance, new HashSet<Class<?>>())) { super.setActualInstance(instance); return; } if (JSON.isInstanceOf(Zebra.class, instance, new HashSet<Class<?>>())) { super.setActualInstance(instance); return; } throw new RuntimeException("Invalid instance type. Must be Pig, Whale, Zebra"); } Mammal();  Mammal(Pig o);  Mammal(Whale o);  Mammal(Zebra o); @JsonAnySetter Mammal putAdditionalProperty(String key, Object value); @JsonAnyGetter Map<String, Object> getAdditionalProperties(); Object getAdditionalProperty(String key); @Override boolean equals(Object o); @Override int hashCode(); @Override Map<String, GenericType> getSchemas(); @Override void setActualInstance(Object instance); @Override Object getActualInstance(); Pig getPig(); Whale getWhale(); Zebra getZebra(); final static Map<String, GenericType> schemas; }### Answer:
@Test public void testGetActualInstanceRecursively() throws Exception { Mammal m = new Mammal(); Pig p = new Pig(); DanishPig dp = new DanishPig(); dp.setClassName("danish_pig"); p.setActualInstance(dp); m.setActualInstance(p); Assert.assertTrue(m.getActualInstanceRecursively() instanceof DanishPig); Pig p2 = new Pig(); m.setActualInstance(p2); Assert.assertEquals(m.getActualInstanceRecursively(), null); }