use of org.graylog2.outputs.DefaultMessageOutput in project graylog2-server by Graylog2.
the class OutputRouterTest method testGetOutputsWithIdenticalMessageOutputs.
@Test
public void testGetOutputsWithIdenticalMessageOutputs() throws Exception {
final Stream stream1 = mock(Stream.class);
final Stream stream2 = mock(Stream.class);
final MessageOutput messageOutput = mock(MessageOutput.class);
final Set<MessageOutput> messageOutputSet = ImmutableSet.of(messageOutput);
final Message message = mock(Message.class);
when(message.getStreams()).thenReturn(ImmutableSet.of(stream1, stream2));
OutputRouter outputRouter = Mockito.spy(new OutputRouter(defaultMessageOutput, outputRegistry));
doReturn(messageOutputSet).when(outputRouter).getMessageOutputsForStream(eq(stream1));
doReturn(messageOutputSet).when(outputRouter).getMessageOutputsForStream(eq(stream2));
final Collection<MessageOutput> result = outputRouter.getOutputsForMessage(message);
assertEquals(result.size(), 2);
assertTrue(result.contains(defaultMessageOutput));
assertTrue(result.contains(messageOutput));
}
use of org.graylog2.outputs.DefaultMessageOutput in project graylog2-server by Graylog2.
the class OutputRouterTest method testGetMessageOutputsForSingleStream.
@Test
public void testGetMessageOutputsForSingleStream() throws Exception {
final Stream stream = mock(Stream.class);
final Output output = mock(Output.class);
final String outputId = "foobar";
final MessageOutput messageOutput = mock(MessageOutput.class);
final Set<Output> outputSet = ImmutableSet.of(output);
when(stream.getOutputs()).thenReturn(outputSet);
when(output.getId()).thenReturn(outputId);
when(outputRegistry.getOutputForIdAndStream(eq(outputId), eq(stream))).thenReturn(messageOutput);
final OutputRouter outputRouter = new OutputRouter(defaultMessageOutput, outputRegistry);
final Collection<MessageOutput> messageOutputs = outputRouter.getMessageOutputsForStream(stream);
assertEquals(messageOutputs.size(), 1);
assertTrue(messageOutputs.contains(messageOutput));
}
use of org.graylog2.outputs.DefaultMessageOutput in project graylog2-server by Graylog2.
the class OutputRouterTest method testAlwaysIncludeDefaultOutput.
@Test
public void testAlwaysIncludeDefaultOutput() throws Exception {
final Message message = mock(Message.class);
final OutputRouter outputRouter = new OutputRouter(defaultMessageOutput, outputRegistry);
final Collection<MessageOutput> messageOutputs = outputRouter.getOutputsForMessage(message);
assertEquals(messageOutputs.size(), 1);
assertTrue(messageOutputs.contains(defaultMessageOutput));
}
Aggregations