### Question:
Group { public Optional<Dimension> findDimension(String name) { if (name == null) return Optional.empty(); Dimension d = findDimensionLocal(name); if (d != null) return Optional.of(d); Group parent = getParentGroup(); if (parent != null) return parent.findDimension(name); return Optional.empty(); } private  Group(Builder builder, @Nullable Group parent); AttributeContainer attributes(); Group commonParent(Group other); @Nullable Attribute findAttribute(String name); String findAttributeString(String attName, String defaultValue); Optional<Dimension> findDimension(String name); @Nullable Dimension findDimension(Dimension dim); @Nullable Dimension findDimensionLocal(String shortName); @Nullable EnumTypedef findEnumeration(String name); @Nullable Group findGroupLocal(String groupShortName); Optional<Group> findGroupNested(String groupShortName); @Nullable Variable findVariableByAttribute(String attName, String attValue); @Nullable Variable findVariableLocal(String varShortName); @Nullable Variable findVariableOrInParent(String varShortName); ImmutableList<Dimension> getDimensions(); ImmutableList<EnumTypedef> getEnumTypedefs(); String getFullName(); ImmutableList<Group> getGroups(); NetcdfFile getNetcdfFile(); @Nullable Group getParentGroup(); String getShortName(); ImmutableList<Variable> getVariables(); boolean isParent(Group other); boolean isRoot(); ImmutableList<Dimension> makeDimensionsList(String dimString); String getNameAndAttributes(); @Override String toString(); @Override boolean equals(Object oo); @Override int hashCode(); Builder toBuilder(); static Builder builder();  }### Answer:
@Test public void testFindDimension() { Dimension low = new Dimension("low", 1); Dimension mid = new Dimension("mid", 1); Dimension high = new Dimension("high", 1); Group.Builder parentg = Group.builder().setName("parent").addDimension(low); Group.Builder grampsb = Group.builder().setName("gramps").addGroup(parentg).addDimension(mid); Group.Builder uncleb = Group.builder().setName("uncle"); Group root = Group.builder().addGroup(grampsb).addGroup(uncleb).addDimension(high).build(); Group parent = root.findGroupNested("parent").orElse(null); assertThat(parent).isNotNull(); Group gramps = root.findGroupNested("gramps").orElse(null); assertThat(gramps).isNotNull(); Group uncle = root.findGroupNested("uncle").orElse(null); assertThat(uncle).isNotNull(); assertThat(parent.findDimension("low").isPresent()).isTrue(); assertThat(parent.findDimension("mid").isPresent()).isTrue(); assertThat(parent.findDimension("high").isPresent()).isTrue(); assertThat(gramps.findDimension("low").isPresent()).isFalse(); assertThat(gramps.findDimension("mid").isPresent()).isTrue(); assertThat(gramps.findDimension("high").isPresent()).isTrue(); assertThat(root.findDimension("low").isPresent()).isFalse(); assertThat(root.findDimension("mid").isPresent()).isFalse(); assertThat(root.findDimension("high").isPresent()).isTrue(); assertThat(uncle.findDimension("low").isPresent()).isFalse(); assertThat(uncle.findDimension("mid").isPresent()).isFalse(); assertThat(uncle.findDimension("high").isPresent()).isTrue(); assertThat(parent.findDimension(low) != null).isTrue(); assertThat(parent.findDimension(mid) != null).isTrue(); assertThat(parent.findDimension(high) != null).isTrue(); assertThat(gramps.findDimension(low) != null).isFalse(); assertThat(gramps.findDimension(mid) != null).isTrue(); assertThat(gramps.findDimension(high) != null).isTrue(); assertThat(root.findDimension(low) != null).isFalse(); assertThat(root.findDimension(mid) != null).isFalse(); assertThat(root.findDimension(high) != null).isTrue(); assertThat(uncle.findDimension(low) != null).isFalse(); assertThat(uncle.findDimension(mid) != null).isFalse(); assertThat(uncle.findDimension(high) != null).isTrue(); assertThat(uncle.findDimension((Dimension) null) == null).isTrue(); assertThat(uncle.findDimension((String) null).isPresent()).isFalse(); assertThat(parent.findDimensionLocal(null) != null).isFalse(); }