@Test(expected = GriffinException.ServiceException.class) public void testGetMetricValuesFailureWithException() throws IOException { given(metricStore.getMetricValues(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt(), Matchers.anyLong())) .willThrow(new IOException()); service.getMetricValues("jobName", 0, 300, 0); }
@Override public List<MetricValue> getMetricValues(String metricName, int offset, int size, long tmst) { if (offset < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_OFFSET); } if (size < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_SIZE); } try { return metricStore.getMetricValues(metricName, offset, size, tmst); } catch (IOException e) { LOGGER.error("Failed to get metric values named {}. {}", metricName, e.getMessage()); throw new GriffinException.ServiceException( "Failed to get metric values", e); } }
MetricServiceImpl implements MetricService { @Override public List<MetricValue> getMetricValues(String metricName, int offset, int size, long tmst) { if (offset < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_OFFSET); } if (size < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_SIZE); } try { return metricStore.getMetricValues(metricName, offset, size, tmst); } catch (IOException e) { LOGGER.error("Failed to get metric values named {}. {}", metricName, e.getMessage()); throw new GriffinException.ServiceException( "Failed to get metric values", e); } } }
MetricServiceImpl implements MetricService { @Override public List<MetricValue> getMetricValues(String metricName, int offset, int size, long tmst) { if (offset < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_OFFSET); } if (size < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_SIZE); } try { return metricStore.getMetricValues(metricName, offset, size, tmst); } catch (IOException e) { LOGGER.error("Failed to get metric values named {}. {}", metricName, e.getMessage()); throw new GriffinException.ServiceException( "Failed to get metric values", e); } }  }
MetricServiceImpl implements MetricService { @Override public List<MetricValue> getMetricValues(String metricName, int offset, int size, long tmst) { if (offset < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_OFFSET); } if (size < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_SIZE); } try { return metricStore.getMetricValues(metricName, offset, size, tmst); } catch (IOException e) { LOGGER.error("Failed to get metric values named {}. {}", metricName, e.getMessage()); throw new GriffinException.ServiceException( "Failed to get metric values", e); } }  @Override Map<String, List<Metric>> getAllMetrics(); @Override List<MetricValue> getMetricValues(String metricName, int offset,
                                             int size, long tmst); @SuppressWarnings("rawtypes") @Override ResponseEntity addMetricValues(List<MetricValue> values); @SuppressWarnings("rawtypes") @Override ResponseEntity deleteMetricValues(String metricName); @Override MetricValue findMetric(Long id); }
MetricServiceImpl implements MetricService { @Override public List<MetricValue> getMetricValues(String metricName, int offset, int size, long tmst) { if (offset < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_OFFSET); } if (size < 0) { throw new GriffinException.BadRequestException (INVALID_METRIC_RECORDS_SIZE); } try { return metricStore.getMetricValues(metricName, offset, size, tmst); } catch (IOException e) { LOGGER.error("Failed to get metric values named {}. {}", metricName, e.getMessage()); throw new GriffinException.ServiceException( "Failed to get metric values", e); } }  @Override Map<String, List<Metric>> getAllMetrics(); @Override List<MetricValue> getMetricValues(String metricName, int offset,
                                             int size, long tmst); @SuppressWarnings("rawtypes") @Override ResponseEntity addMetricValues(List<MetricValue> values); @SuppressWarnings("rawtypes") @Override ResponseEntity deleteMetricValues(String metricName); @Override MetricValue findMetric(Long id);  }