@Test public void typicalNoSchedule() { when(beekeeperEventReader.read()).thenReturn(Optional.empty()); scheduler.scheduleBeekeeperEvent(); verifyNoInteractions(pathSchedulerService); verifyNoInteractions(tableSchedulerService); verify(beekeeperEventReader, times(0)).delete(any()); }
@Transactional public void scheduleBeekeeperEvent() { Optional<BeekeeperEvent> housekeepingEntitiesToBeScheduled = beekeeperEventReader.read(); if (housekeepingEntitiesToBeScheduled.isEmpty()) { return; } BeekeeperEvent beekeeperEvent = housekeepingEntitiesToBeScheduled.get(); List<HousekeepingEntity> housekeepingEntities = beekeeperEvent.getHousekeepingEntities(); for (HousekeepingEntity entity : housekeepingEntities) { try { LifecycleEventType eventType = LifecycleEventType.valueOf(entity.getLifecycleType()); SchedulerService scheduler = schedulerServiceMap.get(eventType); scheduler.scheduleForHousekeeping(entity); } catch (Exception e) { throw new BeekeeperException(format( "Unable to schedule %s deletion for entity, this message will go back on the queue", entity.getLifecycleType()), e); } } beekeeperEventReader.delete(beekeeperEvent); }
SchedulerApiary { @Transactional public void scheduleBeekeeperEvent() { Optional<BeekeeperEvent> housekeepingEntitiesToBeScheduled = beekeeperEventReader.read(); if (housekeepingEntitiesToBeScheduled.isEmpty()) { return; } BeekeeperEvent beekeeperEvent = housekeepingEntitiesToBeScheduled.get(); List<HousekeepingEntity> housekeepingEntities = beekeeperEvent.getHousekeepingEntities(); for (HousekeepingEntity entity : housekeepingEntities) { try { LifecycleEventType eventType = LifecycleEventType.valueOf(entity.getLifecycleType()); SchedulerService scheduler = schedulerServiceMap.get(eventType); scheduler.scheduleForHousekeeping(entity); } catch (Exception e) { throw new BeekeeperException(format( "Unable to schedule %s deletion for entity, this message will go back on the queue", entity.getLifecycleType()), e); } } beekeeperEventReader.delete(beekeeperEvent); } }
SchedulerApiary { @Transactional public void scheduleBeekeeperEvent() { Optional<BeekeeperEvent> housekeepingEntitiesToBeScheduled = beekeeperEventReader.read(); if (housekeepingEntitiesToBeScheduled.isEmpty()) { return; } BeekeeperEvent beekeeperEvent = housekeepingEntitiesToBeScheduled.get(); List<HousekeepingEntity> housekeepingEntities = beekeeperEvent.getHousekeepingEntities(); for (HousekeepingEntity entity : housekeepingEntities) { try { LifecycleEventType eventType = LifecycleEventType.valueOf(entity.getLifecycleType()); SchedulerService scheduler = schedulerServiceMap.get(eventType); scheduler.scheduleForHousekeeping(entity); } catch (Exception e) { throw new BeekeeperException(format( "Unable to schedule %s deletion for entity, this message will go back on the queue", entity.getLifecycleType()), e); } } beekeeperEventReader.delete(beekeeperEvent); } @Autowired  SchedulerApiary(
      BeekeeperEventReader beekeeperEventReader,
      EnumMap<LifecycleEventType, SchedulerService> schedulerServiceMap
  ); }
SchedulerApiary { @Transactional public void scheduleBeekeeperEvent() { Optional<BeekeeperEvent> housekeepingEntitiesToBeScheduled = beekeeperEventReader.read(); if (housekeepingEntitiesToBeScheduled.isEmpty()) { return; } BeekeeperEvent beekeeperEvent = housekeepingEntitiesToBeScheduled.get(); List<HousekeepingEntity> housekeepingEntities = beekeeperEvent.getHousekeepingEntities(); for (HousekeepingEntity entity : housekeepingEntities) { try { LifecycleEventType eventType = LifecycleEventType.valueOf(entity.getLifecycleType()); SchedulerService scheduler = schedulerServiceMap.get(eventType); scheduler.scheduleForHousekeeping(entity); } catch (Exception e) { throw new BeekeeperException(format( "Unable to schedule %s deletion for entity, this message will go back on the queue", entity.getLifecycleType()), e); } } beekeeperEventReader.delete(beekeeperEvent); } @Autowired  SchedulerApiary(
      BeekeeperEventReader beekeeperEventReader,
      EnumMap<LifecycleEventType, SchedulerService> schedulerServiceMap
  ); @Transactional void scheduleBeekeeperEvent(); void close(); }
SchedulerApiary { @Transactional public void scheduleBeekeeperEvent() { Optional<BeekeeperEvent> housekeepingEntitiesToBeScheduled = beekeeperEventReader.read(); if (housekeepingEntitiesToBeScheduled.isEmpty()) { return; } BeekeeperEvent beekeeperEvent = housekeepingEntitiesToBeScheduled.get(); List<HousekeepingEntity> housekeepingEntities = beekeeperEvent.getHousekeepingEntities(); for (HousekeepingEntity entity : housekeepingEntities) { try { LifecycleEventType eventType = LifecycleEventType.valueOf(entity.getLifecycleType()); SchedulerService scheduler = schedulerServiceMap.get(eventType); scheduler.scheduleForHousekeeping(entity); } catch (Exception e) { throw new BeekeeperException(format( "Unable to schedule %s deletion for entity, this message will go back on the queue", entity.getLifecycleType()), e); } } beekeeperEventReader.delete(beekeeperEvent); } @Autowired  SchedulerApiary(
      BeekeeperEventReader beekeeperEventReader,
      EnumMap<LifecycleEventType, SchedulerService> schedulerServiceMap
  ); @Transactional void scheduleBeekeeperEvent(); void close();  }