@Test
 public void testFirstNotLast() throws Exception {
   AlarmPoint underTest = createAlarm("testFirstNotLast");
   underTest.updateCondition(true);
   underTest.updateCondition(false);
   AlarmHistory hist = underTest.history();
   AlarmEvent event1 = hist.firstEvent();
   AlarmEvent event2 = hist.lastEvent();
   assertFalse(event1.equals(event2));
   Assert.assertEquals(AlarmPoint.STATUS_ACTIVATED, event1.newStatus().get().name(null));
   Assert.assertEquals(AlarmPoint.STATUS_NORMAL, event2.newStatus().get().name(null));
 }
  @Test
  public void testGetPosition() throws Exception {
    AlarmPoint underTest = createAlarm("testGetPosition");
    alarmSystem.addAlarmListener(this);
    AlarmHistory hist = underTest.history();
    underTest.trigger(AlarmPoint.TRIGGER_ACTIVATE);
    underTest.trigger(AlarmPoint.TRIGGER_DEACTIVATE);
    underTest.trigger(AlarmPoint.TRIGGER_ACTIVATE);
    underTest.trigger(AlarmPoint.TRIGGER_DEACTIVATE);
    underTest.trigger(AlarmPoint.TRIGGER_DEACTIVATE);
    underTest.trigger(AlarmPoint.TRIGGER_ACTIVATE);

    assertEquals(5, eventCounter);
    assertEquals(5, hist.allAlarmEvents().get().size());

    AlarmEvent event = hist.eventAt(-1);
    assertNull(event);
    event = hist.eventAt(5);
    assertNull(event);
    event = hist.eventAt(0);
    assertEquals("activation", event.systemName().get());
    event = hist.eventAt(1);
    assertEquals("deactivation", event.systemName().get());
    event = hist.eventAt(2);
    assertEquals("activation", event.systemName().get());
    event = hist.eventAt(3);
    assertEquals("deactivation", event.systemName().get());
    event = hist.eventAt(4);
    assertEquals("activation", event.systemName().get());
  }
 private AlarmEvent createEvent(
     Identity alarmId, AlarmStatus oldStatus, AlarmStatus newStatus, String eventSystemName) {
   ValueBuilder<AlarmEvent> builder = vbf.newValueBuilder(AlarmEvent.class);
   AlarmEvent prototype = builder.prototype();
   prototype.alarmIdentity().set(alarmId.identity().get());
   prototype.eventTime().set(new Date());
   prototype.newStatus().set(newStatus);
   prototype.oldStatus().set(oldStatus);
   prototype.systemName().set(eventSystemName);
   return builder.newInstance();
 }
 public void fireRule(Object[] workingMemory) {
   AlarmEvent alarm = (AlarmEvent) workingMemory[0];
   if (alarm.getSeverity() < EventConstants.SEVERITY_CRITICAL) alarm.setEventSource(null);
   System.out.println("Suppress no critical Alarms rule suppress alarm:" + alarm);
 }