예제 #1
0
  @Test
  public void createConfirmed() throws Exception {

    toDelete.add(chatService.createChatCommunity(adminPerson.getUserName(), "confirmed", false));

    try (DbContext context = contextProvider.getDbContext()) {
      context.clearCache();

      Community c = context.getCommunityDAO().getByName("confirmed");
      assertTrue(c.isConfirmed());
    }
  }
예제 #2
0
  @Test
  public void sanityPersonCommunity() throws Exception {

    toDelete.add(chatService.createChatCommunity(plainPerson.getUserName(), "sanityR", false));

    try (DbContext context = contextProvider.getDbContext()) {
      context.clearCache();

      Person person = context.getPersonDAO().getById(plainPerson.getPersonId());

      assertEquals(1, person.getCreatedCommunities().size());
      assertEquals("sanityR", person.getCreatedCommunities().get(0).getName());
    }
  }
예제 #3
0
  @After
  public void teardown() throws Exception {

    try (DbContext context = contextProvider.getDbContext()) {

      CommunityDAO communityDAO = context.getCommunityDAO();

      for (Community c : toDelete) {
        communityDAO.remove(c.getCommunityId());
      }

      PersonDAO personDao = context.getPersonDAO();

      personDao.remove(plainPerson.getPersonId());
      personDao.remove(adminPerson.getPersonId());
      personDao.remove(inActivePerson.getPersonId());

      context.commit();
    }
  }
예제 #4
0
  @Test
  public void createUnconfirmed() throws Exception {

    toDelete.add(chatService.createChatCommunity(plainPerson.getUserName(), "unconfirmed", false));

    /* one would expect this to work, albeit it does not... curse jpa, curse curse curse
     * I guess it is ok, since the entities are detached anyway...
     *
     * assertEquals(1, plainPerson.getMemberships().size() );
     */
    try (DbContext context = contextProvider.getDbContext()) {
      context.clearCache();

      Community c = context.getCommunityDAO().getByName("unconfirmed");
      assertFalse(c.isConfirmed());

      Person p = context.getPersonDAO().getById(plainPerson.getPersonId());
      assertEquals(1, p.getMemberships().size());
      assertEquals("unconfirmed", p.getMemberships().get(0).getCommunity().getName());
    }
  }
예제 #5
0
  @Before
  public void setup() throws Exception {

    contextProvider = new DbContextProviderImpl();

    chatService = new ChatServiceImpl();
    chatService.setDbContext(contextProvider);

    try (DbContext context = contextProvider.getDbContext()) {

      context.persist(plainPerson);

      adminPerson.setIsAdmin(true);
      context.persist(adminPerson);

      inActivePerson.setIsActive(false);
      context.persist(inActivePerson);

      context.commit();
    }
  }