Esempio n. 1
0
  @Test
  public void testGetNullValues() {
    final Event testEvent = Event.create("type").value("key1", "val1").build();

    assertTrue(testEvent.getValue("key1").isPresent());
    assertFalse(testEvent.getValue("key2").isPresent());
  }
Esempio n. 2
0
  @Test
  @Transactional
  public void testRemoveContactFromEventMultipleGroups() throws Exception {

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

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

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

    event = eventService.findById(event.getId());
    contactService.attendEvent(newContact, event);

    newContact = contactService.findById(newContact.getId());
    contactService.unattendEvent(newContact, event);

    event = eventService.findById(event.getId());
    assertFalse(event.getAttendees().contains(newContact));

    newContact = contactService.findById(newContact.getId());
    assertFalse(newContact.getAttendedEvents().contains(event));
  }
Esempio n. 3
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. 4
0
  public static Event createEvent() {
    Event event = new Event();

    event.setDateCreated(new Date());
    event.setDescription(randomString("description", 2000));
    event.setCategory(randomString("category", 50));

    return event;
  }
 public boolean onEvent(Event event) {
   System.out.println(event.toString());
   if (event.getEventType() == EventType.CALL
       && event.getCallHandle().equals(waitingForCallHandle)
       && event.getEventCode() == waitingForCallCode
       && event.getEventReason() == waitingForCallReason) {
     callSignal.notifyResponseEvent();
   }
   return false;
 }
Esempio n. 6
0
 @Test
 public void testRetrieve() throws PaysioException {
   Map<String, Object> listParams = new HashMap<String, Object>();
   listParams.put("count", 1);
   Event originalEvent = Event.all(listParams).getData().get(0);
   Event retrievedEvent = Event.retrieve(originalEvent.getId());
   assertEquals(originalEvent.getId(), retrievedEvent.getId());
   assertEquals(originalEvent.getCreated(), retrievedEvent.getCreated());
   assertNotNull(retrievedEvent.getData());
 }
Esempio n. 7
0
  @Test
  public void testToString() {
    final Event event = this.createTestEvent();

    final String result = event.toString();

    assertTrue(result.contains("type=type"));
    assertTrue(result.contains("distributed=true"));
    assertTrue(result.contains("data={key1=val1, key2=val2}"));
  }
  @Test
  public void testSamplingEvent() {
    System.out.println("- testSamplingEvent -");

    System.out.println("Create event");
    Event e = new Event();
    e.setSamplingEvent(host1, 0, 4);
    System.out.println(e.toString());

    System.out.println("Process event in tree");
    tt.processEvent(e);
    System.out.println(tt.treeInfo());
  }
Esempio n. 9
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. 10
0
  @Test
  public void testClone() {
    final Event event = this.createTestEvent();
    final Event clonedEvent = Event.create(event).build();

    assertEquals(event.getType(), clonedEvent.getType());
    assertEquals(event.isDistributed(), clonedEvent.isDistributed());
    assertEquals(event.getData(), clonedEvent.getData());
    assertEquals(event, clonedEvent);
  }
Esempio n. 11
0
  @Test
  public void testDate() {
    Model m = ModelFactory.createDefaultModel();
    Bean2RDF writer = new Bean2RDF(m);
    RDF2Bean reader = new RDF2Bean(m);

    Date d = new Date();
    Event event = new Event(d);
    event.setLocation("Dallas");
    event.setName("dinner");
    writer.save(event);
    Event event2 = reader.load(Event.class, d);
    assertNotNull(event2);
    assertEquals(d, event2.id());
  }
Esempio n. 12
0
 private Event createTestEvent() {
   return Event.create("type")
       .distributed(true)
       .value("key1", "val1")
       .value("key2", "val2")
       .build();
 }
 @Override
 public void onCoordinateEvent(Event event, String message) {
   System.err.println("Got unit test even " + event.toString() + " " + message);
   events.add(event);
   latch1.countDown();
   latch2.countDown();
 }
Esempio n. 14
0
 @Test
 public void testAll() throws PaysioException {
   Map<String, Object> listParams = new HashMap<String, Object>();
   listParams.put("count", 1);
   List<Event> events = Event.all(listParams).getData();
   assertEquals(events.size(), 1);
 }
  @Test
  public void testProcessEvent() {

    System.out.println("- testProcessEvent -");

    Host host3 = new Host(deme1, "Host3");

    System.out.println("Create event");
    Event e = new Event();
    e.setInfectionEvent(host1, host3, 2, 3.5);
    System.out.println(e.toString());

    System.out.println("Process event in tree");
    tt.processEvent(e);
    System.out.println(tt.treeInfo());

    // fail("Not yet implemented");
  }
Esempio n. 16
0
  @Test
  public void testCreateGroupFromEvent() throws Exception {
    String id = groupService.create(group);
    groupService.addAggregation(event, group);

    Group fromDb = groupService.findById(id);
    assertEquals(group.getGroupName(), fromDb.getGroupName());
    Aggregation aggregation = fromDb.getAggregations().iterator().next();
    assertNotNull(aggregation);
    assertEquals(1, aggregation.getGroups().size());
    assertEquals(event.getAggregationMembers().size(), aggregation.getAggregationMembers().size());
  }
Esempio n. 17
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));
  }
Esempio n. 18
0
  @Test
  public void testBuilder() {
    final Event event = this.createTestEvent();

    assertEquals("type", event.getType());
    assertEquals(true, event.isDistributed());
    assertNotNull(event.getData());
    assertTrue(event.hasValue("key1"));
    assertTrue(event.hasValue("key2"));
    assertEquals("val1", event.getValue("key1").get());
    assertEquals("val2", event.getValue("key2").get());
  }
Esempio n. 19
0
  @Test
  public void testDataValues() {
    final Event testEvent =
        Event.create("type")
            .distributed(true)
            .value("int1", 1)
            .value("long1", 10L)
            .value("bool1", false)
            .value("obj1", this.createTestEvent())
            .build();

    assertTrue(testEvent.hasValue("int1"));
    assertTrue(testEvent.hasValue("long1"));
    assertTrue(testEvent.hasValue("bool1"));
    assertTrue(testEvent.hasValue("obj1"));
    assertTrue(testEvent.getValue("int1").get() instanceof Integer);
    assertTrue(testEvent.getValue("long1").get() instanceof Long);
    assertTrue(testEvent.getValue("bool1").get() instanceof Boolean);
    assertTrue(testEvent.getValue("obj1").get() instanceof String);
  }
Esempio n. 20
0
  @Test
  public void testGetValueAs() {
    final Event testEvent =
        Event.create("type")
            .value("int1", 1)
            .value("long1", 10L)
            .value("obj1", ContentId.from("testId"))
            .build();

    assertTrue(testEvent.getValueAs(Double.class, "int1").get() != null);
    assertTrue(testEvent.getValueAs(Boolean.class, "long1").get() != null);
    assertTrue(testEvent.getValueAs(ContentId.class, "obj1").get() != null);
    assertFalse(testEvent.getValueAs(ContentId.class, "obj2").isPresent());
  }
Esempio n. 21
0
  @Test
  public void test() throws Exception {

    SqlSession session = SessionFactory.getSession();
    EventDao eventDao = session.getMapper(EventDao.class);

    try {

      Event event = TestEventDao.createEvent();
      String where = "KEY='" + event.getKey() + "' ";
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("where", where);

      int count = eventDao.create(event);
      assertEquals(1, count);
      assertNotNull(event.getKey());

      Event readRecord = eventDao.read(map);
      assertNotNull(readRecord.getKey());

      compareRecords(event, readRecord);

      modifyRecord(event);
      count = eventDao.update(event);
      assertEquals(1, count);

      readRecord = eventDao.read(map);
      assertNotNull(readRecord.getKey());

      compareRecords(event, readRecord);

      count = eventDao.delete(map);
      assertEquals(1, count);

      readRecord = eventDao.read(map);
      assertNull(readRecord);

    } finally {
      if (session != null) {
        session.rollback();
        session.close();
      }
    }
  }
Esempio n. 22
0
  @Test
  public void testSubTypes() {
    final Event testEvent = Event.create("type1.type2.type3.type4").build();

    assertTrue(testEvent.isSubType("type1"));
    assertTrue(testEvent.isSubType("type1.type2"));
    assertTrue(testEvent.isSubType("type1.type2.type3"));
    assertFalse(testEvent.isSubType("type1.type3"));
    assertFalse(testEvent.isSubType("type2"));
    assertFalse(testEvent.isSubType("type4"));
    assertFalse(testEvent.isSubType("type2.type3.type4"));
    assertFalse(testEvent.isSubType("type1.type2.type3.type4"));
    assertFalse(testEvent.isSubType("type2.type3"));

    assertTrue(testEvent.isType("type1.type2.type3.type4"));
    assertFalse(testEvent.isType("type1.type2.type3"));
  }
Esempio n. 23
0
 @Override
 public int compareTo(Event o) {
   return this.time.compareTo(o.getTime());
 }
Esempio n. 24
0
  public static void compareRecords(Event event, Event readRecord) {

    assertNotSame(event.getDateCreated(), readRecord.getDateCreated());
    assertEquals(event.getDescription(), readRecord.getDescription());
    assertEquals(event.getCategory(), readRecord.getCategory());
  }
Esempio n. 25
0
  public static void modifyRecord(Event event) {

    event.setDateCreated(new Date());
    event.setDescription(randomString("description", 2000));
    event.setCategory(randomString("category", 50));
  }