use of org.graylog2.plugin.outputs.MessageOutput in project graylog2-server by Graylog2.
the class OutputRouterTest method testGetMessageOutputsForEmptyStream.
@Test
public void testGetMessageOutputsForEmptyStream() throws Exception {
final Stream stream = mock(Stream.class);
final OutputRouter outputRouter = new OutputRouter(defaultMessageOutput, outputRegistry);
final Collection<MessageOutput> messageOutputs = outputRouter.getMessageOutputsForStream(stream);
assertEquals(messageOutputs.size(), 0);
}
use of org.graylog2.plugin.outputs.MessageOutput in project graylog2-server by Graylog2.
the class OutputRouterTest method testGetMessageOutputsForStreamWithTwoOutputs.
@Test
public void testGetMessageOutputsForStreamWithTwoOutputs() throws Exception {
final Stream stream = mock(Stream.class);
final Output output1 = mock(Output.class);
final Output output2 = mock(Output.class);
final String output1Id = "foo";
final String output2Id = "bar";
final MessageOutput messageOutput1 = mock(MessageOutput.class);
final MessageOutput messageOutput2 = mock(MessageOutput.class);
final Set<Output> outputSet = ImmutableSet.of(output1, output2);
when(stream.getOutputs()).thenReturn(outputSet);
when(output1.getId()).thenReturn(output1Id);
when(output2.getId()).thenReturn(output2Id);
when(outputRegistry.getOutputForIdAndStream(eq(output1Id), eq(stream))).thenReturn(messageOutput1);
when(outputRegistry.getOutputForIdAndStream(eq(output2Id), eq(stream))).thenReturn(messageOutput2);
final OutputRouter outputRouter = new OutputRouter(defaultMessageOutput, outputRegistry);
final Collection<MessageOutput> messageOutputs = outputRouter.getMessageOutputsForStream(stream);
assertEquals(messageOutputs.size(), 2);
assertTrue(messageOutputs.contains(messageOutput1));
assertTrue(messageOutputs.contains(messageOutput2));
}
use of org.graylog2.plugin.outputs.MessageOutput 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.plugin.outputs.MessageOutput 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.plugin.outputs.MessageOutput 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