### Question:
FunctionUtils { public static int toTensorIndex(int[] indices, int[] dimensions) { ArgChecker.notNull(indices, "indices"); ArgChecker.notNull(dimensions, "dimensions"); int dim = indices.length; ArgChecker.isTrue(dim == dimensions.length); int sum = 0; int product = 1; for (int i = 0; i < dim; i++) { ArgChecker.isTrue(indices[i] < dimensions[i], "index out of bounds"); sum += indices[i] * product; product *= dimensions[i]; } return sum; } private  FunctionUtils(); @Deprecated static double square(double x); @Deprecated static double cube(double x); static int toTensorIndex(int[] indices, int[] dimensions); static int[] fromTensorIndex(int index, int[] dimensions); static double[] unique(double[] in); static int[] unique(int[] in); static int getLowerBoundIndex(DoubleArray set, double value);  }### Answer:
@Test public void testNullIndices() { assertThatIllegalArgumentException() .isThrownBy(() -> FunctionUtils.toTensorIndex(null, new int[] {1, 2, 3})); }
@Test public void testNullDimensions1() { assertThatIllegalArgumentException() .isThrownBy(() -> FunctionUtils.toTensorIndex(new int[] {1, 2, 3}, null)); }
@Test public void testWrongLength() { assertThatIllegalArgumentException() .isThrownBy(() -> FunctionUtils.toTensorIndex(new int[] {1, 2}, new int[] {1, 2, 3})); }
@Test public void testOutOfBounds() { final int[] indices = new int[] {2, 7, 1}; final int[] dimensions = new int[] {5, 7, 3}; assertThatIllegalArgumentException() .isThrownBy(() -> FunctionUtils.toTensorIndex(indices, dimensions)); }