Interface CollectionContract<E,C extends Collection<E>>
- Type Parameters:
E
- The element type being tested.sC
- The collection type being tested.
- All Superinterfaces:
AddAllContract<E,
,C> AddContract<E,
,C> ClearContract<E,
,C> CollectionContractConfig
,CollectionContractSupport<E,
,C> CollectionProviderSupport<E,
,C> ContainsAllContract<E,
,C> ContainsContract<E,
,C> ContractSupport<C>
,ElementProviderSupport<E>
,EqualsContract<C>
,ForEachContract<E,
,C> HashCodeContract<C>
,IsEmptyContract<E,
,C> IterableContract<E,
,C> IteratorContract<E,
,C> ObjectContract<C>
,ProviderSupport<C>
,RemoveAllContract<E,
,C> RemoveContract<E,
,C> RemoveIfContract<E,
,C> RetainAllContract<E,
,C> SizeContract<E,
,C> SpliteratorContract<E,
,C> StreamContract<E,
,C> SupportedMethods
,ToArrayContract<E,
,C> ToStringContract<C>
- All Known Subinterfaces:
ListContract<E,
,L> SequencedCollectionContract<E,
C>
public interface CollectionContract<E,C extends Collection<E>>
extends IterableContract<E,C>, CollectionContractConfig, AddContract<E,C>, AddAllContract<E,C>, ClearContract<E,C>, ContainsContract<E,C>, ContainsAllContract<E,C>, IsEmptyContract<E,C>, RemoveContract<E,C>, RemoveAllContract<E,C>, RemoveIfContract<E,C>, RetainAllContract<E,C>, SizeContract<E,C>, StreamContract<E,C>, ToArrayContract<E,C>
Test suite for classes that implement the Collection
interface. When implementing this class, the only
method that will need to be implemented is ProviderSupport.provider()
. Also, the following methods
will allow the tests to be configured based upon the desired behavior of the collection class being tested:
- permitNulls: Specifies if the collection permits null value elements.
- permitDuplicates: Specifies if the collection permits duplicate values.
- permitIncompatibleTypes: Specifies if the collection allows the search for incompatible values.
For example, most of the collections from the JDK permit null values, permit duplicate values, and permit the search for incompatible types. To create a test class for ArrayList, the following constructor would be appropriate:
public class ArrayListTest
extends AbstractTest<Integer>
implements TestCollection<ArrayList<Integer>, Integer>, WithIntegerElement<ArrayList<Integer>> {
public ArrayListTest() {
permitNulls(true);
permitIncompatibleTypes(true);
permitDuplicates(true);
}
}
- Since:
- 1.0
- Author:
- evanbergstrom
- See Also:
-
Field Summary
Fields inherited from interface org.soliscode.test.contract.support.CollectionContractSupport
DEFAULT_SIZE
Fields inherited from interface org.soliscode.test.contract.iterable.SpliteratorContract
CHARACTERISTIC_VALUES
-
Method Summary
Modifier and TypeMethodDescriptionvoid
doesNotSupportMethod
(OptionalMethod method) Used to indicate that the class being tested does not support an optional method.default void
Specific if the test collection supports the methods that allow modification.boolean
supportsMethod
(OptionalMethod method) Used to determine if this object supports an optional method.Methods inherited from interface org.soliscode.test.contract.collection.AddAllContract
testAddAllToContainer, testAddAllWithDuplicateValue, testAddAllWithNullValue
Methods inherited from interface org.soliscode.test.contract.collection.AddContract
addWithDuplicateValue, testAdd, testAddWithNullValue
Methods inherited from interface org.soliscode.test.contract.collection.ClearContract
testClearOnCollectionWithElements, testClearOnEmptyCollection
Methods inherited from interface org.soliscode.test.contract.CollectionContractConfig
permitDuplicates, permitIncompatibleTypes, permitNulls
Methods inherited from interface org.soliscode.test.contract.support.CollectionProviderSupport
provider
Methods inherited from interface org.soliscode.test.contract.collection.ContainsAllContract
testContainsAllOnCollectionWithElements, testContainsAllOnCollectionWithNulls, testContainsAllOnEmptyCollection, testContainsAllWithIncompatibleType
Methods inherited from interface org.soliscode.test.contract.collection.ContainsContract
testContainsOnCollectionWithElements, testContainsOnCollectionWithNulls, testContainsOnEmptyCollection, testContainsWithIncompatibleType
Methods inherited from interface org.soliscode.test.contract.support.ElementProviderSupport
elementProvider
Methods inherited from interface org.soliscode.test.contract.object.EqualsContract
testEqualsForNullValue, testEqualsIsConsistent, testEqualsIsReflexive, testEqualsIsSymmetric, testEqualsIsTransitive
Methods inherited from interface org.soliscode.test.contract.iterable.ForEachContract
testForEachForEmptyCollection, testForEachWithNullAction, testForeEachOverCollectionWithElements
Methods inherited from interface org.soliscode.test.contract.object.HashCodeContract
testHashCodeDistribution, testHashCodeIsStable, testHashCodeWithEqualValues, testHashDifferentValues
Methods inherited from interface org.soliscode.test.contract.collection.IsEmptyContract
testIsEmptyForEmptyCollection, testIsEmptyForNonEmptyCollection
Methods inherited from interface org.soliscode.test.contract.iterable.IteratorContract
testForEachRemainingForNullAction, testForEachRemainingOverEntireCollection, testForEachRemainingOverPartialCollection, testIteratorOverCollectionWithElements, testIteratorOverEmptyCollection, testIteratorRemove, testIteratorRemoveThrowsOnIllegalState
Methods inherited from interface org.soliscode.test.contract.collection.RemoveAllContract
testRemoveAllOnContainerWithElements, testRemoveAllOnEmptyContainer, testRemoveAllOnIncompatibleObject, testRemoveAllOnNullElement, testRemoveAllThrowsOnNullCollection
Methods inherited from interface org.soliscode.test.contract.collection.RemoveContract
testRemoveOnContainerWithElements, testRemoveOnContainerWithNulls, testRemoveOnEmptyContainer, testRemoveOnIncompatibleObject
Methods inherited from interface org.soliscode.test.contract.collection.RemoveIfContract
testRemoveIfOnContainerWithElements, testRemoveIfOnEmptyContainer, testRemoveIfThrowsOnANullFilter
Methods inherited from interface org.soliscode.test.contract.collection.RetainAllContract
testRetainAllOnContainerWithElements, testRetainAllOnEmptyContainer, testRetainAllOnIncompatibleObject, testRetainAllThrowsOnNullCollection
Methods inherited from interface org.soliscode.test.contract.collection.SizeContract
testSizeOnCollectionWithElements, testSizeOnEmptyCollection
Methods inherited from interface org.soliscode.test.contract.iterable.SpliteratorContract
testHasCharacteristic, testSpliteratorEstimateSizeOnACollectionWithElements, testSpliteratorEstimateSizeOnAnEmptyCollection, testSpliteratorForEachRemainingOnACollectionWithElements, testSpliteratorForEachRemainingOnAnEmptyCollection, testSpliteratorGetExactSizeIfKnownOnACollectionWithElements, testSpliteratorGetExactSizeIfKnownOnAnEmptyCollection, testSpliteratorTryAdvanceOnACollectionWithElements, testSpliteratorTryAdvanceOnAnEmptyCollection, testSpliteratorTrySplitOnACollectionWithElements, testSpliteratorTrySplitOnAnEmptyCollection
Methods inherited from interface org.soliscode.test.contract.collection.StreamContract
testParallelStreamForCollectionWithElements, testParallelStreamForEmptyCollection, testStreamForCollectionWithElements, testStreamForEmptyCollection
Methods inherited from interface org.soliscode.test.contract.collection.ToArrayContract
testToArray, testToArrayIsSafe, testToArrayOnEmptyCollection, testToArrayStore, testToArrayStoreOnEmptyCollection, testToArrayStoreThrowsOnNullArray
Methods inherited from interface org.soliscode.test.contract.object.ToStringContract
testToStringForDifferentValues, testToStringForEqualValues, testToStringIsConsistent, testToStringOverridden
-
Method Details
-
supportsMethod
Description copied from interface:SupportedMethods
Used to determine if this object supports an optional method.- Specified by:
supportsMethod
in interfaceSupportedMethods
- Parameters:
method
- The identifier for the method.- Returns:
- 'true' if the method is supported.
false
if it is not.
-
doesNotSupportMethod
Used to indicate that the class being tested does not support an optional method.- Parameters:
method
- the method that the class being tested does not support.
-
doesNotSupportModification
default void doesNotSupportModification()Specific if the test collection supports the methods that allow modification. It is a convenience function to set the support state for all the modification methods at once. These methods are:
-