Examples of Blog


Examples of slim3.demo.model.Blog

        assertThat(updated.getContent(), is("222"));
    }

    @Test
    public void delete() throws Exception {
        Blog blog = new Blog();
        Datastore.put(blog);
        service.delete(blog.getKey(), blog.getVersion());
    }
View Full Code Here

Examples of slim3.demo.model.Blog

        service.delete(Datastore.createKey(Blog.class, 1), 1L);
    }

    @Test(expected = ConcurrentModificationException.class)
    public void deleteWhenOptimisticLockFailed() throws Exception {
        Blog blog = new Blog();
        Datastore.put(blog);
        service.delete(blog.getKey(), blog.getVersion() + 1);
    }
View Full Code Here

Examples of slim3.demo.model.Blog

        tx.commit();
    }

    public Blog update(Key key, Long version, Map<String, Object> input) {
        Transaction tx = Datastore.beginTransaction();
        Blog blog = Datastore.get(tx, b, key, version);
        BeanUtil.copy(input, blog);
        Datastore.put(tx, blog);
        tx.commit();
        return blog;
    }
View Full Code Here

Examples of slim3.demo.model.Blog

        return blog;
    }

    public void delete(Key key, Long version) {
        Transaction tx = Datastore.beginTransaction();
        Blog blog = Datastore.get(tx, b, key, version);
        Datastore.delete(tx, blog.getKey());
        tx.commit();
    }
View Full Code Here

Examples of slim3.demo.model.Blog

    @Override
    public Navigation run() throws Exception {
        if (!validate()) {
            return forward("create");
        }
        Blog blog = new Blog();
        BeanUtil.copy(request, blog);
        service.insert(blog);
        return redirect(basePath);
    }
View Full Code Here

Examples of slim3.demo.model.Blog

    private BlogMeta meta = BlogMeta.get();

    @Override
    public Navigation run() throws Exception {
        Blog blog = service.get(asKey(meta.key), asLong(meta.version));
        BeanUtil.copy(blog, request);
        return forward("/blog/edit.jsp");
    }
View Full Code Here

Examples of slim3.demo.model.Blog

    private BlogMeta b = BlogMeta.get();

    @Override
    public Navigation run() throws Exception {
        Blog blog = new Blog();
        BeanUtil.copy(request, blog);
        response.getWriter().write(b.modelToJson(blog));
        return null;
    }
View Full Code Here

Examples of slim3.demo.model.Blog

public class UpdateControllerTest extends ControllerTestCase {

    @Test
    public void run() throws Exception {
        Blog blog = new Blog();
        blog.setTitle("aaa");
        blog.setContent("111");
        Datastore.put(blog);
        tester.param("key", Datastore.keyToString(blog.getKey()));
        tester.param("title", "aaa2");
        tester.param("content", "222");
        tester.param("version", blog.getVersion());
        tester.start("/blog/update");
        UpdateController controller = tester.getController();
        assertThat(controller, is(notNullValue()));
        assertThat(tester.isRedirect(), is(true));
        assertThat(tester.getDestinationPath(), is("/blog/"));
        blog = Datastore.get(Blog.class, blog.getKey());
        assertThat(blog, is(notNullValue()));
        assertThat(blog.getTitle(), is("aaa2"));
        assertThat(blog.getContent(), is("222"));
    }
View Full Code Here

Examples of slim3.demo.model.Blog

public class DeleteControllerTest extends ControllerTestCase {

    @Test
    public void run() throws Exception {
        int count = Datastore.query(Blog.class).count();
        Blog blog = new Blog();
        Datastore.put(blog);
        tester.param("key", Datastore.keyToString(blog.getKey()));
        tester.param("version", blog.getVersion());
        tester.start("/blog/delete");
        DeleteController controller = tester.getController();
        assertThat(controller, is(notNullValue()));
        assertThat(tester.isRedirect(), is(true));
        assertThat(tester.getDestinationPath(), is("/blog/"));
View Full Code Here

Examples of slim3.demo.model.Blog

public class EditControllerTest extends ControllerTestCase {

    @Test
    public void run() throws Exception {
        Blog blog = new Blog();
        blog.setTitle("aaa");
        blog.setContent("111");
        Datastore.put(blog);
        tester.param("key", Datastore.keyToString(blog.getKey()));
        tester.param("version", blog.getVersion());
        tester.start("/blog/edit");
        EditController controller = tester.getController();
        assertThat(controller, is(notNullValue()));
        assertThat(tester.isRedirect(), is(false));
        assertThat(tester.getDestinationPath(), is("/blog/edit.jsp"));
        assertThat(tester.asKey("key"), is(blog.getKey()));
        assertThat(tester.asString("title"), is(blog.getTitle()));
        assertThat(tester.asString("content"), is(blog.getContent()));
        assertThat(tester.asLong("version"), is(blog.getVersion()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.