use of com.hortonworks.streamline.streams.notifiers.ConsoleNotifier in project streamline by hortonworks.
the class NotificationBoltTest method testWithConsoleNotifier.
@Test
public void testWithConsoleNotifier() throws Exception {
Map<String, Object> fieldsAndValues = new HashMap<>();
fieldsAndValues.put("foo", "100");
fieldsAndValues.put("bar", "200");
final StreamlineEvent event = StreamlineEventImpl.builder().fieldsAndValues(fieldsAndValues).dataSourceId("srcid").build();
NotificationBolt consoleNotificationBolt = new NotificationBolt(new NotificationSink() {
@Override
public String getNotifierName() {
return "console_notifier";
}
@Override
public String getNotifierJarFileName() {
return "console_notifier.jar";
}
@Override
public String getNotifierClassName() {
return "ConsoleNotifier";
}
@Override
public Map<String, Object> getNotifierProperties() {
return new HashMap<>();
}
@Override
public Map<String, Object> getNotifierFieldValues() {
return new HashMap<>();
}
});
consoleNotificationBolt.withNotificationStoreClass("com.hortonworks.streamline.streams.notification.store.hbase.HBaseNotificationStore");
final ConsoleNotifier consoleNotifier = new ConsoleNotifier();
final Notification notification = new StreamlineEventAdapter(event);
new MockUp<NotificationQueueHandler>() {
@Mock
public void enqueue(Notifier notifier, Notification notification1) {
// System.out.println("Mocked enqueue");
notifier.notify(notification);
}
};
new Expectations() {
{
mockProxyUtil.loadClassFromJar("/tmp/console_notifier.jar", "ConsoleNotifier");
result = consoleNotifier;
tuple.getValueByField(anyString);
result = event;
}
};
Map<String, String> stormConf = new HashMap<>();
stormConf.put("catalog.root.url", "http://localhost:8080/api/v1/catalog");
stormConf.put("local.notifier.jar.path", "/tmp");
consoleNotificationBolt.prepare(stormConf, null, collector);
consoleNotificationBolt.execute(tuple);
new Verifications() {
{
collector.ack(tuple);
times = 1;
hBaseNotificationStore.store(notification);
times = 1;
}
};
}
Aggregations