use of com.aphyr.riemann.client.IPromise in project nifi by apache.
the class TestPutRiemann method getTestRunner.
private TestRunner getTestRunner(final boolean failOnWrite) {
RiemannClient riemannClient = mock(RiemannClient.class);
when(riemannClient.sendEvents(anyListOf(Proto.Event.class))).thenAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
List<Proto.Event> events = (List<Proto.Event>) invocationOnMock.getArguments()[0];
for (Proto.Event event : events) {
eventStream.add(event);
}
IPromise iPromise = mock(IPromise.class);
if (!failOnWrite) {
when(iPromise.deref(anyInt(), any(TimeUnit.class))).thenReturn(Proto.Msg.getDefaultInstance());
} else {
when(iPromise.deref(anyInt(), any(TimeUnit.class))).thenReturn(null);
}
return iPromise;
}
});
when(riemannClient.isConnected()).thenReturn(true);
PutRiemann riemannProcessor = new PutRiemann();
riemannProcessor.riemannClient = riemannClient;
riemannProcessor.transport = PutRiemann.Transport.TCP;
TestRunner runner = TestRunners.newTestRunner(riemannProcessor);
runner.setProperty(PutRiemann.RIEMANN_HOST, "localhost");
runner.setProperty(PutRiemann.RIEMANN_PORT, "5555");
runner.setProperty(PutRiemann.TRANSPORT_PROTOCOL, "TCP");
runner.setProperty(PutRiemann.BATCH_SIZE, "100");
runner.setProperty(PutRiemann.ATTR_SERVICE, "nifi-test-service");
runner.setProperty(PutRiemann.ATTR_HOST, "${riemann.host}");
runner.setProperty(PutRiemann.ATTR_TTL, "5");
runner.setProperty(PutRiemann.ATTR_DESCRIPTION, "test");
runner.setProperty(PutRiemann.ATTR_TAGS, "tag1, tag2, tag3");
runner.setProperty(PutRiemann.ATTR_METRIC, "${riemann.metric}");
runner.setProperty("custom-attribute-1", "${custom.attribute.1}");
runner.setProperty("custom-attribute-2", "${custom.attribute.2}");
runner.setProperty("custom-attribute-3", "${custom.attribute.3}");
return runner;
}
Aggregations