Пример #1
0
  @Test
  public void testCounters() throws Exception {
    AlarmPoint underTest = createAlarm("testCounters");
    AlarmHistory hist = underTest.history();
    Map<String, Integer> counters = hist.counters().get();

    underTest.trigger(AlarmPoint.TRIGGER_ACTIVATE);
    verifyCounters(counters, 1, 0);

    underTest.trigger(AlarmPoint.TRIGGER_DEACTIVATE);
    verifyCounters(counters, 1, 1);

    underTest.trigger(AlarmPoint.TRIGGER_ACTIVATE);
    verifyCounters(counters, 2, 1);

    underTest.trigger(AlarmPoint.TRIGGER_DEACTIVATE);
    verifyCounters(counters, 2, 2);

    underTest.trigger(AlarmPoint.TRIGGER_DEACTIVATE);
    verifyCounters(counters, 2, 2);

    underTest.trigger(AlarmPoint.TRIGGER_ACTIVATE);
    verifyCounters(counters, 3, 2);

    int activateCounters = hist.activateCounter();
    assertEquals(3, activateCounters);

    hist.resetActivateCounter();
    verifyCounters(counters, 0, 2);

    hist.resetAllCounters();
    verifyCounters(counters, 0, 0);
  }
Пример #2
0
 @Test
 public void testEmpty() throws Exception {
   AlarmPoint underTest = createAlarm("testEmpty");
   AlarmHistory hist = underTest.history();
   AlarmEvent event1 = hist.firstEvent();
   AlarmEvent event2 = hist.lastEvent();
   assertNull(event1);
   assertNull(event2);
   assertEquals("Activate Counter", 0, hist.activateCounter());
 }