@Test public void testUpdateDetectorTrainingTime() { val uuid = this.someUuid.toString(); val timestamp = DateUtil.toUtcDate("2020-07-15 20:00:00").toInstant().toEpochMilli(); serviceUnderTest.updateDetectorTrainingTime(uuid, timestamp); verify(repository, times(1)).findByUuid(someUuid.toString()); verify(repository, times(1)).save(legalParamsDetector); }
@Override public void updateDetectorTrainingTime(String uuid, long nextRun) { notNull(uuid, "uuid can't be null"); MDC.put("DetectorUuid", uuid); Detector detectorToBeUpdated = repository.findByUuid(uuid); TrainingMetaData updatedTrainingTimeMeta = DetectorDataUtil.buildUpdatedRuntimeTrainingMeta( detectorToBeUpdated, nextRun); detectorToBeUpdated.getDetectorConfig().setTrainingMetaData(updatedTrainingTimeMeta); repository.save(detectorToBeUpdated); }
DetectorServiceImpl implements DetectorService { @Override public void updateDetectorTrainingTime(String uuid, long nextRun) { notNull(uuid, "uuid can't be null"); MDC.put("DetectorUuid", uuid); Detector detectorToBeUpdated = repository.findByUuid(uuid); TrainingMetaData updatedTrainingTimeMeta = DetectorDataUtil.buildUpdatedRuntimeTrainingMeta( detectorToBeUpdated, nextRun); detectorToBeUpdated.getDetectorConfig().setTrainingMetaData(updatedTrainingTimeMeta); repository.save(detectorToBeUpdated); } }
DetectorServiceImpl implements DetectorService { @Override public void updateDetectorTrainingTime(String uuid, long nextRun) { notNull(uuid, "uuid can't be null"); MDC.put("DetectorUuid", uuid); Detector detectorToBeUpdated = repository.findByUuid(uuid); TrainingMetaData updatedTrainingTimeMeta = DetectorDataUtil.buildUpdatedRuntimeTrainingMeta( detectorToBeUpdated, nextRun); detectorToBeUpdated.getDetectorConfig().setTrainingMetaData(updatedTrainingTimeMeta); repository.save(detectorToBeUpdated); }  }
DetectorServiceImpl implements DetectorService { @Override public void updateDetectorTrainingTime(String uuid, long nextRun) { notNull(uuid, "uuid can't be null"); MDC.put("DetectorUuid", uuid); Detector detectorToBeUpdated = repository.findByUuid(uuid); TrainingMetaData updatedTrainingTimeMeta = DetectorDataUtil.buildUpdatedRuntimeTrainingMeta( detectorToBeUpdated, nextRun); detectorToBeUpdated.getDetectorConfig().setTrainingMetaData(updatedTrainingTimeMeta); repository.save(detectorToBeUpdated); }  @Override UUID createDetector(Detector detector); @Override Detector findByUuid(String uuid); @Override List<Detector> findByCreatedBy(String user); @Override void toggleDetector(String uuid, Boolean enabled); @Override void trustDetector(String uuid, Boolean trusted); @Override List<Detector> getLastUpdatedDetectors(long interval); @Override List<Detector> getLastUsedDetectors(int noOfDays); @Override List<Detector> getDetectorsToBeTrained(long timestampMs); @Override void updateDetector(String uuid, Detector detector); @Override void updateDetectorLastUsed(String uuid); @Override void updateDetectorTrainingTime(String uuid, long nextRun); @Override void deleteDetector(String uuid); }
DetectorServiceImpl implements DetectorService { @Override public void updateDetectorTrainingTime(String uuid, long nextRun) { notNull(uuid, "uuid can't be null"); MDC.put("DetectorUuid", uuid); Detector detectorToBeUpdated = repository.findByUuid(uuid); TrainingMetaData updatedTrainingTimeMeta = DetectorDataUtil.buildUpdatedRuntimeTrainingMeta( detectorToBeUpdated, nextRun); detectorToBeUpdated.getDetectorConfig().setTrainingMetaData(updatedTrainingTimeMeta); repository.save(detectorToBeUpdated); }  @Override UUID createDetector(Detector detector); @Override Detector findByUuid(String uuid); @Override List<Detector> findByCreatedBy(String user); @Override void toggleDetector(String uuid, Boolean enabled); @Override void trustDetector(String uuid, Boolean trusted); @Override List<Detector> getLastUpdatedDetectors(long interval); @Override List<Detector> getLastUsedDetectors(int noOfDays); @Override List<Detector> getDetectorsToBeTrained(long timestampMs); @Override void updateDetector(String uuid, Detector detector); @Override void updateDetectorLastUsed(String uuid); @Override void updateDetectorTrainingTime(String uuid, long nextRun); @Override void deleteDetector(String uuid);  }