Example #1
0
 /**
  * Allows matching arguments with hamcrest matchers.
  *
  * <p>See examples in javadoc for {@link MockitoHamcrest} class
  *
  * @param matcher decides whether argument matches
  * @return <code>null</code> or default value for primitive (0, false, etc.)
  * @since 2.0
  */
 public static <T> T argThat(Matcher<T> matcher) {
   return (T)
       MOCKING_PROGRESS
           .getArgumentMatcherStorage()
           .reportMatcher(new HamcrestArgumentMatcher(matcher))
           .returnFor(MatcherGenericTypeExtractor.genericTypeOfMatcher(matcher.getClass()));
 }
Example #2
0
 private Matcher<T> bestMatcher() {
   for (Matcher<T> matcher : elements) {
     if (matcher.getClass() != IsNull.class) {
       return matcher;
     }
   }
   return equalTo(null);
 }
 private void assertValues(
     final MimeRulesSource mimeRulesSource,
     final String path,
     final Matcher<? super String> matcher) {
   MimeRule nexusMimeType = mimeRulesSource.getRuleForName(path);
   if (matcher.getClass().equals(nullValue().getClass())) {
     assertThat(nexusMimeType, nullValue());
     return;
   }
   assertThat(nexusMimeType, notNullValue());
   assertThat(nexusMimeType.getMimetypes(), hasSize(1));
   assertThat(nexusMimeType.getMimetypes().get(0), matcher);
 }