@Override
    public List<AlarmId> unassignDeletedUserAlarms(TenantId tenantId, UserId userId, String userTitle, long unassignTs) {
        List<AlarmId> totalAlarmIds = new ArrayList<>();
        PageLink pageLink = new PageLink(100, 0, null, new SortOrder("id", SortOrder.Direction.ASC));
        while (true) {
            PageData<AlarmId> pageData = alarmService.findAlarmIdsByAssigneeId(tenantId, userId, pageLink);
            List<AlarmId> alarmIds = pageData.getData();
            if (alarmIds.isEmpty()) {
                break;
            }
            processAlarmsUnassignment(tenantId, userId, userTitle, alarmIds, unassignTs);
            totalAlarmIds.addAll(alarmIds);
            pageLink = pageLink.nextPageLink();
        }
        return totalAlarmIds;
    }
@Test
    public void testUnassignDeletedUserAlarms() throws ThingsboardException {
        AlarmInfo alarm = new AlarmInfo();
        alarm.setId(new AlarmId(UUID.randomUUID()));

        when(alarmService.findAlarmIdsByAssigneeId(any(), any(), any()))
                .thenReturn(new PageData<>(List.of(alarm.getId()), 0, 1, false))
                .thenReturn(new PageData<>(Collections.EMPTY_LIST, 0, 0, false));
        when(alarmSubscriptionService.unassignAlarm(any(), any(), anyLong()))
                .thenReturn(AlarmApiCallResult.builder().successful(true).modified(true).alarm(alarm).build());

        User user = new User();
        user.setEmail("testEmail@gmail.com");
        user.setId(new UserId(UUID.randomUUID()));
        service.unassignDeletedUserAlarms(new TenantId(UUID.randomUUID()), user.getId(), user.getTitle(), System.currentTimeMillis());

        ObjectNode commentNode = JacksonUtil.newObjectNode();
        commentNode.put("subtype", "ASSIGN");
        commentNode.put("text", String.format("Alarm was unassigned because user %s - was deleted", user.getTitle()));
        AlarmComment expectedAlarmComment = AlarmComment.builder()
                .alarmId(alarm.getId())
                .type(AlarmCommentType.SYSTEM)
                .comment(commentNode)
                .build();

        verify(alarmCommentService, times(1))
                .saveAlarmComment(eq(alarm), eq(expectedAlarmComment), eq(null));
    }