### Question:
ClusterInfo implements Serializable { public synchronized void update(double[] newPoint, long newCount) { int length = center.length; Preconditions.checkArgument(length == newPoint.length); double[] newCenter = new double[length]; long newTotalCount = newCount + count; double newToTotal = (double) newCount / newTotalCount; for (int i = 0; i < length; i++) { double centerI = center[i]; newCenter[i] = centerI + newToTotal * (newPoint[i] - centerI); } center = newCenter; count = newTotalCount; } ClusterInfo(int id, double[] center, long initialCount); int getID(); double[] getCenter(); long getCount(); synchronized void update(double[] newPoint, long newCount); @Override synchronized String toString();  }### Answer:
@Test public void testUpdate() { ClusterInfo info = new ClusterInfo(0, new double[] { -1.0, 2.0 }, 2); assertEquals(0, info.getID()); assertArrayEquals(new double[]{-1.0, 2.0}, info.getCenter()); assertEquals(2, info.getCount()); assertEquals("0 [-1.0, 2.0] 2", info.toString()); info.update(new double[] { -1.0, -1.0 }, 1); assertEquals(0, info.getID()); assertArrayEquals(new double[] { -1.0, 1.0 }, info.getCenter()); assertEquals(3, info.getCount()); assertEquals("0 [-1.0, 1.0] 3", info.toString()); info.update(new double[] { 0.0, 0.0 }, 3); assertEquals(0, info.getID()); assertArrayEquals(new double[] { -0.5, 0.5 }, info.getCenter()); assertEquals(6, info.getCount()); assertEquals("0 [-0.5, 0.5] 6", info.toString()); }