CollectionOfMocksField { @SuppressWarnings("rawtypes") public boolean matches(CollectionOfMocksField collectionOfMocksField) { if (this == collectionOfMocksField) { return true; } return getTypeOfCollection().equals(collectionOfMocksField.getTypeOfCollection()) && getTypeOfElements().equals(collectionOfMocksField.getTypeOfElements()); } CollectionOfMocksField(C value, Class<C> typeOfCollection, Class<E> typeOfElements); C getValue(); Class<C> getTypeOfCollection(); Class<E> getTypeOfElements(); @SuppressWarnings("rawtypes") boolean matches(CollectionOfMocksField collectionOfMocksField);  }
@Test @SuppressWarnings({ "rawtypes", "unchecked" }) public void shouldMatchesGivenSelf() { Set<Object> value = Collections.emptySet(); Class<Set> typeOfCollection = Set.class; Class<Object> typeOfElements = Object.class; CollectionOfMocksField collectionOfMocksField = new CollectionOfMocksField(value, typeOfCollection, typeOfElements); boolean matches = collectionOfMocksField.matches(collectionOfMocksField); assertTrue(matches); }
@Test @SuppressWarnings({ "rawtypes", "unchecked" }) public void shouldMatchesGivenEqualTypeOfCollection() { Set value = Collections.emptySet(); CollectionOfMocksField collectionOfMocksField = new CollectionOfMocksField(value, Set.class, Object.class); CollectionOfMocksField otherInjectableCollection = new CollectionOfMocksField(value, Set.class, String.class); boolean matches = collectionOfMocksField.matches(otherInjectableCollection); assertFalse(matches); }
@Test @SuppressWarnings({ "rawtypes", "unchecked" }) public void shouldMatchesGivenEqualTypeOfElement() { CollectionOfMocksField collectionOfMocksField = new CollectionOfMocksField(Collections.emptySet(), Set.class, Number.class); CollectionOfMocksField otherInjectableCollection = new CollectionOfMocksField(Collections.emptyList(), List.class, Number.class); boolean matches = collectionOfMocksField.matches(otherInjectableCollection); assertFalse(matches); }
@Test @SuppressWarnings({ "rawtypes", "unchecked" }) public void shouldMatchesGivenEqualTypeOfCollectionAndEqualTypeOfElement() { Set<Object> value = Collections.emptySet(); CollectionOfMocksField collectionOfMocksField = new CollectionOfMocksField(value, Set.class, Number.class); CollectionOfMocksField otherInjectableCollection = new CollectionOfMocksField(value, Set.class, Number.class); boolean matches = collectionOfMocksField.matches(otherInjectableCollection); assertTrue(matches); }