SurfaceValue { public double toSingleValue() { double amount = 0; for (final DoublesPair point : _data.keySet()) { amount += _data.get(point); } return amount; } SurfaceValue(); private  SurfaceValue(final HashMap<DoublesPair, Double> map); static SurfaceValue from(final DoublesPair point, final Double value); static SurfaceValue from(final Map<DoublesPair, Double> map); static SurfaceValue from(final SurfaceValue surface); HashMap<DoublesPair, Double> getMap(); void add(final DoublesPair point, final Double value); int getNumberOfElements(); static SurfaceValue plus(final SurfaceValue value1, final SurfaceValue value2); static SurfaceValue plus(final SurfaceValue surfaceValue, final DoublesPair point, final Double value); static SurfaceValue multiplyBy(final SurfaceValue surfaceValue, final double factor); static boolean compare(final SurfaceValue value1, final SurfaceValue value2, final double tolerance); double toSingleValue(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void toSingleValue() { DoublesPair point1 = DoublesPair.of(1.0, 2.0); double value1 = 2345.678; SurfaceValue surf1 = SurfaceValue.from(point1, value1); DoublesPair point2 = DoublesPair.of(2.0, Math.PI); double value2 = 10 * Math.E; SurfaceValue surf2 = SurfaceValue.from(point2, value2); SurfaceValue surfPlus1 = SurfaceValue.plus(surf1, surf2); double amountComputed = surfPlus1.toSingleValue(); assertEquals("Surface value - single value", amountComputed, value1 + value2, TOLERANCE); }