DetectorServiceImpl implements DetectorService { @Override public UUID createDetector(Detector detector) { notNull(detector, "detectorDto can't be null"); isNull(detector.getUuid(), "Required: detectorDto.uuid == null"); val uuid = UUID.randomUUID(); detector.setId(uuid.toString()); detector.setUuid(uuid); detector.setMeta(DetectorDataUtil.buildNewDetectorMeta(detector)); RequestValidator.validateDetector(detector); repository.save(detector); return uuid; }  @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);  }
@Test public void testCreateDetector() { legalParamsDetector.setUuid(null); val uuid = serviceUnderTest.createDetector(legalParamsDetector); assertNotNull(uuid); }
@Test(expected = IllegalArgumentException.class) public void testCreateDetector_null_detector() { serviceUnderTest.createDetector(null); }
@Test(expected = IllegalArgumentException.class) public void testCreateDetector_set_uuid() { legalParamsDetector.setUuid(UUID.randomUUID()); serviceUnderTest.createDetector(legalParamsDetector); }