### Question:
VirtualArray extends VirtualType { @Override public Set<? extends VirtualType> getImmediateAncestors() { Set<VirtualType> parents = new HashSet<>(); VirtualType componentType = getComponentType(); if (componentType.isPrimitive()) { String objectType = buildRankString(dimensionRank - 1) + CommonTypes.OBJECT; VirtualType parent = classManager.getVirtualType(objectType); parents.add(parent); } else { for (VirtualType ancestorComponent : componentType.getImmediateAncestors()) { String ancestorName = '[' + ancestorComponent.getTypeReference().getType(); VirtualArray parent = (VirtualArray) classManager.getVirtualType(ancestorName); parents.add(parent); } if (componentType.getName().endsWith(CommonTypes.OBJECT)) { parents.add(componentType); } } return parents; } VirtualArray(TypeReference typeReference); @Override Set<? extends VirtualType> getImmediateAncestors(); @Override Set<? extends VirtualType> getAncestors(); @Override VirtualField getField(String fieldName); @Override Collection<VirtualField> getFields(); @Override VirtualMethod getMethod(String methodDescriptor); @Override Collection<VirtualMethod> getMethods(); @Override boolean instanceOf(VirtualType targetType); @Override boolean isArray(); @Override boolean isPrimitive(); VirtualType getBaseType(); VirtualType getComponentType();  }### Answer:
@Test public void twoDimensionalStringArrayHasExpectedImmediateAncestors() { String arrayType = "[[" + CommonTypes.STRING; virtualArray = (VirtualArray) classManager.getVirtualType(arrayType); String[] expectedImmediateAncestorNames = new String[]{ "[[Ljava/lang/Object;", "[[Ljava/lang/CharSequence;", "[[Ljava/lang/Comparable;", "[[Ljava/io/Serializable;" }; Set<VirtualType> expectedImmediateAncestors = Arrays.stream(expectedImmediateAncestorNames).map(a -> classManager.getVirtualType(a)).collect(Collectors.toSet()); Set<? extends VirtualType> ancestors = virtualArray.getImmediateAncestors(); assertEquals(expectedImmediateAncestors, ancestors); }
@Test public void oneDimensionalStringArrayHasExpectedImmediateAncestors() { String arrayType = "[" + CommonTypes.STRING; virtualArray = (VirtualArray) classManager.getVirtualType(arrayType); String[] expectedImmediateAncestorNames = new String[]{ "[Ljava/lang/Object;", "[Ljava/lang/CharSequence;", "[Ljava/lang/Comparable;", "[Ljava/io/Serializable;" }; Set<VirtualType> expectedImmediateAncestors = Arrays.stream(expectedImmediateAncestorNames).map(a -> classManager.getVirtualType(a)).collect(Collectors.toSet()); Set<? extends VirtualType> ancestors = virtualArray.getImmediateAncestors(); assertEquals(expectedImmediateAncestors, ancestors); }