Ejemplo n.º 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());
    }
  }
Ejemplo n.º 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());
    }
  }
Ejemplo n.º 3
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());
    }
  }
Ejemplo n.º 4
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();
    }
  }
Ejemplo n.º 5
0
  @Test(expected = EntityNotFoundException.class)
  public void unknownPerson() throws Exception {

    toDelete.add(chatService.createChatCommunity("gustl", "confirmed", false));
  }
Ejemplo n.º 6
0
  @Test(expected = IllegalStateException.class)
  public void inActivePerson() throws Exception {

    toDelete.add(chatService.createChatCommunity(inActivePerson.getUserName(), "confirmed", false));
  }
Ejemplo n.º 7
0
  @Test(expected = DuplicateEntityException.class)
  public void duplicate() throws Exception {

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