Java Code Examples for org.mockito.Mockito#argThat()

The following examples show how to use org.mockito.Mockito#argThat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScriptModuleLoaderTest.java    From Nicobar with Apache License 2.0 7 votes vote down vote up
/**
 * Custom mockito/hamcrest matcher which will inspect a ScriptModule and see if its moduleId
 * equals the input moduleId and likewise for the creation time
 */
private ScriptModule moduleEquals(final String scriptModuleId, final long createTime) {
    return Mockito.argThat(new ArgumentMatcher<ScriptModule>() {
        @Override
        public boolean matches(Object argument) {
            ScriptModule scriptModule = (ScriptModule)argument;
            return scriptModule != null &&
                scriptModule.getModuleId().toString().equals(scriptModuleId) &&
                scriptModule.getCreateTime() == createTime;
        }
        @Override
        public void describeTo(Description description) {
            description.appendText("ScriptModule.getModuleId().equals(\"" + scriptModuleId + "\")");
        }
    });
}
 
Example 2
Source File: TestCheckpoint.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private File filePathContaining(final String substring) {
  return Mockito.argThat(
      new ArgumentMatcher<File>() {
        @Override
        public boolean matches(Object argument) {
          String path = ((File) argument).getAbsolutePath();
          return path.contains(substring);
        }
      });
}
 
Example 3
Source File: TestCheckpoint.java    From big-c with Apache License 2.0 5 votes vote down vote up
private File filePathContaining(final String substring) {
  return Mockito.argThat(
      new ArgumentMatcher<File>() {
        @Override
        public boolean matches(Object argument) {
          String path = ((File) argument).getAbsolutePath();
          return path.contains(substring);
        }
      });
}
 
Example 4
Source File: MobileMessagingCloudServiceTest.java    From mobile-messaging-sdk-android with Apache License 2.0 5 votes vote down vote up
private static Intent intentWith(final Message message) {
    return Mockito.argThat(new ArgumentMatcher<Intent>() {
        @Override
        public boolean matches(Object o) {
            Intent intent = (Intent) o;

            Message that = Message.createFrom(intent.getExtras());
            return message.getBody().equals(that.getBody())
                    && message.getMessageId().equals(that.getMessageId());
        }
    });
}
 
Example 5
Source File: MobileMessagingCloudServiceTest.java    From mobile-messaging-sdk-android with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("SameParameterValue")
private static Intent intentWith(final String senderId) {
    return Mockito.argThat(new ArgumentMatcher<Intent>() {
        @Override
        public boolean matches(Object o) {
            Intent intent = (Intent) o;
            return senderId.equals(intent.getStringExtra(MobileMessagingCloudHandler.EXTRA_SENDER_ID));
        }
    });
}
 
Example 6
Source File: MobileMessagingCloudServiceTest.java    From mobile-messaging-sdk-android with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("SameParameterValue")
private static Intent intentWith(final String senderId, final String token) {
    return Mockito.argThat(new ArgumentMatcher<Intent>() {
        @Override
        public boolean matches(Object o) {
            Intent intent = (Intent) o;
            return senderId.equals(intent.getStringExtra(MobileMessagingCloudHandler.EXTRA_SENDER_ID))
                    && token.equals(intent.getStringExtra(MobileMessagingCloudHandler.EXTRA_TOKEN));
        }
    });
}
 
Example 7
Source File: VertxVaadinResponseUT.java    From vertx-vaadin with MIT License 4 votes vote down vote up
private static String caseInsensitive(String arg) {
    return Mockito.argThat(new CaseInsensitiveEquals(arg));
}
 
Example 8
Source File: VertxVaadinResponseUT.java    From vertx-vaadin with MIT License 4 votes vote down vote up
private static String caseInsensitive(String arg) {
    return Mockito.argThat(new CaseInsensitiveEquals(arg));
}
 
Example 9
Source File: AssertionMatcher.java    From mockito-java8 with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("ResultOfMethodCallIgnored")
private static <T> void argThat(Consumer<T> consumer) {
    Mockito.argThat(new AssertionMatcher<>(consumer));
}
 
Example 10
Source File: MockitoTestUtils.java    From joynr with Apache License 2.0 4 votes vote down vote up
public static HttpRequest anyPerformanceHttpRequest(final String bpId, int activeLongPolls, int assignedChannels) {
    return Mockito.argThat(new IsAnyPerformanceHttpRequest(bpId, activeLongPolls, assignedChannels));
}