@Test public void testClearAlarmsOnNodeAndSubtreeForEmptyAlarmList() { PersistenceManagerUtil persistenceManagerUtil = mock(PersistenceManagerUtil.class); EntityDataStoreManager entityDataStoreManager = mock(EntityDataStoreManager.class); AlarmServiceImpl alarmService = new AlarmServiceImpl(persistenceManagerUtil, m_alarmQueue); Map<String, String> matchValue = new HashMap<String, String>(); List<Alarm> alarms = new ArrayList<Alarm>(); when(persistenceManagerUtil.getEntityDataStoreManager()).thenReturn(entityDataStoreManager); when(entityDataStoreManager.findLike(Alarm.class, matchValue)).thenReturn(alarms); alarmService.clearAlarmsOnNodeAndSubtree(MODEL_NODE_ID, MOUNT_KEY); verify(m_notificationService, times(0)).sendNotification(eq(AlarmConstants.ALARM_STREAM_NAME), any(DefaultAlarmStateChangeNotification.class)); }
@Override public void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(identifier, mountKey); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); }
AlarmServiceImpl implements AlarmService { @Override public void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(identifier, mountKey); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); } }
AlarmServiceImpl implements AlarmService { @Override public void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(identifier, mountKey); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); } AlarmServiceImpl(PersistenceManagerUtil persistenceManagerUtil, AlarmQueue alarmQueue); }
AlarmServiceImpl implements AlarmService { @Override public void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(identifier, mountKey); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); } AlarmServiceImpl(PersistenceManagerUtil persistenceManagerUtil, AlarmQueue alarmQueue); void init(); void close(); @Override void raiseAlarm(AlarmInfo alarm); @Override void raiseAlarms(List<AlarmInfo> alarmInfoList); @Override void clearAlarm(AlarmInfo alarm); @Override void clearAlarms(List<AlarmInfo> alarmInfoList); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarms(PagingInput pagingInput); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarms(PagingInput pagingInput, String deviceId); @Override void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey); @Override void clearAlarmsOnDevice(String deviceId); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarmsUnderResource(String resourceDbIdLike); @Override void updateAlarmsForResync(List<AlarmInfo> newRaiseAlarms, List<AlarmInfo> updateAlarms, List<AlarmInfo> clearAlarms); @Override void updateAlarmNotificationQNameToAdapterTypeVersion(QName alarmNotificationQName, String typeVersion); @Override void removeAlarmNotificationQNameToAdapterTypeVersion(QName alarmNotificationQName, String typeVersion); @Override Set<String> retrieveAdapterTypeVersionsFromAlarmNotificationQName(QName alarmNotificationQName); }
AlarmServiceImpl implements AlarmService { @Override public void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(identifier, mountKey); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); } AlarmServiceImpl(PersistenceManagerUtil persistenceManagerUtil, AlarmQueue alarmQueue); void init(); void close(); @Override void raiseAlarm(AlarmInfo alarm); @Override void raiseAlarms(List<AlarmInfo> alarmInfoList); @Override void clearAlarm(AlarmInfo alarm); @Override void clearAlarms(List<AlarmInfo> alarmInfoList); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarms(PagingInput pagingInput); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarms(PagingInput pagingInput, String deviceId); @Override void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey); @Override void clearAlarmsOnDevice(String deviceId); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarmsUnderResource(String resourceDbIdLike); @Override void updateAlarmsForResync(List<AlarmInfo> newRaiseAlarms, List<AlarmInfo> updateAlarms, List<AlarmInfo> clearAlarms); @Override void updateAlarmNotificationQNameToAdapterTypeVersion(QName alarmNotificationQName, String typeVersion); @Override void removeAlarmNotificationQNameToAdapterTypeVersion(QName alarmNotificationQName, String typeVersion); @Override Set<String> retrieveAdapterTypeVersionsFromAlarmNotificationQName(QName alarmNotificationQName);  }