예제 #1
0
 /** Test default document content. */
 @Test
 public void testDefaultDocumentContent() {
   final Content content = defaultGroup.getDefaultContent();
   assertEquals(TYPE_DOCUMENT, content.getTypeId());
   final Container rootDocFolder = content.getContainer();
   assertEquals(true, rootDocFolder.isRoot());
 }
예제 #2
0
  @Test
  public void testContentNotRated() {
    final Content cd = new Content();
    cd.setLanguage(english);
    cd.setPublishedOn(new Date());
    entityManager.persist(cd);

    closeTransaction();
    final Double rate = rateFinder.calculateRate(cd);
    final Long rateByUsers = rateFinder.calculateRateNumberOfUsers(cd);
    assertEquals(0, (long) rateByUsers);

    // FIXME: Why null? in other tests this return zero
    assertEquals(null, rate);
  }
예제 #3
0
  @Test
  @Ignore
  public void testContentRateAverage() {
    final User user1 = TestDomainHelper.createUser(1);
    final User user2 = TestDomainHelper.createUser(2);

    user1.setLanguage(english);
    user2.setLanguage(english);

    user1.setCountry(gb);
    user2.setCountry(gb);

    entityManager.persist(user1.getUserGroup());
    entityManager.persist(user2.getUserGroup());
    entityManager.persist(user1);
    entityManager.persist(user2);

    final Content cd = new Content();
    cd.setLanguage(english);
    cd.setPublishedOn(new Date());
    entityManager.persist(cd);

    entityManager.persist(new Rate(user1, cd, 1.3));
    entityManager.persist(new Rate(user2, cd, 3.3));

    // same user and content other rate
    final Rate rateFinded = rateFinder.find(user2, cd);
    rateFinded.setValue(4.3);
    entityManager.persist(rateFinded);

    closeTransaction();
    final Double rate = rateFinder.calculateRate(cd);
    final Long rateByUsers = rateFinder.calculateRateNumberOfUsers(cd);
    final Double average = (1.3 + 4.3) / 2;
    assertEquals(average, rate);
    assertEquals(Long.valueOf(2), rateByUsers);
    final Rate newRate1 = rateFinder.find(user1, cd);
    final Rate newRate2 = rateFinder.find(user2, cd);
    assertEquals(new Double(1.3), newRate1.getValue());
    assertEquals(new Double(4.3), newRate2.getValue());
  }