@Test
public void testClearAlarmsOnDevice() {

    EntityDataStoreManager manager = m_persistenceManager.getEntityDataStoreManager();
    // Raise an alarms with resource type as string as well as modelnode
    Timestamp timestamp = new Timestamp(System.currentTimeMillis());
    createAlarms(timestamp, 3);
    AlarmInfo alarm1 = buildAlarmInfoWithResourceTypeString();
    AlarmInfo alarm2 = buildAlarmInfoWithResourceTypeString_Device2();
    m_alarmService.raiseAlarm(alarm1);
    m_alarmService.raiseAlarm(alarm2);
    manager.beginTransaction();
    m_alarmQueue.clearQueue();
    manager.commitTransaction();
    // Verify the count of active alarms
    List<Alarm> alarms = getAlarmsFor(0, 10);
    assertEquals(5, alarms.size());
    // clear alarms with different ways for device1 and device2
    m_alarmService.clearAlarm(alarm1);
    m_alarmService.clearAlarm(alarm2);
    m_alarmService.clearAlarmsOnNodeAndSubtree(MODEL_NODE_ID, MOUNT_KEY);
    m_alarmService.clearAlarmsOnNodeAndSubtree(MODEL_NODE_ID2, MOUNT_KEY);
    m_alarmService.clearAlarmsOnDevice(DEVICE_ID);
    m_alarmService.clearAlarmsOnNodeAndSubtree(MODEL_NODE_ID2, MOUNT_KEY);
    m_alarmService.clearAlarmsOnDevice(DEVICE_ID2);
    m_alarmService.clearAlarmsOnDevice(DEVICE_ID);
    manager.beginTransaction();
    m_alarmQueue.clearQueue();
    manager.commitTransaction();
    // All the alarms cleared which was belongs to device1 and device2
    alarms = getAlarmsFor(0, 10);
    assertEquals(1, alarms.size());
}