@Override
    public Map<Alarm.SeverityLevel, Long> getAlarmCounts(DeviceId deviceId) {
        return getAlarms(deviceId).stream().collect(
                Collectors.groupingBy(Alarm::severity, Collectors.counting()));
    }
@Test
    public void testRemoveWhenDeviceRemoved() {
        providerService.updateAlarmList(DEVICE_ID, ImmutableSet.of(ALARM_B, ALARM_A));
        verifyGettingSetsOfAlarms(manager, 2, 2);
        validateEvents(AlarmEvent.Type.CREATED, AlarmEvent.Type.CREATED);
        Map<Alarm.SeverityLevel, Long> critical2 = new CountsMapBuilder().with(CRITICAL, 2L).create();
        assertEquals("A critical should be present", critical2, manager.getAlarmCounts());
        assertEquals("A critical should be present", critical2, manager.getAlarmCounts(DEVICE_ID));
        deviceService.deviceListener.event(new DeviceEvent(DeviceEvent.Type.DEVICE_REMOVED, device));
        Map<Alarm.SeverityLevel, Long> zeroAlarms = new CountsMapBuilder().create();
        assertEquals("The counts should be empty for removed device", zeroAlarms,
                manager.getAlarmCounts(DEVICE_ID));

    }