예제 #1
0
  /** Tests the compileIssueAndCreateNew function */
  public void testCompileIssueAndCreateNew() {
    Newsletter newsletter = new Newsletter("BFH Newsletter", "blablabla", 6);
    Issue issue = newsletter.compileIssueAndCreateNew(2007, new Date());

    assertTrue(issue.getYear() == 2007);
    assertTrue(issue.getId() == 200701);
  }
예제 #2
0
  /** Tests the addArticle function */
  public void testAddArticle() {
    Newsletter newsletter = new Newsletter("BFH Newsletter", "blablabla", 6);
    Article article =
        newsletter.addArticle("NewsletterArticle", "The newsletter project is really funny ;)");

    assertTrue("NewsletterArticle".equals(newsletter.getArticle(article.getId()).getTitle()));
  }
예제 #3
0
  /** Tests the subscribe function */
  public void testSubscribe() {
    Subscriber subscriber = new Subscriber("*****@*****.**", "myPassword");
    Newsletter newsletter = new Newsletter("BFH Newsletter", "blablabla", 6);

    newsletter.subscribe(subscriber);
    assertTrue(newsletter.hasNewsletterSubscription(subscriber));
  }
예제 #4
0
  /** Tests the getArticle function */
  public void testGetArticle() {
    Newsletter newsletter = new Newsletter("BFH Newsletter", "blablabla", 6);
    Article article1 =
        newsletter.addArticle("Article 1", "The newsletter project is really funny ;)");

    assertTrue(article1.equals(newsletter.getArticle(article1.getId())));
  }
예제 #5
0
  /** Tests the getUnlinkedArticle function */
  public void testGetUnlinkedArticles() {
    Newsletter newsletter = new Newsletter("BFH Newsletter", "blablabla", 6);
    Article article1 =
        newsletter.addArticle("Article 1", "The newsletter project is really funny ;)");
    Article article2 =
        newsletter.addArticle("Article 2", "The newsletter project is really funny ;)");
    Article article3 =
        newsletter.addArticle("Article 3", "The newsletter project is really funny ;)");

    Map unlinkedArticles = newsletter.getUnlinkedArticles();

    assertTrue(unlinkedArticles.containsValue(article1));
    assertTrue(unlinkedArticles.containsValue(article2));
    assertTrue(unlinkedArticles.containsValue(article3));
    assertTrue(unlinkedArticles.size() == 3);
  }
예제 #6
0
  /** Tests the setArticleToOpenIssue function */
  public void testLinkArticles() {

    Newsletter newsletter = new Newsletter("BFH Newsletter", "blablabla", 6);
    Issue issue = newsletter.compileIssueAndCreateNew(2007, new Date());

    Article article1 =
        newsletter.addArticle("Article 1", "The newsletter project is really funny ;)");
    Article article2 =
        newsletter.addArticle("Article 2", "The newsletter project is really funny ;)");
    Article article3 =
        newsletter.addArticle("Article 3", "The newsletter project is really funny ;)");

    newsletter.setArticleToOpenIssue(article1.getId());
    newsletter.setArticleToOpenIssue(article2.getId());

    Map unlinkedArticles = newsletter.getUnlinkedArticles();
    Map issueArticles = issue.getArticles();

    assertFalse(unlinkedArticles.containsValue(article1));
    assertFalse(unlinkedArticles.containsValue(article2));
    assertTrue(unlinkedArticles.containsValue(article3));
    assertTrue(unlinkedArticles.size() == 1);

    assertTrue(issueArticles.containsValue(article1));
    assertTrue(issueArticles.containsValue(article2));
    assertFalse(issueArticles.containsValue(article3));
    assertTrue(issueArticles.size() == 2);
  }