### Question:
TppStopListScheduleTask { @Scheduled(cron = "${xs2a.cms.stoplist.cron.expression}") @Transactional public void unblockTppIfBlockingExpired() { log.info("Tpp Stop List schedule task is run!"); List<TppStopListEntity> blockedWithExpirationTpps = tppStopListRepository.findAllByStatusAndBlockingExpirationTimestampLessThanEqual(TppStatus.BLOCKED, OffsetDateTime.now()); List<TppStopListEntity> unblockedTpps = unblockTpps(blockedWithExpirationTpps); if (!unblockedTpps.isEmpty()) { tppStopListRepository.saveAll(unblockedTpps); } }  @Scheduled(cron = "${xs2a.cms.stoplist.cron.expression}") @Transactional void unblockTppIfBlockingExpired();  }### Answer:
@Test void unblockTppIfBlockingExpired() { List<TppStopListEntity> tppStopList = new ArrayList<>(); tppStopList.add(createTppStopEntity()); tppStopList.add(createTppStopEntity()); when(tppStopListRepository.findAllByStatusAndBlockingExpirationTimestampLessThanEqual(eq(TppStatus.BLOCKED), any(OffsetDateTime.class))) .thenReturn(tppStopList); when(tppStopListRepository.saveAll(unblockedTppsCaptor.capture())).thenReturn(Collections.emptyList()); scheduleTask.unblockTppIfBlockingExpired(); verify(tppStopListRepository, times(1)).findAllByStatusAndBlockingExpirationTimestampLessThanEqual(eq(TppStatus.BLOCKED), any(OffsetDateTime.class)); verify(tppStopListRepository, times(1)).saveAll(anyList()); assertEquals(2, unblockedTppsCaptor.getValue().size()); unblockedTppsCaptor.getValue().forEach(tpp -> { assertEquals(TppStatus.ENABLED, tpp.getStatus()); assertNull(tpp.getBlockingExpirationTimestamp()); }); }
@Test void unblockTppIfBlockingExpired_emptyList() { List<TppStopListEntity> tppStopList = new ArrayList<>(); tppStopList.add(createTppStopEntity()); tppStopList.add(createTppStopEntity()); when(tppStopListRepository.findAllByStatusAndBlockingExpirationTimestampLessThanEqual(eq(TppStatus.BLOCKED), any(OffsetDateTime.class))) .thenReturn(Collections.emptyList()); scheduleTask.unblockTppIfBlockingExpired(); verify(tppStopListRepository, times(1)).findAllByStatusAndBlockingExpirationTimestampLessThanEqual(eq(TppStatus.BLOCKED), any(OffsetDateTime.class)); verify(tppStopListRepository, never()).saveAll(anyList()); }