Package com.jdkcn.myblog.domain

Examples of com.jdkcn.myblog.domain.Entry


  public void testEntriesPageSearch() throws Exception {
   
    EntryService entryServiceMock = EasyMock.createMock(EntryServiceImpl.class);
   
    List<Entry> list = new LinkedList<Entry>();
    list.add(new Entry());
    Capture<Range> captureRange = new Capture<Range>();
   
    PaginationSupport<Entry> ps = new PaginationSupport<Entry>(list, list.size());
    expect(entryServiceMock.search(EasyMock.anyObject(Condition.class), EasyMock.capture(captureRange), EasyMock.anyObject(Sorter.class))).andReturn(ps)
    .once();
View Full Code Here


   * {@inheritDoc}
   */
  @Transactional
  public Entry saveOrUpdate(Entry entry) {
    if (StringUtils.isNotBlank(entry.getName())) {
      Entry exist = getByName(entry.getBlog().getId(), entry.getName());
      if (exist != null && !StringUtils.equals(exist.getId(), entry.getId())) {
        throw new DuplicateException("entry in blogId[" + entry.getBlog().getId() + "] duplicate with name:" + entry.getName());
      }
    }
    if (entry.getStatus() == null) {
      entry.setStatus(Status.DRAFT);
View Full Code Here

  public void testEntriesPage() throws Exception {

    EntryService entryServiceMock = EasyMock.createMock(EntryServiceImpl.class);

    List<Entry> list = new LinkedList<Entry>();
    list.add(new Entry());
    Capture<Range> captureRange = new Capture<Range>();

    PaginationSupport<Entry> ps = new PaginationSupport<Entry>(list, list.size());
    expect(entryServiceMock.search(EasyMock.anyObject(Condition.class), EasyMock.capture(captureRange), EasyMock.anyObject(Sorter.class))).andReturn(ps)
        .once();
View Full Code Here

    author.setEmail("tester@gmail.com");
    author.setPassword("******");
    author = userService.saveOrUpdate(author);
   
    EntryService entryService = injector.getInstance(EntryService.class);
    entry = new Entry();
    entry.setBlog(blog);
    entry.setTitle("Test post");
    entry.setType(Type.ENTRY);
    entry.setContent("Test content");
    entry.setExcerpt("Test excerpt");
View Full Code Here

  }
 
  @Post
  public String save() {
    if (StringUtils.isNotBlank(entry.getName())) {
      Entry exist = entryService.getByName(blogId, entry.getName());
      if (exist != null) {
        return "/adm/entry/add";
      }
    }
    entry.setBlog(blogService.get(blogId));
View Full Code Here

    return blog;
  }

  @Test
  public void testSaveOrUpdate() throws Exception {
    Entry entry = new Entry();
    entry.setBlog(blog);
    entry.setAuthor(author);
    entry.setType(Type.ENTRY);
    entry.setTitle("Welcome to Myblog 2.0");
    entry.setContent("My first post..");
    entry.setExcerpt("First");
    entry.setCommentStatus(CommentStatus.OPEN);
    entry.setStatus(Status.PUBLISH);
    entry.setPingStatus(PingStatus.OPEN);
    entry.setUpdateDate(new Date());
    entry.setPublishDate(new Date());

    assertNull(entry.getId());
    String entryId = entryService.saveOrUpdate(entry).getId();
    assertNotNull(entryId);

    Entry savedEntry = entryService.get(entryId);
    assertEquals("Welcome to Myblog 2.0", savedEntry.getTitle());
  }
View Full Code Here

    assertEquals("Welcome to Myblog 2.0", savedEntry.getTitle());
  }

  @Test(expected = DuplicateException.class)
  public void testDuplicateName() throws Exception {
    Entry entry = new Entry();
    entry.setType(Type.ENTRY);
    entry.setBlog(blog);
    entry.setAuthor(author);
    entry.setTitle("Welcome to Myblog 2.0");
    entry.setContent("My first post..");
    entry.setExcerpt("First");
    entry.setName("welcome-to-myblog2");
    entry.setCommentStatus(CommentStatus.OPEN);
    entry.setStatus(Status.PUBLISH);
    entry.setPingStatus(PingStatus.OPEN);
    entry.setUpdateDate(new Date());
    entry.setPublishDate(new Date());

    entryService.saveOrUpdate(entry);

    Entry entry2 = new Entry();
    entry2.setBlog(blog);
    entry2.setType(Type.ENTRY);
    entry2.setAuthor(author);
    entry2.setTitle("Another Welcome");
    entry2.setContent("Another content");
    entry2.setExcerpt("First");
    entry2.setName("welcome-to-myblog2");
    entry2.setCommentStatus(CommentStatus.OPEN);
    entry2.setStatus(Status.PUBLISH);
    entry2.setPingStatus(PingStatus.OPEN);
    entry2.setUpdateDate(new Date());
    entry2.setPublishDate(new Date());

    entryService.saveOrUpdate(entry2);
  }
View Full Code Here

    entryService.saveOrUpdate(entry2);
  }

  @Test
  public void testNotDuplicateName() throws Exception {
    Entry entry = new Entry();
    entry.setType(Type.ENTRY);
    entry.setBlog(blog);
    entry.setAuthor(author);
    entry.setTitle("Welcome to Myblog 2.0");
    entry.setContent("My first post..");
    entry.setExcerpt("First");
    entry.setName("welcome-to-myblog2");
    entry.setCommentStatus(CommentStatus.OPEN);
    entry.setStatus(Status.PUBLISH);
    entry.setPingStatus(PingStatus.OPEN);
    entry.setUpdateDate(new Date());
    entry.setPublishDate(new Date());

    entryService.saveOrUpdate(entry);

    Entry entry2 = new Entry();
    entry2.setBlog(createBlog("Another Blog", injector.getInstance(BlogService.class)));
    entry2.setType(Type.ENTRY);
    entry2.setAuthor(author);
    entry2.setTitle("Another Welcome");
    entry2.setContent("Another content");
    entry2.setExcerpt("First");
    entry2.setName("welcome-to-myblog2");
    entry2.setCommentStatus(CommentStatus.OPEN);
    entry2.setStatus(Status.PUBLISH);
    entry2.setPingStatus(PingStatus.OPEN);
    entry2.setUpdateDate(new Date());
    entry2.setPublishDate(new Date());

    entryService.saveOrUpdate(entry2);
  }
View Full Code Here

    ps = entryService.search(condition, new Range(0, 5), new Sorter().asc("title"));
    assertEquals(5, ps.getTotalCount());
  }

  private Entry createEntry(String title, String content) {
    Entry entry = new Entry();
    entry.setType(Type.ENTRY);
    entry.setBlog(blog);
    entry.setAuthor(author);
    entry.setTitle(title);
    entry.setContent(content);
    entry.setExcerpt(title);
    entry.setCommentStatus(CommentStatus.OPEN);
    entry.setStatus(Status.PUBLISH);
    entry.setPingStatus(PingStatus.OPEN);
    entry.setUpdateDate(new Date());
    entry.setPublishDate(new Date());

    return entryService.saveOrUpdate(entry);
  }
View Full Code Here

TOP

Related Classes of com.jdkcn.myblog.domain.Entry

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.