Package org.graylog2.plugin.streams

Examples of org.graylog2.plugin.streams.Stream


        if(!type.equals("users") && !type.equals("emails")) {
            LOG.warn("No such type: [{}]", type);
            throw new WebApplicationException(400);
        }

        Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (org.graylog2.database.NotFoundException e) {
            throw new WebApplicationException(404);
        }
View Full Code Here


            value = "The stream id this new alert condition belongs to.",
            required = true) @PathParam("streamId") String streamid)
            throws TransportConfigurationException, EmailException {
        checkPermission(RestPermissions.STREAMS_EDIT, streamid);

        Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (org.graylog2.database.NotFoundException e) {
            throw new WebApplicationException(404);
        }
View Full Code Here

        assertEquals(messageOutputs.size(), 1);
        assertTrue(messageOutputs.contains(defaultMessageOutput));
    }

    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);
View Full Code Here

        assertEquals(messageOutputs.size(), 0);
    }

    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 = new HashSet<Output>() {{ add(output); }};
        when(stream.getOutputs()).thenReturn(outputSet);
        when(output.getId()).thenReturn(outputId);
        when(outputRegistry.getOutputForId(eq(outputId))).thenReturn(messageOutput);
        final OutputRouter outputRouter = new OutputRouter(defaultMessageOutput, outputRegistry);

        final Collection<MessageOutput> messageOutputs = outputRouter.getMessageOutputsForStream(stream);
View Full Code Here

        assertEquals(messageOutputs.size(), 1);
        assertTrue(messageOutputs.contains(messageOutput));
    }

    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 = new HashSet<Output>() {{ add(output1); add(output2); }};
        when(stream.getOutputs()).thenReturn(outputSet);
        when(output1.getId()).thenReturn(output1Id);
        when(output2.getId()).thenReturn(output2Id);
        when(outputRegistry.getOutputForId(eq(output1Id))).thenReturn(messageOutput1);
        when(outputRegistry.getOutputForId(eq(output2Id))).thenReturn(messageOutput2);
        final OutputRouter outputRouter = new OutputRouter(defaultMessageOutput, outputRegistry);
View Full Code Here

        assertTrue(messageOutputs.contains(messageOutput1));
        assertTrue(messageOutputs.contains(messageOutput2));
    }

    public void testGetOutputFromSingleStreams() throws Exception {
        final Stream stream = mock(Stream.class);
        List<Stream> streamList = new ArrayList<Stream>() {{
            add(stream);
        }};
        final Message message = mock(Message.class);
        when(message.getStreams()).thenReturn(streamList);
View Full Code Here

        assertTrue(messageOutputs.contains(defaultMessageOutput));
        assertTrue(messageOutputs.contains(messageOutput));
    }

    public void testGetOutputsFromTwoStreams() throws Exception {
        final Stream stream1 = mock(Stream.class);
        final Stream stream2 = mock(Stream.class);
        final MessageOutput messageOutput1 = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputSet1 = new HashSet<MessageOutput>() {{ add(messageOutput1); }};
        final MessageOutput messageOutput2 = mock(MessageOutput.class);
        final Set<MessageOutput> messageOutputSet2 = new HashSet<MessageOutput>() {{ add(messageOutput2); }};
        final Message message = mock(Message.class);
View Full Code Here

        assertTrue(result.contains(messageOutput2));
    }

    @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 = new HashSet<MessageOutput>() {{ add(messageOutput); }};
        final Message message = mock(Message.class);
        final List<Stream> streamList = new ArrayList<Stream>() {{ add(stream1); add(stream2); }};
        when(message.getStreams()).thenReturn(streamList);
View Full Code Here

    public Response create(@ApiParam(name = "JSON body", required = true) final CreateRequest cr) throws ValidationException {
        checkPermission(RestPermissions.STREAMS_CREATE);

        // Create stream.

        final Stream stream = streamService.create(cr, getCurrentUser().getName());
        stream.setDisabled(true);

        final String id = streamService.save(stream);

        if (cr.rules != null && cr.rules.size() > 0) {
            for (CreateStreamRuleRequest request : cr.rules) {
View Full Code Here

            @ApiResponse(code = 404, message = "Stream not found."),
            @ApiResponse(code = 400, message = "Invalid ObjectId.")
    })
    public Stream update(@ApiParam(name = "JSON body", required = true) CreateRequest cr, @ApiParam(name = "streamId", required = true) @PathParam("streamId") String streamId) throws NotFoundException, ValidationException {
        checkPermission(RestPermissions.STREAMS_EDIT, streamId);
        final Stream stream = streamService.load(streamId);

        stream.setTitle(cr.title);
        stream.setDescription(cr.description);

        streamService.save(stream);

        return stream;
    }
View Full Code Here

TOP

Related Classes of org.graylog2.plugin.streams.Stream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.