Package com.example.model

Examples of com.example.model.Greeting


    {
        final String userEmail = "foo@example.com";
        final String content = "Hello, World!";
        final Date date = new Date();
        User author = new User(userEmail, "");
        Greeting greeting = new Greeting(author, content, date);

        greetingRepo.persist(greeting);

        assertNotNull(greeting.getId());
        assertNotNull(greetingRepo.get(greeting.getId()));
    }
View Full Code Here


    @Test
    public void testPersistWithAnonymousUser()
    {
        final String content = "Hello, World!";
        final Date date = new Date();
        Greeting greeting = new Greeting(null, content, date);

        greetingRepo.persist(greeting);

        assertNotNull(greeting.getId());
        assertNotNull(greetingRepo.get(greeting.getId()));
    }
View Full Code Here

    @Test
    public void testDelete()
    {
        final String content = "Hello, World!";
        final Date date = new Date();
        final Greeting greeting = new Greeting(null, content, date);

        greetingRepo.runInTransaction(new Runnable()
        {
            public void run()
            {
                greetingRepo.persist(greeting);
            }
        });

        Long id = greeting.getId();
        assertNotNull(greetingRepo.get(id));

        greetingRepo.runInTransaction(new Runnable()
        {
            public void run()
View Full Code Here

        {
            calendar.setTime(baseDate);
            calendar.add(Calendar.MINUTE, i);
            Date date = calendar.getTime();
            dates.add(date);
            Greeting greeting = new Greeting(null, String.format(content, i), date);
            greetingRepo.persist(greeting);
        }

        // The latest greetings are returned in descending date order.
        List<Greeting> greetings = greetingQueries.latest(max);
       
        assertEquals(greetings.size(), max);
        Collections.reverse(greetings);
        dates = dates.subList(total - max, total);
        for (int i = 0; i < max; i++)
        {
            Greeting greeting = greetings.get(i);
            assertEquals(greeting.getContent(), String.format(content, total - max + i));
            assertEquals(greeting.getDate(), dates.get(i));
        }
    }
View Full Code Here

        ListView<Greeting> messages = new ListView<Greeting>("messages", latestGreetings)
        {
            @Override
            protected void populateItem(ListItem<Greeting> item)
            {
                Greeting greeting = item.getModel().getObject();
                String email = greeting.getAuthor() != null ? greeting.getAuthor().getNickname() : "An anonymous person ";
                item.add(new Label("author", email));
                item.add(new Label("message", greeting.getContent()));
            }
        };
        add(messages);

        Form<String> signForm = new Form<String>("sign-form", new Model<String>())
        {
            private TextArea<String> contentField;

            {
                contentField = new TextArea<String>("sign-content", new Model<String>(""));
                add(contentField);
            }

            @Override
            protected void onSubmit()
            {
                String content = contentField.getModelObject();
                Date date = new Date();
                Greeting greeting = new Greeting(user, content, date);
                Guestbook.this.greetingRepo.persist(greeting);
                contentField.setModelObject("");

                // This causes a redirect to a clean page and URL, rather than rendering to the state of the
                // current page which we don't care about here.
View Full Code Here

TOP

Related Classes of com.example.model.Greeting

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.