@CollectionFeature.Require(absent = SUPPORTS_ADD) @CollectionSize.Require(absent = ZERO) public void testAdd_unsupportedPresent() { try { assertFalse("add(present) should return false or throw", collection.add(e0())); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }
@CollectionFeature.Require( value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, absent = RESTRICTS_ELEMENTS ) public void testAdd_nullSupported() { assertTrue("add(null) should return true", collection.add(null)); expectAdded((E) null); }
@CollectionFeature.Require(absent = SUPPORTS_ADD) public void testAdd_unsupportedNotPresent() { try { collection.add(e3()); fail("add(notPresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(e3()); }
@CollectionFeature.Require(SUPPORTS_ADD) public void testAdd_supportedNotPresent() { assertTrue("add(notPresent) should return true", collection.add(e3())); expectAdded(e3()); }
@CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES) public void testAdd_nullUnsupported() { try { collection.add(null); fail("add(null) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(null)"); }
@CollectionFeature.Require(absent = SUPPORTS_ADD) public void testAdd_unsupportedNotPresent() { try { collection.add(samples.e3); fail("add(notPresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(samples.e3); }
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION}) @CollectionSize.Require(absent = ZERO) public void testAddConcurrentWithIteration() { try { Iterator<E> iterator = collection.iterator(); assertTrue(collection.add(e3())); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@CollectionFeature.Require(absent = SUPPORTS_ADD) @CollectionSize.Require(absent = ZERO) public void testAdd_unsupportedPresent() { try { assertFalse("add(present) should return false or throw", collection.add(samples.e0)); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION}) @CollectionSize.Require(absent = ZERO) public void testAddConcurrentWithIteration() { try { Iterator<E> iterator = collection.iterator(); assertTrue(collection.add(samples.e3)); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@Override protected Collection<Method> suppressForCheckedSet() { return Arrays.asList(getAddNullSupportedMethod(), getAddSupportedNullPresentMethod()); } }
@Override protected Collection<Method> suppressForTreeSetNatural() { return Arrays.asList( getAddNullUnsupportedMethod(), getAddAllNullUnsupportedMethod(), getCreateWithNullUnsupportedMethod()); }
@CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES) public void testAdd_nullUnsupported() { try { collection.add(null); fail("add(null) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullMissingWhenNullUnsupported("Should not contain null after unsupported add(null)"); }
@CollectionFeature.Require({SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION}) @CollectionSize.Require(absent = ZERO) public void testAddConcurrentWithIteration() { try { Iterator<E> iterator = collection.iterator(); assertTrue(collection.add(e3())); iterator.next(); fail("Expected ConcurrentModificationException"); } catch (ConcurrentModificationException expected) { // success } }
@CollectionFeature.Require(SUPPORTS_ADD) public void testAdd_supportedNotPresent() { assertTrue("add(notPresent) should return true", collection.add(e3())); expectAdded(e3()); }
@Override protected Collection<Method> suppressForCheckedList() { return Arrays.asList( CollectionAddTester.getAddNullSupportedMethod(), getAddSupportedNullPresentMethod(), ListAddAtIndexTester.getAddNullSupportedMethod(), getSetNullSupportedMethod()); } }
@Override protected Collection<Method> suppressForTreeSetNatural() { return Arrays.asList( getAddNullUnsupportedMethod(), getAddAllNullUnsupportedMethod(), getCreateWithNullUnsupportedMethod()); }
@CollectionFeature.Require(value = SUPPORTS_ADD, absent = ALLOWS_NULL_VALUES) public void testAdd_nullUnsupported() { try { collection.add(null); fail("add(null) should throw"); } catch (NullPointerException expected) { } expectUnchanged(); expectNullMissingWhenNullUnsupported( "Should not contain null after unsupported add(null)"); }
@CollectionFeature.Require(absent = SUPPORTS_ADD) public void testAdd_unsupportedNotPresent() { try { collection.add(e3()); fail("add(notPresent) should throw"); } catch (UnsupportedOperationException expected) { } expectUnchanged(); expectMissing(e3()); }
@CollectionFeature.Require( value = {SUPPORTS_ADD, ALLOWS_NULL_VALUES}, absent = RESTRICTS_ELEMENTS) public void testAdd_nullSupported() { assertTrue("add(null) should return true", collection.add(null)); expectAdded((E) null); }
@CollectionFeature.Require(absent = SUPPORTS_ADD) @CollectionSize.Require(absent = ZERO) public void testAdd_unsupportedPresent() { try { assertFalse("add(present) should return false or throw", collection.add(e0())); } catch (UnsupportedOperationException tolerated) { } expectUnchanged(); }