Package org.eurekastreams.server.domain.stream

Examples of org.eurekastreams.server.domain.stream.Stream


     * Tests with invalid parameters, null string.
     */
    @Test(expected = ValidationException.class)
    public void testInvalidNull()
    {
        Stream stream = new Stream();
        stream.setName(null);

        PrincipalActionContext actionContext = new ServiceActionContext(stream, null);

        sut.validate(actionContext);
    }
View Full Code Here


     * Tests with empty array.
     */
    @Test(expected = ValidationException.class)
    public void testEmptyArray()
    {
        Stream stream = new Stream();
        stream.setName("something");
        stream.setRequest("{ query : { recipient: [  ] } }");

        PrincipalActionContext actionContext = new ServiceActionContext(stream, null);

        sut.validate(actionContext);
    }
View Full Code Here

    @Test(expected = ValidationException.class)
    public void testArrayTooLarge()
    {
        final int tooLarge = 26;

        Stream stream = new Stream();
        stream.setName("something");
        String request = "{ query : { recipient: [  ";

        for (int i = 0; i < tooLarge; i++)
        {
            if (i > 0)
            {
                request += ",";
            }
            request += "{ name: 'something" + i + "', type: 'GROUP' }";
        }

        request += "] } }";
       
        stream.setRequest(request);

        PrincipalActionContext actionContext = new ServiceActionContext(stream, null);

        sut.validate(actionContext);
    }
View Full Code Here

     * Tests with malformed JSON.
     */
    @Test(expected = ValidationException.class)
    public void testMalformedJSON()
    {
        Stream stream = new Stream();
        stream.setName("something");
        // Missing open curly brace
        stream.setRequest(" query : { recipient: [  ] } }");

        PrincipalActionContext actionContext = new ServiceActionContext(stream, null);

        sut.validate(actionContext);
    }
View Full Code Here

                int start = (null == callback) ? 5 : 7;
                queryJson = requestParser.parseRequest(getPath(), start);
            }
            else if (mode.equals("saved"))
            {
                Stream stream = streamMapper.execute(new FindByIdRequest("Stream", streamId));
                if (stream == null)
                {
                    throw new Exception("Unknown saved stream.");
                }
                queryJson = JSONObject.fromObject(stream.getRequest());
            }
            else
            {
                throw new Exception("Unknown request mode.");
            }
View Full Code Here

    @Override
    public void validate(final PrincipalActionContext inActionContext) throws ValidationException
    {
        ValidationException valEx = new ValidationException();

        Stream stream = (Stream) inActionContext.getParams();

        JSONObject object = null;
        try
        {
            object = JSONObject.fromObject(stream.getRequest());
        }
        catch (JSONException ex)
        {
            valEx.addError("stream", "Malformed JSON. Try again later.");
            throw valEx;
        }

        if (stream.getName() == null || stream.getName().length() == 0)
        {
            valEx.addError("name", "Stream must have a name.");
            throw valEx;
        }
View Full Code Here

            person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId()));
        }

        List<Stream> streams = person.getStreams();

        Stream stream = (Stream) inActionContext.getParams();
        stream.setReadOnly(false);

        if (0L != stream.getId())
        {
            for (Stream s : streams)
            {
                if (s.getId() == stream.getId())
                {
                    s.setName(stream.getName());
                    s.setReadOnly(stream.getReadOnly());
                    s.setRequest(stream.getRequest());
                }
            }
        }
        else
        {
View Full Code Here

                feed.setDescription("");
            }
            else if (mode.equals("saved"))
            {
                Stream stream = streamMapper.execute(new FindByIdRequest("Stream", streamId));

                String feedTitle = ("Eureka Streams: " + stream.getName());

                feed.setTitle(feedTitle);
                feed.setLink(baseUrl);

                feed.setDescription(feedTitle);

                if (stream == null)
                {
                    throw new Exception("Unknown saved stream.");
                }
                queryJson = JSONObject.fromObject(stream.getRequest());
            }
            else
            {
                throw new Exception("Unknown request mode.");
            }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.stream.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.