Package org.javaee7.json.streaming.generate

Examples of org.javaee7.json.streaming.generate.StreamingGeneratorTest


    @Test
    public void saveParentSeparatelyFirst() {

        Parent parent = indexColumnTesterService.save(new Parent());

        Child child1 = new Child();
        Child child2 = new Child();

        parent.getChildren().add(child1);
        parent.getChildren().add(child2);

        parent = indexColumnTesterService.save(parent);
View Full Code Here


     */
    @Test
    public void saveParentWithOneChildFirst() {

        Parent parent = new Parent();
        Child child1 = new Child();
        parent.getChildren().add(child1);

        // Save parent with 1 child in one go
        parent = indexColumnTesterService.save(parent);

        Child child2 = new Child();
        parent.getChildren().add(child2);

        // Save parent again with second child
        parent = indexColumnTesterService.save(parent);

View Full Code Here

     *
     */
    @Test
    public void saveInOneGo() {

        Parent parent = new Parent();
        Child child1 = new Child();
        Child child2 = new Child();

        parent.getChildren().add(child1);
        parent.getChildren().add(child2);

        parent = indexColumnTesterService.save(parent);

        Parent savedParent = indexColumnTesterService.getParentById(parent.getId());

        assertEquals("2 children added to parent and saved, but after re-loading number of chilren different",
            2, savedParent.getChildren().size()
        );
    }
View Full Code Here

     *
     */
    @Test
    public void saveParentSeparatelyFirst() {

        Parent parent = indexColumnTesterService.save(new Parent());

        Child child1 = new Child();
        Child child2 = new Child();

        parent.getChildren().add(child1);
        parent.getChildren().add(child2);

        parent = indexColumnTesterService.save(parent);

        Parent savedParent = indexColumnTesterService.getParentById(parent.getId());

        assertEquals("2 children added to parent and saved, but after re-loading number of chilren different",
            2, savedParent.getChildren().size()
        );

    }
View Full Code Here

     * </pre>
     */
    @Test
    public void saveParentWithOneChildFirst() {

        Parent parent = new Parent();
        Child child1 = new Child();
        parent.getChildren().add(child1);

        // Save parent with 1 child in one go
        parent = indexColumnTesterService.save(parent);

        Child child2 = new Child();
        parent.getChildren().add(child2);

        // Save parent again with second child
        parent = indexColumnTesterService.save(parent);

        Parent savedParent = indexColumnTesterService.getParentById(parent.getId());

        assertEquals("2 children added to parent and saved, but after re-loading number of chilren different",
            2, savedParent.getChildren().size()
        );

    }
View Full Code Here

    public void testGet() throws Exception {
        assertNotNull(bean);
        List<Employee> list = bean.get();
        assertNotNull(list);
        assertEquals(8, list.size());
        assertFalse(list.contains(new Employee("Penny")));
        assertFalse(list.contains(new Employee("Sheldon")));
        assertFalse(list.contains(new Employee("Amy")));
        assertFalse(list.contains(new Employee("Leonard")));
        assertFalse(list.contains(new Employee("Bernadette")));
        assertFalse(list.contains(new Employee("Raj")));
        assertFalse(list.contains(new Employee("Howard")));
        assertFalse(list.contains(new Employee("Priya")));
    }
View Full Code Here

                .request()
                .get(Movie[].class);
    }

    public Movie getMovie() {
        Movie m = target
                .path("{movie}")
                .resolveTemplate("movie", bean.getMovieId())
                .request()
                .get(Movie.class);
        return m;
View Full Code Here

                .get(Movie.class);
        return m;
    }

    public Movie getMovieJson() {
        Movie m = target
                .path("{movie}")
                .resolveTemplate("movie", bean.getMovieId())
                .request(MediaType.APPLICATION_JSON)
                .get(Movie.class);
        return m;
View Full Code Here

                .get(Movie.class);
        return m;
    }

    public void addMovie() {
        Movie m = new Movie();
        m.setId(bean.getMovieId());
        m.setName(bean.getMovieName());
        m.setActors(bean.getActors());
        target
                .register(MovieWriter.class)
                .request()
                .post(Entity.entity(m, MediaType.APPLICATION_JSON));
    }
View Full Code Here

        return Movie.class.isAssignableFrom(type);
    }

    @Override
    public Movie readFrom(Class<Movie> type, Type type1, Annotation[] antns, MediaType mt, MultivaluedMap<String, String> mm, InputStream in) throws IOException, WebApplicationException {
        Movie movie = new Movie();
        JsonParser parser = Json.createParser(in);
        while (parser.hasNext()) {
            switch (parser.next()) {
                case KEY_NAME:
                    String key = parser.getString();
                    parser.next();
                    switch (key) {
                        case "id":
                            movie.setId(parser.getInt());
                            break;
                        case "name":
                            movie.setName(parser.getString());
                            break;
                        case "actors":
                            movie.setActors(parser.getString());
                            break;
                        default:
                            break;
                    }
                    break;
View Full Code Here

TOP

Related Classes of org.javaee7.json.streaming.generate.StreamingGeneratorTest

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.