DefaultMockSelectionStrategy implements MockSelectionStrategy { @SuppressWarnings("unchecked") public <T> OrderedSet<T> selectMocks(OrderedSet<Object> mocks, Class<T> mockClass) { OrderedSet<T> matchingMocks = new OrderedSet<T>(); for (Object object : mocks) { if (mockClass.isAssignableFrom(object.getClass())) { matchingMocks.add((T) object); } } return matchingMocks; }  @SuppressWarnings("unchecked") OrderedSet<T> selectMocks(OrderedSet<Object> mocks, Class<T> mockClass); @SuppressWarnings("unchecked") CollectionOfMocksField<C, E> getCollectionOfMocksField(
			CollectionOfMocksFieldSet collectionOfMocksFieldSet, Class<C> typeOfCollection, Class<E> typeOfElements);  }
@Test public void shouldGetMocks() { InputStream mock1 = mock(InputStream.class); OutputStream mock2 = mock(OutputStream.class); InputStream mock3 = mock(FileInputStream.class); OrderedSet<Object> mocks = new OrderedSet<Object>(Arrays.<Object> asList(mock1, mock2, mock3)); OrderedSet<InputStream> actualMocks = strategy.selectMocks(mocks, InputStream.class); assertTrue(actualMocks.equals(new OrderedSet<InputStream>(Arrays.<InputStream> asList(mock1, mock3)))); }
@Test public void shouldGetMocksGivenNoMatchingMocks() { Object mock1 = mock(InputStream.class); Object mock2 = mock(OutputStream.class); OrderedSet<Object> mocks = new OrderedSet<Object>(Arrays.asList(mock1, mock2)); OrderedSet<FileOutputStream> actualMocks = strategy.selectMocks(mocks, FileOutputStream.class); assertTrue(actualMocks.isEmpty()); }