@Test public void scheduleFails() { HousekeepingMetadata metadata = createHousekeepingMetadataTable(); when(housekeepingMetadataRepository.save(metadata)).thenThrow(new RuntimeException()); assertThatExceptionOfType(BeekeeperException.class) .isThrownBy(() -> expiredHousekeepingMetadataSchedulerService.scheduleForHousekeeping(metadata)) .withMessage(format("Unable to schedule %s", metadata)); verify(housekeepingMetadataRepository).save(metadata); }
@Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } }
ExpiredHousekeepingMetadataSchedulerService implements SchedulerService { @Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } } }
ExpiredHousekeepingMetadataSchedulerService implements SchedulerService { @Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } } @Autowired  ExpiredHousekeepingMetadataSchedulerService(HousekeepingMetadataRepository housekeepingMetadataRepository); }
ExpiredHousekeepingMetadataSchedulerService implements SchedulerService { @Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } } @Autowired  ExpiredHousekeepingMetadataSchedulerService(HousekeepingMetadataRepository housekeepingMetadataRepository); @Override LifecycleEventType getLifecycleEventType(); @Override @TimedTaggable("metadata-scheduled") void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity); }
ExpiredHousekeepingMetadataSchedulerService implements SchedulerService { @Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } } @Autowired  ExpiredHousekeepingMetadataSchedulerService(HousekeepingMetadataRepository housekeepingMetadataRepository); @Override LifecycleEventType getLifecycleEventType(); @Override @TimedTaggable("metadata-scheduled") void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity);  }