Пример #1
0
  @Test
  public void testCreateGroupFromCommittee() throws Exception {
    String id = groupService.create(group);
    groupService.addAggregation(committee, group);

    Group fromDb = groupService.findById(id);
    assertEquals(group.getGroupName(), fromDb.getGroupName());
    Aggregation aggregation = fromDb.getAggregations().iterator().next();
    assertNotNull(aggregation);
    assertEquals(
        committee.getAggregationMembers().size(), aggregation.getAggregationMembers().size());
  }
Пример #2
0
  @Test
  public void testDeleteGroup() throws Exception {
    groupService.create(group);
    groupService.addAggregation(committee, group);

    group = groupService.findById(group.getId());
    contactService.addToGroup(topLevel, group);

    groupService.delete(group);

    Group groupFromDb = groupService.findById(group.getId());
    assertNull(groupFromDb);
    Aggregation fromDb = committeeService.findById(committee.getId());
    assertNotNull(fromDb);
    assertEquals(0, fromDb.getGroups().size());
    assertEquals(committee.getAggregationMembers().size(), fromDb.getAggregationMembers().size());

    Contact topLevelFromDb = contactService.findById(topLevel.getId());
    assertNotNull(topLevelFromDb);
    assertEquals(0, topLevelFromDb.getGroups().size());
  }
Пример #3
0
  @Test
  public void testCreateGroupFromMultipleAggregations() throws Exception {
    String id = groupService.create(group);
    groupService.addAggregation(committee, group);
    group = groupService.findById(group.getId());
    groupService.addAggregation(organization, group);
    group = groupService.findById(group.getId());
    groupService.addAggregation(event, group);
    group = groupService.findById(group.getId());
    contactService.addToGroup(topLevel, group);

    Group fromDb = groupService.findById(id);
    assertEquals(group.getGroupName(), fromDb.getGroupName());
    assertEquals(3, group.getAggregations().size());
    Set<Contact> allAggregationMembers = new HashSet<>();
    for (Aggregation aggregation : group.getAggregations()) {
      for (Contact c : aggregation.getAggregationMembers()) {
        allAggregationMembers.add(c);
      }
    }
    assertEquals(2, allAggregationMembers.size());
    assertEquals(1, group.getTopLevelMembers().size());
  }