ScheduledTaskExecutorService { public void processScheduledTasks() { this.processScheduledTasks(ScheduledTaskStatusType.NEW); this.processScheduledTasks(ScheduledTaskStatusType.RETRY); }  void processScheduledTasks();  }
@Test public void testRunFunctionalException() throws FunctionalException, UnknownHostException, JobExecutionException { final List<ScheduledTask> scheduledTasks = new ArrayList<>(); final ScheduledTask scheduledTask = new ScheduledTask(DEVICE_MESSAGE_DATA, DOMAIN, DOMAIN, DATA_OBJECT, SCHEDULED_TIME); scheduledTasks.add(scheduledTask); when(this.scheduledTaskRepository.findByStatusAndScheduledTimeLessThan(any(ScheduledTaskStatusType.class), any(Timestamp.class), any(Pageable.class))).thenReturn(scheduledTasks) .thenReturn(new ArrayList<ScheduledTask>()); final Device device = new Device(); device.updateRegistrationData(InetAddress.getByName("127.0.0.1"), "deviceType"); when(this.deviceRepository.findByDeviceIdentification(anyString())).thenReturn(device); when(this.scheduledTaskRepository.save(any(ScheduledTask.class))).thenReturn(scheduledTask); when(this.scheduledTaskExecutorJobConfig.scheduledTaskPageSize()).thenReturn(30); doThrow(new FunctionalException(FunctionalExceptionType.ARGUMENT_NULL, ComponentType.OSGP_CORE)) .when(this.deviceRequestMessageService) .processMessage(any(ProtocolRequestMessage.class)); this.scheduledTaskExecutorService.processScheduledTasks(); verify(this.scheduledTaskRepository).delete(scheduledTask); }