Esempio n. 1
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));
  }
Esempio n. 2
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));
  }
Esempio n. 3
0
 public Attitude(Amendment amendment, Committee committee) {
   this();
   setAmendment(amendment);
   setAttendance(
       attendanceService.getByCommitteeIdAndCounselId(
           committee.getId(), amendment.getCounselId()));
 }
Esempio n. 4
0
  @Before
  public void setup() throws ConstraintViolation, NullDomainReference {

    createContacts();

    committee = new Committee();
    committee.setName("Committee Name");
    committeeService.create(committee);
    contactService.addContactToCommittee(first, committee);
    contactService.addContactToCommittee(second, committee);

    organization = new Organization();
    organization.setName("Organization Name");
    organizationService.create(organization);
    contactService.addContactToOrganization(first, organization);
    contactService.addContactToOrganization(second, organization);

    event = new Event();
    event.setName("Event Name");
    event.setDateHeld("2015-01-01");
    eventService.create(event);
    contactService.attendEvent(first, event);
    contactService.attendEvent(second, event);

    group = new Group();
    group.setGroupName("New AlinskyGroup");
  }
Esempio n. 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());
  }
Esempio n. 6
0
  @Test
  public void testRemoveAggregation() throws Exception {
    String id = groupService.create(group);
    groupService.addAggregation(committee, group);

    Group fromDb = groupService.findById(id);
    assertEquals(1, fromDb.getAggregations().size());
    assertEquals(1, fromDb.getAggregations().iterator().next().getGroups().size());

    Aggregation aggregation = committeeService.findById(committee.getId());
    assertEquals(1, aggregation.getGroups().size());

    groupService.removeAggregation(committee, fromDb);

    fromDb = groupService.findById(id);
    assertEquals(0, fromDb.getAggregations().size());

    aggregation = committeeService.findById(committee.getId());
    assertEquals(0, aggregation.getGroups().size());
  }
Esempio n. 7
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());
  }
Esempio n. 8
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());
  }
 public void addCommittee(Committee committee) {
   getCommittees().add(committee);
   committee.addExpertBeerConsumer(this);
 }