コード例 #1
0
 @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));
 }
コード例 #2
0
  @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());
  }