JavaHamcrest icon indicating copy to clipboard operation
JavaHamcrest copied to clipboard

Improve generics on some collection matchers.

Open fbarber opened this issue 12 years ago • 6 comments

The following classes are no longer parameterized as they don't care what is in the collection they match:

  • IsCollectionWithSize
  • IsIterableWithSize
  • IsMapWithSize
  • IsEmptyCollection
  • IsEmptyIterable

fbarber avatar Feb 22 '13 15:02 fbarber

I think this will be superseded by our plans for collection-specific factory methods

sf105 avatar Dec 30 '14 17:12 sf105

@sf105 Are those methods available already?

I'm running into generics compilation errors with the JDT 3.20 compiler for the following code:

List<String> result = ...
assertThat(result, allOf(hasSize(1), hasItems("foo")));

The error is: The method allOf(Matcher<? super T>, Matcher<? super T>) in the type Matchers is not applicable for the arguments (Matcher<Collection<? extends Object>>, Matcher<Iterable<String>>)

guw avatar Mar 06 '20 13:03 guw

@fbarber fancy rebasing this from master, as hamcrest-core and hamcrest-library have been refactored a lot and also deprecated, so that everything is just in hamcrest.

I've got some custom collections matchers, which do similar and would be interested getting richer collection matches into hamcrest. i.e. if the collection is the wrong size then output the collection, so when debugging you can shortcut having to run it yourself and get a start on working out the issue.

nhojpatrick avatar Jun 28 '20 22:06 nhojpatrick

Sure. I will update with a rebased version soon.

fbarber avatar Jul 03 '20 23:07 fbarber

@nhojpatrick Rebase done.

fbarber avatar Jul 07 '20 15:07 fbarber

Going to try and kick start hamcrest, so if you want to get it merged, please rebase from the branch v2.3-candidates. Still trying to understand how has permissions to perform a release.

nhojpatrick avatar Feb 13 '22 12:02 nhojpatrick