### Question:
ArrayUtils { @SuppressWarnings("PMD.AvoidArrayLoops") public static long[] toPrimitive(Long[] array) { if (array == null || array.length == 0) { return EMPTY_LONG_ARRAY; } final long[] result = new long[array.length]; for (int i = 0; i < array.length; i++) { result[i] = array[i]; } return result; } private  ArrayUtils(); @SuppressWarnings("PMD.AvoidArrayLoops") static Long[] toObject(long[] array); @SuppressWarnings("PMD.AvoidArrayLoops") static long[] toPrimitive(Long[] array);  }### Answer:
@Test public void toPrimitiveCreatesPrimitiveLongArray() throws Exception { assertArrayEquals(new long[]{1, 2, 3, 4, 5}, toPrimitive(new Long[]{1L, 2L, 3L, 4L, 5L})); }
@Test(expected = NullPointerException.class) public void arrayContainingNullCausesNpe() { toPrimitive(new Long[]{1L, null, 3L, 4L, 5L}); }
@Test(expected = NullPointerException.class) public void arrayStartingWithNullCausesNpe() { toPrimitive(new Long[]{null, 3L, 4L, 5L}); }
@Test(expected = NullPointerException.class) public void arrayEndingWithNullCausesNpe() { toPrimitive(new Long[]{1L, 3L, 4L, null}); }
@Test public void toPrimitiveCreatesPrimitiveLongArray() throws Exception { assertArrayEquals(new long[] {1, 2, 3, 4, 5}, toPrimitive(new Long[] {1L, 2L, 3L, 4L, 5L})); }
@Test public void nullToPrimitiveCreatesEmptyPrimitiveLongArray() throws Exception { assertArrayEquals(new long[0], toPrimitive(null)); }
@Test(expected = NullPointerException.class) public void arrayContainingNullCausesNpe() { toPrimitive(new Long[] {1L, null, 3L, 4L, 5L}); }
@Test(expected = NullPointerException.class) public void arrayStartingWithNullCausesNpe() { toPrimitive(new Long[] {null, 3L, 4L, 5L}); }
@Test(expected = NullPointerException.class) public void arrayEndingWithNullCausesNpe() { toPrimitive(new Long[] {1L, 3L, 4L, null}); }