Skip to content

Commit

Permalink
Remove expected from tests
Browse files Browse the repository at this point in the history
5
  • Loading branch information
Desislav-Petrov committed Jun 22, 2024
1 parent 236564e commit 1057736
Show file tree
Hide file tree
Showing 27 changed files with 277 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ public void addOccurrences()
assertEquals(BooleanHashBag.newBagWith(false, false, false, false, false, true), bag);
}

@Test(expected = IllegalArgumentException.class)
@Test
public void addOccurrences_throws()
{
this.newWith().addOccurrences(true, -1);
assertThrows(IllegalArgumentException.class, () -> this.newWith().addOccurrences(true, -1));
}

@Test
Expand Down Expand Up @@ -129,10 +129,10 @@ public void removeOccurrences()
assertEquals(new BooleanHashBag(), bag2);
}

@Test(expected = IllegalArgumentException.class)
@Test
public void removeOccurrences_throws()
{
this.newWith().removeOccurrences(true, -1);
assertThrows(IllegalArgumentException.class, () -> this.newWith().removeOccurrences(true, -1));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ protected <T> ImmutableSortedBag<T> newWithOccurrences(ObjectIntPair<T>... eleme

protected abstract <T> ImmutableSortedBag<T> newWith(Comparator<? super T> comparator, T... elements);

@Test(expected = NullPointerException.class)
@Test
public void noSupportForNull()
{
this.classUnderTest().newWith(null);
assertThrows(NullPointerException.class, () -> this.classUnderTest().newWith(null));
}

@Test
Expand Down Expand Up @@ -717,10 +717,10 @@ public void zipWithIndex()
}

@Override
@Test(expected = IllegalArgumentException.class)
@Test
public void chunk_zero_throws()
{
this.classUnderTest().chunk(0);
assertThrows(IllegalArgumentException.class, () -> this.classUnderTest().chunk(0));
}

@Test
Expand Down Expand Up @@ -1514,10 +1514,10 @@ public void take()
assertSame(integers2, integers2.take(Integer.MAX_VALUE));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void take_throws()
{
this.classUnderTest().take(-1);
assertThrows(IllegalArgumentException.class, () -> this.classUnderTest().take(-1));
}

@Test
Expand All @@ -1532,10 +1532,10 @@ public void drop()
assertEquals(SortedBags.immutable.empty(integers1.comparator()), integers1.drop(Integer.MAX_VALUE));
}

@Test(expected = IllegalArgumentException.class)
@Test
public void drop_throws()
{
this.classUnderTest().drop(-1);
assertThrows(IllegalArgumentException.class, () -> this.classUnderTest().drop(-1));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,20 @@ public void entrySet_containsAll()
assertTrue(entries.containsAll(FastList.newListWith(ImmutableEntry.of(1, "One"), ImmutableEntry.of(3, "Three"))));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void entrySet_add()
{
MutableBiMap<Integer, String> biMap = this.newMapWithKeyValue(1, "One");
Set<Map.Entry<Integer, String>> entries = biMap.entrySet();
entries.add(ImmutableEntry.of(2, "Two"));
assertThrows(UnsupportedOperationException.class, () -> entries.add(ImmutableEntry.of(2, "Two")));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void entrySet_addAll()
{
MutableBiMap<Integer, String> biMap = this.newMapWithKeyValue(1, "One");
Set<Map.Entry<Integer, String>> entries = biMap.entrySet();
entries.addAll(FastList.newListWith(ImmutableEntry.of(2, "Two")));
assertThrows(UnsupportedOperationException.class, () -> entries.addAll(FastList.newListWith(ImmutableEntry.of(2, "Two"))));
}

@Test
Expand All @@ -208,13 +208,13 @@ public void entrySet_equals()
assertEquals(expected, biMap.entrySet());
}

@Test(expected = NoSuchElementException.class)
@Test
public void entrySet_Iterator_incrementPastEnd()
{
MutableBiMap<Integer, String> biMap = this.newMapWithKeyValue(1, "One");
Iterator<Map.Entry<Integer, String>> iterator = biMap.entrySet().iterator();
iterator.next();
iterator.next();
assertThrows(NoSuchElementException.class, () -> iterator.next());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ public abstract class AbstractMutableBiMapKeySetTestCase

protected abstract MutableBiMap<String, Integer> newMapWithKeysValues(String key1, int value1, String key2, int value2, String key3, int value3, String key4, int value4);

@Test(expected = UnsupportedOperationException.class)
@Test
public void add()
{
this.newMapWithKeysValues("One", 1, "Two", 2, "Three", 3).keySet().add("Four");
assertThrows(UnsupportedOperationException.class, () -> this.newMapWithKeysValues("One", 1, "Two", 2, "Three", 3).keySet().add("Four"));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void addAll()
{
this.newMapWithKeysValues("One", 1, "Two", 2, "Three", 3).keySet().addAll(FastList.newListWith("Four"));
assertThrows(UnsupportedOperationException.class, () -> this.newMapWithKeysValues("One", 1, "Two", 2, "Three", 3).keySet().addAll(FastList.newListWith("Four")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ public abstract class AbstractMutableBiMapValuesTestCase

protected abstract MutableBiMap<Float, Integer> newMapWithKeysValues(float key1, Integer value1, float key2, Integer value2, float key3, Integer value3, float key4, Integer value4);

@Test(expected = UnsupportedOperationException.class)
@Test
public void add()
{
this.newMapWithKeysValues(1.0f, 1, 2.0f, 2, 3.0f, 3).values().add(4);
assertThrows(UnsupportedOperationException.class, () -> this.newMapWithKeysValues(1.0f, 1, 2.0f, 2, 3.0f, 3).values().add(4));
}

@Test(expected = UnsupportedOperationException.class)
@Test
public void addAll()
{
this.newMapWithKeysValues(1.0f, 1, 2.0f, 2, 3.0f, 3).values().addAll(FastList.newListWith(4));
assertThrows(UnsupportedOperationException.class, () -> this.newMapWithKeysValues(1.0f, 1, 2.0f, 2, 3.0f, 3).values().addAll(FastList.newListWith(4)));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ public void parallelStream()
/**
* @since 9.0
*/
@Test(expected = UnsupportedOperationException.class)
@Test
public void castToCollection()
{
this.classUnderTest().castToCollection().add(0);
assertThrows(UnsupportedOperationException.class, () -> this.classUnderTest().castToCollection().add(0));
}

/**
Expand Down Expand Up @@ -612,10 +612,10 @@ public void flatCollectWith()
assertEquals(expected, actual);
}

@Test(expected = IllegalArgumentException.class)
@Test
public void chunk_zero_throws()
{
this.classUnderTest().chunk(0);
assertThrows(IllegalArgumentException.class, () -> this.classUnderTest().chunk(0));
}

@Test
Expand Down Expand Up @@ -817,21 +817,21 @@ public void forLoop()
}
}

private ImmutableCollection<Integer> classUnderTestWithNull()
protected ImmutableCollection<Integer> classUnderTestWithNull()
{
return this.classUnderTest().reject(Integer.valueOf(1)::equals).newWith(null);
}

@Test(expected = NullPointerException.class)
@Test
public void min_null_throws()
{
this.classUnderTestWithNull().min(Integer::compareTo);
assertThrows(NullPointerException.class, () -> this.classUnderTestWithNull().min(Integer::compareTo));
}

@Test(expected = NullPointerException.class)
@Test
public void max_null_throws()
{
this.classUnderTestWithNull().max(Integer::compareTo);
assertThrows(NullPointerException.class, () -> this.classUnderTestWithNull().max(Integer::compareTo));
}

@Test
Expand All @@ -846,16 +846,16 @@ public void max()
assertEquals(Integer.valueOf(1), this.classUnderTest().max(Comparators.reverse(Integer::compareTo)));
}

@Test(expected = NullPointerException.class)
@Test
public void min_null_throws_without_comparator()
{
this.classUnderTestWithNull().min();
assertThrows(NullPointerException.class, () -> this.classUnderTestWithNull().min());
}

@Test(expected = NullPointerException.class)
@Test
public void max_null_throws_without_comparator()
{
this.classUnderTestWithNull().max();
assertThrows(NullPointerException.class, () -> this.classUnderTestWithNull().max());
}

@Test
Expand Down
Loading

0 comments on commit 1057736

Please sign in to comment.