public static int[] toIntArray(Collection<Integer> collection) {
        int[] collectionArray = new int[collection.size()];
        int index = 0;
        for (Integer item : collection) {
            collectionArray[index++] = item;
        }
        return collectionArray;
    }
@Test(expected = NullPointerException.class)
    public void testToIntArray_whenNull_thenThrowNPE() {
        toIntArray(null);
    }