@Test public void testSerialize() { Data data = serializationService.toData(list); List<Integer> deserializedList = serializationService.toObject(data); int size = list.size(); assertEquals(size, deserializedList.size()); for (int i = 0; i < size; i++) { assertEquals(list.get(i), deserializedList.get(i)); } }
@Test public void testContainsAll_False() { ArrayList<Integer> integers = new ArrayList<Integer>(); integers.add(randomInt()); integers.add(randomInt() + SIZE); assertFalse(list.containsAll(integers)); }
@Test(expected = UnsupportedOperationException.class) public void testRetainAll() { ArrayList<Integer> integers = new ArrayList<Integer>(); integers.add(randomInt()); integers.add(randomInt()); list.retainAll(integers); }
@Test(expected = UnsupportedOperationException.class) public void testAddAll_WithIndex() { ArrayList<Integer> integers = new ArrayList<Integer>(); integers.add(randomInt()); integers.add(randomInt()); list.addAll(randomInt(), integers); }
@Test public void testSubList() { int i = RandomPicker.getInt(SIZE / 2); List<Integer> subList = list.subList(i, i + SIZE / 2); for (int integer : subList) { assertEquals(i++, integer); } }
@Test public void testListIterator() { int i = randomInt(); ListIterator<Integer> listIterator = list.listIterator(i); while (listIterator.hasNext()) { assertEquals(i++, (int) listIterator.next()); } while (listIterator.hasPrevious()) { assertEquals(--i, (int) listIterator.previous()); } }
@Test(expected = UnsupportedOperationException.class) public void testListIterator_Set() { ListIterator<Integer> listIterator = list.listIterator(); listIterator.next(); listIterator.set(randomInt()); }
@Test public void testLastIndexOf() { int i = randomInt(); assertEquals(i, list.indexOf(i)); }
@Test(expected = UnsupportedOperationException.class) public void testRemove_WithIndex() { list.remove(randomInt()); }
@Test public void testContains_True() { assertTrue(list.contains(randomInt())); }
@Test public void testToArray_AsObject() { Object[] array = list.toArray(); assertParamsEquals(array, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); }
@Test(expected = UnsupportedOperationException.class) public void testIterator_remove() { Iterator<Integer> iterator = list.iterator(); iterator.next(); iterator.remove(); }
@Test(expected = UnsupportedOperationException.class) public void testClear() { list.clear(); }
@Test(expected = UnsupportedOperationException.class) public void testRemove() { list.remove(new Integer(randomInt())); }
@Test(expected = UnsupportedOperationException.class) public void testAdd() { list.add(randomInt()); }
@Test public void testToArray_AsGenericType_GreaterSize() { Integer[] a = new Integer[SIZE + 1]; Integer[] array = list.toArray(a); assertParamsEquals(array, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, null); }
@Test public void testToArray_AsGenericType_SmallSize() { Integer[] a = new Integer[randomInt()]; Integer[] array = list.toArray(a); assertParamsEquals(array, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); }
@Test public void testIsEmpty_True() { list = new UnmodifiableLazyList<Integer>(Collections.emptyList(), serializationService); assertTrue(list.isEmpty()); }
@Test public void testGet() { int i = randomInt(); assertEquals(i, (int) list.get(i)); }
@Test public void testContains_False() { assertFalse(list.contains(randomInt() + SIZE)); }
@Test public void testSize() { assertEquals(SIZE, list.size()); }
@Test(expected = UnsupportedOperationException.class) public void testSet() { int i = randomInt(); list.set(i, i + 1); }
@Test public void testIsEmpty_False() { assertFalse(list.isEmpty()); }
@Test(expected = UnsupportedOperationException.class) public void testAdd_WithIndex() { int i = randomInt(); list.add(i, i + 1); }