AlarmQueue { public void clearQueue() { List<AlarmChange> changes = Collections.emptyList(); LOGGER.trace(null, "clearQueue(): trying to acquire lock"); synchronized (this) { if (!m_queue.isEmpty()) { changes = m_queue; m_queue = new ArrayList<>(1000); m_queueSize = 0; } } try { if (!changes.isEmpty()) { cleanupQueue(changes); } if (!changes.isEmpty()) { LOGGER.debug(null, "clearQueue(): flushing a total of {} events", changes.size()); for (List<AlarmChange> batchList : Lists.partition(changes, DB_BATCH_SIZE)) { long startTime = System.currentTimeMillis(); LOGGER.debug(null, "clearQueue(): flushing {} events", batchList.size()); m_alarmService.processChanges(batchList); long delta = System.currentTimeMillis() - startTime; LOGGER.debug(null, "clearQueue(): flushing {} events finished in {} ms", batchList.size(), delta); } } } catch (Exception e) { LOGGER.error(null, "clearQueue() exception", e); } } AlarmQueue(InternalAlarmService service); synchronized void addAlarmChanges(List<AlarmChange> changes); void clearQueue(); long getDroppedAlarms(); long getAlarmQueueSize();  }
@Test public void testNoAlarmChanges() { m_alarmQueue.clearQueue(); verify(m_alarmService, never()).processChanges(anyListOf(AlarmChange.class)); }