use of org.easymock.IArgumentMatcher in project easymock by easymock.
the class LastControl method reportNot.
public static void reportNot() {
List<IArgumentMatcher> stack = threadToArgumentMatcherStack.get();
assertState(stack != null, NO_MATCHERS_FOUND);
stack.add(new Not(popLastArgumentMatchers(1).get(0)));
}
use of org.easymock.IArgumentMatcher in project felix by apache.
the class ConfigInstallerTest method testSetConfiguration.
public void testSetConfiguration() throws Exception {
EasyMock.expect(mockBundleContext.getProperty(DirectoryWatcher.CONFIG_ENCODING)).andReturn(null);
EasyMock.expect(mockBundleContext.getProperty(DirectoryWatcher.LOG_DEFAULT)).andReturn(null);
EasyMock.expect(mockBundleContext.getProperty(DirectoryWatcher.LOG_LEVEL)).andReturn(null);
EasyMock.expect(mockConfiguration.getProperties()).andReturn(new Hashtable<String, Object>());
EasyMock.reportMatcher(new IArgumentMatcher() {
public boolean matches(Object argument) {
return ((Dictionary) argument).get("testkey").equals("testvalue");
}
public void appendTo(StringBuffer buffer) {
buffer.append("<Dictionary check: testkey present?>");
}
});
mockConfiguration.update(new Hashtable<String, Object>());
EasyMock.expect(mockConfigurationAdmin.listConfigurations((String) EasyMock.anyObject())).andReturn(null);
EasyMock.expect(mockConfigurationAdmin.getConfiguration("firstcfg", "?")).andReturn(mockConfiguration);
EasyMock.replay(mockConfiguration, mockConfigurationAdmin, mockBundleContext);
ConfigInstaller ci = new ConfigInstaller(mockBundleContext, mockConfigurationAdmin, new FileInstall());
assertTrue(ci.setConfig(new File("src/test/resources/watched/firstcfg.cfg")));
EasyMock.verify(mockConfiguration, mockConfigurationAdmin, mockBundleContext);
}
use of org.easymock.IArgumentMatcher in project ksql by confluentinc.
the class KafkaTopicClientImplTest method withResourceConfig.
/*
* Config has broken hashCode & equals method:
* https://issues.apache.org/jira/browse/KAFKA-6727
*/
private static Map<ConfigResource, Config> withResourceConfig(final ConfigResource resource, final ConfigEntry... entries) {
final Set<ConfigEntry> expected = Arrays.stream(entries).collect(Collectors.toSet());
class ConfigMatcher implements IArgumentMatcher {
@SuppressWarnings("unchecked")
@Override
public boolean matches(final Object argument) {
final Map<ConfigResource, Config> request = (Map<ConfigResource, Config>) argument;
if (request.size() != 1) {
return false;
}
final Config config = request.get(resource);
if (config == null) {
return false;
}
final Set<ConfigEntry> actual = new HashSet<>(config.entries());
return actual.equals(expected);
}
@Override
public void appendTo(final StringBuffer buffer) {
buffer.append(resource).append("->").append("Config{").append(expected).append("}");
}
}
EasyMock.reportMatcher(new ConfigMatcher());
return null;
}
use of org.easymock.IArgumentMatcher in project ksql by confluentinc.
the class KafkaTopicClientImplTest method singleNewTopic.
private static Collection<NewTopic> singleNewTopic(final NewTopic expected) {
class NewTopicsMatcher implements IArgumentMatcher {
@SuppressWarnings("unchecked")
@Override
public boolean matches(final Object argument) {
final Collection<NewTopic> newTopics = (Collection<NewTopic>) argument;
if (newTopics.size() != 1) {
return false;
}
final NewTopic actual = newTopics.iterator().next();
return Objects.equals(actual.name(), expected.name()) && Objects.equals(actual.replicationFactor(), expected.replicationFactor()) && Objects.equals(actual.numPartitions(), expected.numPartitions()) && Objects.equals(actual.configs(), expected.configs());
}
@Override
public void appendTo(final StringBuffer buffer) {
buffer.append("{NewTopic").append(expected).append("}");
}
}
EasyMock.reportMatcher(new NewTopicsMatcher());
return null;
}
use of org.easymock.IArgumentMatcher in project easymock by easymock.
the class LastControl method reportOr.
public static void reportOr(int count) {
List<IArgumentMatcher> stack = threadToArgumentMatcherStack.get();
assertState(stack != null, NO_MATCHERS_FOUND);
stack.add(new Or(popLastArgumentMatchers(count)));
}
Aggregations