use of org.mockito.ArgumentMatcher in project sonarqube by SonarSource.
the class TomcatConnectorsTest method test_max_post_size_for_http_connection.
@Test
public void test_max_post_size_for_http_connection() throws Exception {
Properties properties = new Properties();
Props props = new Props(properties);
TomcatConnectors.configure(tomcat, props);
verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() {
@Override
public boolean matches(Object o) {
Connector c = (Connector) o;
return c.getMaxPostSize() == -1;
}
}));
}
use of org.mockito.ArgumentMatcher in project sonarqube by SonarSource.
the class TomcatConnectorsTest method bind_to_specific_address.
@Test
public void bind_to_specific_address() {
Properties p = new Properties();
p.setProperty("sonar.web.port", "9000");
p.setProperty("sonar.web.host", "1.2.3.4");
TomcatConnectors.configure(tomcat, new Props(p));
verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() {
@Override
public boolean matches(Object o) {
Connector c = (Connector) o;
return c.getScheme().equals("http") && c.getPort() == 9000 && ((InetAddress) c.getProperty("address")).getHostAddress().equals("1.2.3.4");
}
}));
}
use of org.mockito.ArgumentMatcher in project android_frameworks_base by ResurrectionRemix.
the class NetworkScorerAppManagerTest method setScorers.
private void setScorers(List<ResolveInfoHolder> scorers) {
List<ResolveInfo> receivers = new ArrayList<>();
for (final ResolveInfoHolder scorer : scorers) {
receivers.add(scorer.scorerResolveInfo);
if (scorer.configActivityResolveInfo != null) {
// This scorer has a config activity.
Mockito.when(mMockPm.queryIntentActivities(Mockito.argThat(new ArgumentMatcher<Intent>() {
@Override
public boolean matches(Object object) {
Intent intent = (Intent) object;
return NetworkScoreManager.ACTION_CUSTOM_ENABLE.equals(intent.getAction()) && scorer.scorerResolveInfo.activityInfo.packageName.equals(intent.getPackage());
}
}), Mockito.eq(0))).thenReturn(Collections.singletonList(scorer.configActivityResolveInfo));
}
if (scorer.serviceResolveInfo != null) {
// This scorer has a service to bind to
Mockito.when(mMockPm.resolveService(Mockito.argThat(new ArgumentMatcher<Intent>() {
@Override
public boolean matches(Object object) {
Intent intent = (Intent) object;
return NetworkScoreManager.ACTION_SCORE_NETWORKS.equals(intent.getAction()) && scorer.scorerResolveInfo.activityInfo.packageName.equals(intent.getPackage());
}
}), Mockito.eq(0))).thenReturn(scorer.serviceResolveInfo);
}
}
Mockito.when(mMockPm.queryBroadcastReceiversAsUser(Mockito.argThat(new ArgumentMatcher<Intent>() {
@Override
public boolean matches(Object object) {
Intent intent = (Intent) object;
return NetworkScoreManager.ACTION_SCORE_NETWORKS.equals(intent.getAction());
}
}), Mockito.eq(0), Mockito.eq(UserHandle.USER_SYSTEM))).thenReturn(receivers);
}
use of org.mockito.ArgumentMatcher in project powermock by powermock.
the class ToStringGenerator method generate.
public String generate(Object mock, Method method, Object[] arguments) {
final List<ArgumentMatcher> matcherList = ArgumentsProcessor.argumentsToMatchers(arguments);
final PrintSettings printSettings = new PrintSettings();
MatchersPrinter matchersPrinter = new MatchersPrinter();
String methodName = Whitebox.getUnproxyType(mock).getName() + "." + method.getName();
String invocation = methodName + matchersPrinter.getArgumentsLine(matcherList, printSettings);
if (printSettings.isMultiline() || (!matcherList.isEmpty() && invocation.length() > Whitebox.<Integer>getInternalState(PrintSettings.class, "MAX_LINE_LENGTH"))) {
return methodName + matchersPrinter.getArgumentsBlock(matcherList, printSettings);
} else {
return invocation;
}
}
use of org.mockito.ArgumentMatcher in project kafka-spout by HolmesNL.
the class KafkaSpoutBufferBehaviourTest method testDeclarations.
@Test
public void testDeclarations() {
final OutputFieldsDeclarer declarer = mock(OutputFieldsDeclarer.class);
_subject.declareOutputFields(declarer);
// verify the spout declares to output single-field tuples
verify(declarer).declare(argThat(new ArgumentMatcher<Fields>() {
@Override
public boolean matches(final Object argument) {
final Fields fields = (Fields) argument;
return fields.size() == 1 && fields.get(0).equals("bytes");
}
}));
// verify the spout will not provide component configuration
assertNull(_subject.getComponentConfiguration());
}
Aggregations