Пример #1
0
  @Test
  @Transactional
  public void testAddContactToOrganizationMultipleGroups() throws Exception {

    groupService.create(group);
    groupService.addAggregation(organization, group);

    Group secondGroup = new Group();
    secondGroup.setGroupName("Second Group");
    groupService.create(secondGroup);
    groupService.addAggregation(organization, secondGroup);

    Contact newContact = new Contact();
    newContact.setFirstName("Fresh Contact");
    newContact.setEmail("Fresh email");
    contactService.create(newContact);

    contactService.addContactToOrganization(newContact, organization);

    newContact = contactService.findById(newContact.getId());
    assertTrue(newContact.getOrganizations().contains(organization));

    group = groupService.findById(group.getId());
    assertTrue(group.getAggregations().contains(organization));

    secondGroup = groupService.findById(secondGroup.getId());
    assertTrue(secondGroup.getAggregations().contains(organization));

    organization = organizationService.findById(organization.getId());
    assertTrue(organization.getMembers().contains(newContact));
  }
Пример #2
0
  @Test
  public void testAddMultipleContacts() throws Exception {
    groupService.create(group);
    groupService.addAggregation(committee, group);

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

    Contact anotherContact = new Contact();
    anotherContact.setFirstName("Another");
    anotherContact.setEmail("*****@*****.**");
    contactService.create(anotherContact);

    contactService.addToGroup(anotherContact, group);
    group = groupService.findById(group.getId());
    assertEquals(2, group.getTopLevelMembers().size());

    anotherContact = contactService.findById(anotherContact.getId());
    topLevel = contactService.findById(topLevel.getId());

    assertEquals(1, anotherContact.getGroups().size());
    assertEquals(1, topLevel.getGroups().size());

    groupService.delete(group);

    anotherContact = contactService.findById(anotherContact.getId());
    topLevel = contactService.findById(topLevel.getId());

    assertEquals(0, anotherContact.getGroups().size());
    assertEquals(0, topLevel.getGroups().size());
  }
Пример #3
0
  @Test
  @Transactional
  public void testAddContactToMultipleGroupsMultipleConstituents() throws Exception {

    groupService.create(group);
    groupService.addAggregation(committee, group);
    groupService.addAggregation(event, group);

    Group secondGroup = new Group();
    secondGroup.setGroupName("Second Group");
    groupService.create(secondGroup);
    groupService.addAggregation(committee, secondGroup);
    groupService.addAggregation(event, secondGroup);

    Contact contact = new Contact();
    contact.setFirstName("Test Contact");
    contact.setEmail("*****@*****.**");
    contactService.create(contact);

    contactService.addContactToCommittee(contact, committee);
    contactService.attendEvent(contact, event);
    contactService.addToGroup(contact, group);
    contactService.addToGroup(contact, secondGroup);

    contact = contactService.findById(contact.getId());
    group = groupService.findById(group.getId());
    secondGroup = groupService.findById(secondGroup.getId());
    event = eventService.findById(event.getId());
    committee = committeeService.findById(committee.getId());

    assertTrue(contact.getGroups().contains(group));
    assertTrue(contact.getGroups().contains(secondGroup));
    assertTrue(contact.getCommittees().contains(committee));
    assertTrue(contact.getAttendedEvents().contains(event));

    assertTrue(event.getAttendees().contains(contact));
    assertTrue(event.getGroups().contains(group));
    assertTrue(event.getGroups().contains(secondGroup));

    assertTrue(committee.getMembers().contains(contact));
    assertTrue(committee.getGroups().contains(group));
    assertTrue(committee.getGroups().contains(secondGroup));

    assertTrue(group.getTopLevelMembers().contains(contact));
    assertTrue(group.getAggregations().contains(committee));
    assertTrue(group.getAggregations().contains(event));

    assertTrue(secondGroup.getTopLevelMembers().contains(contact));
    assertTrue(secondGroup.getAggregations().contains(committee));
    assertTrue(secondGroup.getAggregations().contains(event));
  }
Пример #4
0
  @Test
  @Transactional
  public void testAddContactToGroupAndGroupConstituent() throws Exception {

    groupService.create(group);
    groupService.addAggregation(committee, group);

    Contact contact = new Contact();
    contact.setFirstName("Test Contact");
    contact.setEmail("*****@*****.**");
    contactService.create(contact);

    contactService.addContactToCommittee(contact, committee);
    contactService.addToGroup(contact, group);

    contact = contactService.findById(contact.getId());
    assertTrue(contact.getGroups().contains(group));
    assertTrue(contact.getCommittees().contains(committee));

    committee = committeeService.findById(committee.getId());
    assertTrue(committee.getMembers().contains(contact));

    group = groupService.findById(group.getId());
    assertTrue(group.getTopLevelMembers().contains(contact));
  }
Пример #5
0
  @Test
  public void testRemoveContactFromAggregation() throws Exception {
    groupService.create(group);
    groupService.addAggregation(committee, group);

    group = groupService.findById(group.getId());
    assertEquals(
        committee.getMembers().size(),
        group.getAggregations().iterator().next().getAggregationMembers().size());

    contactService.removeContactFromCommittee(first, committee);

    committee = committeeService.findById(committee.getId());
    group = groupService.findById(group.getId());
    assertEquals(
        committee.getMembers().size(),
        group.getAggregations().iterator().next().getAggregationMembers().size());
  }
Пример #6
0
  @Test
  public void testAddAggregation() throws Exception {
    groupService.create(group);
    groupService.addAggregation(committee, group);

    Group fromDb = groupService.findById(group.getId());
    assertEquals(1, fromDb.getAggregations().size());
    Aggregation aggregation = fromDb.getAggregations().iterator().next();
    assertEquals(group.getGroupName(), aggregation.getGroups().iterator().next().getGroupName());
  }
Пример #7
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());
  }
Пример #8
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());
  }
Пример #9
0
  @Test
  @Transactional
  public void testAddEventMultipleGroups() throws Exception {

    groupService.create(group);
    groupService.addAggregation(event, group);
    groupService.addAggregation(committee, group);

    Group secondGroup = new Group();
    secondGroup.setGroupName("Second Group");
    groupService.create(secondGroup);
    groupService.addAggregation(event, secondGroup);
    groupService.addAggregation(organization, secondGroup);

    event = eventService.findById(event.getId());
    assertTrue(event.getGroups().contains(group));
    assertTrue(event.getGroups().contains(secondGroup));

    group = groupService.findById(group.getId());
    assertTrue(group.getAggregations().contains(event));

    secondGroup = groupService.findById(secondGroup.getId());
    assertTrue(secondGroup.getAggregations().contains(event));
  }
Пример #10
0
  @Test
  public void testRemoveContactFromGroup() throws Exception {
    groupService.create(group);
    groupService.addAggregation(committee, group);
    contactService.addToGroup(topLevel, group);

    assertEquals(1, group.getTopLevelMembers().size());

    contactService.removeFromGroup(topLevel, group);

    Group fromDb = groupService.findById(group.getId());
    assertEquals(0, fromDb.getTopLevelMembers().size());

    Contact contactFromDb = contactService.findById(topLevel.getId());
    assertEquals(0, contactFromDb.getGroups().size());
  }