### Question:
Dimensions { public static ucar.ma2.Section.Builder makeSectionFromDimensions(Iterable<Dimension> dimensions) { try { Section.Builder builder = Section.builder(); for (Dimension d : dimensions) { int len = d.getLength(); if (len > 0) builder.appendRange(new Range(d.getShortName(), 0, len - 1)); else if (len == 0) builder.appendRange(Range.EMPTY); else { assert d.isVariableLength(); builder.appendRange(Range.VLEN); } } return builder; } catch (InvalidRangeException e) { throw new IllegalStateException(e.getMessage()); } } private  Dimensions(); static ucar.ma2.Section.Builder makeSectionFromDimensions(Iterable<Dimension> dimensions); static long getSize(Iterable<Dimension> dimensions); static int[] makeShapeAll(Variable v); static int[] makeShape(Iterable<Dimension> dimensions); static String makeDimensionsString(List<Dimension> dimensions); static ImmutableList<Dimension> makeDimensionsList(FindDimensionByName finder, String dimString); static ImmutableList<Dimension> makeDimensionsAnon(int[] shape); static ImmutableList<Dimension> makeDimensionsAll(Variable v);  }### Answer:
@Test public void testMakeSectionFromDimensions() { Dimension dim1 = new Dimension("dim1", 5); Dimension dim2 = new Dimension("dim2", 6); Dimension dim3 = new Dimension("dim3", 7); Section section = Dimensions.makeSectionFromDimensions(ImmutableList.of(dim1, dim2, dim3)).build(); assertThat(section).isEqualTo(new Section(new int[] {5, 6, 7})); }
@Test public void testMakeSectionVlen() { Dimension dim1 = new Dimension("dim1", 5); Dimension dim2 = new Dimension("dim2", 6); Dimension dim3 = Dimension.builder().setIsVariableLength(true).build(); Section section = Dimensions.makeSectionFromDimensions(ImmutableList.of(dim1, dim2, dim3)).build(); assertThat(section).isEqualTo(new Section(new int[] {5, 6, -1})); }
@Test public void testMakeSectionUlim() { Dimension dim1 = new Dimension("dim1", 5); Dimension dim2 = new Dimension("dim2", 6); Dimension dim3 = Dimension.builder().setName("udim").setIsUnlimited(true).build(); Section section = Dimensions.makeSectionFromDimensions(ImmutableList.of(dim1, dim2, dim3)).build(); assertThat(section).isEqualTo(new Section(new int[] {5, 6, 0})); }