@Test(expected = GriffinException.ConflictException.class) public void testCreateMeasureForFailureWithDuplicate() throws Exception { String measureName = "view_item_hourly"; GriffinMeasure measure = createGriffinMeasure(measureName); given(measureRepo.findByNameAndDeleted(measureName, false)) .willReturn(Collections.singletonList(measure)); service.createMeasure(measure); }
@Override public Measure createMeasure(Measure measure) { List<Measure> aliveMeasureList = measureRepo .findByNameAndDeleted(measure.getName(), false); if (!CollectionUtils.isEmpty(aliveMeasureList)) { LOGGER.warn("Failed to create new measure {}, it already exists.", measure.getName()); throw new GriffinException.ConflictException( MEASURE_NAME_ALREADY_EXIST); } MeasureOperator op = getOperation(measure); return op.create(measure); }
MeasureServiceImpl implements MeasureService { @Override public Measure createMeasure(Measure measure) { List<Measure> aliveMeasureList = measureRepo .findByNameAndDeleted(measure.getName(), false); if (!CollectionUtils.isEmpty(aliveMeasureList)) { LOGGER.warn("Failed to create new measure {}, it already exists.", measure.getName()); throw new GriffinException.ConflictException( MEASURE_NAME_ALREADY_EXIST); } MeasureOperator op = getOperation(measure); return op.create(measure); } }
MeasureServiceImpl implements MeasureService { @Override public Measure createMeasure(Measure measure) { List<Measure> aliveMeasureList = measureRepo .findByNameAndDeleted(measure.getName(), false); if (!CollectionUtils.isEmpty(aliveMeasureList)) { LOGGER.warn("Failed to create new measure {}, it already exists.", measure.getName()); throw new GriffinException.ConflictException( MEASURE_NAME_ALREADY_EXIST); } MeasureOperator op = getOperation(measure); return op.create(measure); }  }
MeasureServiceImpl implements MeasureService { @Override public Measure createMeasure(Measure measure) { List<Measure> aliveMeasureList = measureRepo .findByNameAndDeleted(measure.getName(), false); if (!CollectionUtils.isEmpty(aliveMeasureList)) { LOGGER.warn("Failed to create new measure {}, it already exists.", measure.getName()); throw new GriffinException.ConflictException( MEASURE_NAME_ALREADY_EXIST); } MeasureOperator op = getOperation(measure); return op.create(measure); }  @Override List<? extends Measure> getAllAliveMeasures(String type); @Override Measure getMeasureById(long id); @Override List<Measure> getAliveMeasuresByOwner(String owner); @Override Measure createMeasure(Measure measure); @Override Measure updateMeasure(Measure measure); @Override void deleteMeasureById(Long measureId); @Override void deleteMeasures(); }
MeasureServiceImpl implements MeasureService { @Override public Measure createMeasure(Measure measure) { List<Measure> aliveMeasureList = measureRepo .findByNameAndDeleted(measure.getName(), false); if (!CollectionUtils.isEmpty(aliveMeasureList)) { LOGGER.warn("Failed to create new measure {}, it already exists.", measure.getName()); throw new GriffinException.ConflictException( MEASURE_NAME_ALREADY_EXIST); } MeasureOperator op = getOperation(measure); return op.create(measure); }  @Override List<? extends Measure> getAllAliveMeasures(String type); @Override Measure getMeasureById(long id); @Override List<Measure> getAliveMeasuresByOwner(String owner); @Override Measure createMeasure(Measure measure); @Override Measure updateMeasure(Measure measure); @Override void deleteMeasureById(Long measureId); @Override void deleteMeasures();  }