@Test(expected = GriffinException.NotFoundException.class) public void testUpdateMeasureForFailureWithNotFound() throws Exception { Measure measure = createGriffinMeasure("view_item_hourly"); given(measureRepo.findByIdAndDeleted(measure.getId(), false)) .willReturn(null); service.updateMeasure(measure); }
@Override public Measure updateMeasure(Measure measure) { Measure m = measureRepo.findByIdAndDeleted(measure.getId(), false); if (m == null) { throw new GriffinException.NotFoundException( MEASURE_ID_DOES_NOT_EXIST); } if (!m.getType().equals(measure.getType())) { LOGGER.warn("Can't update measure to different type."); throw new GriffinException.BadRequestException( MEASURE_TYPE_DOES_NOT_MATCH); } MeasureOperator op = getOperation(measure); return op.update(measure); }
MeasureServiceImpl implements MeasureService { @Override public Measure updateMeasure(Measure measure) { Measure m = measureRepo.findByIdAndDeleted(measure.getId(), false); if (m == null) { throw new GriffinException.NotFoundException( MEASURE_ID_DOES_NOT_EXIST); } if (!m.getType().equals(measure.getType())) { LOGGER.warn("Can't update measure to different type."); throw new GriffinException.BadRequestException( MEASURE_TYPE_DOES_NOT_MATCH); } MeasureOperator op = getOperation(measure); return op.update(measure); } }
MeasureServiceImpl implements MeasureService { @Override public Measure updateMeasure(Measure measure) { Measure m = measureRepo.findByIdAndDeleted(measure.getId(), false); if (m == null) { throw new GriffinException.NotFoundException( MEASURE_ID_DOES_NOT_EXIST); } if (!m.getType().equals(measure.getType())) { LOGGER.warn("Can't update measure to different type."); throw new GriffinException.BadRequestException( MEASURE_TYPE_DOES_NOT_MATCH); } MeasureOperator op = getOperation(measure); return op.update(measure); }  }
MeasureServiceImpl implements MeasureService { @Override public Measure updateMeasure(Measure measure) { Measure m = measureRepo.findByIdAndDeleted(measure.getId(), false); if (m == null) { throw new GriffinException.NotFoundException( MEASURE_ID_DOES_NOT_EXIST); } if (!m.getType().equals(measure.getType())) { LOGGER.warn("Can't update measure to different type."); throw new GriffinException.BadRequestException( MEASURE_TYPE_DOES_NOT_MATCH); } MeasureOperator op = getOperation(measure); return op.update(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 updateMeasure(Measure measure) { Measure m = measureRepo.findByIdAndDeleted(measure.getId(), false); if (m == null) { throw new GriffinException.NotFoundException( MEASURE_ID_DOES_NOT_EXIST); } if (!m.getType().equals(measure.getType())) { LOGGER.warn("Can't update measure to different type."); throw new GriffinException.BadRequestException( MEASURE_TYPE_DOES_NOT_MATCH); } MeasureOperator op = getOperation(measure); return op.update(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();  }