@Test(expected = GriffinException.NotFoundException.class) public void testFailedToFindJobInstance() throws IOException { Long id = 1L; given(jobInstanceRepo.findByInstanceId(id)) .willReturn(null); service.findMetric(id); }
@Override public MetricValue findMetric(Long id) { JobInstanceBean jobInstanceBean = jobInstanceRepo.findByInstanceId(id); if (jobInstanceBean == null) { LOGGER.warn("There are no job instances with id {} ", id); throw new GriffinException .NotFoundException(JOB_INSTANCE_NOT_FOUND); } String appId = jobInstanceBean.getAppId(); try { return metricStore.getMetric(appId); } catch (IOException e) { LOGGER.warn("Failed to get metric for applicationId {} ", appId); throw new GriffinException.ServiceException("Failed to find metric", e); } }
MetricServiceImpl implements MetricService { @Override public MetricValue findMetric(Long id) { JobInstanceBean jobInstanceBean = jobInstanceRepo.findByInstanceId(id); if (jobInstanceBean == null) { LOGGER.warn("There are no job instances with id {} ", id); throw new GriffinException .NotFoundException(JOB_INSTANCE_NOT_FOUND); } String appId = jobInstanceBean.getAppId(); try { return metricStore.getMetric(appId); } catch (IOException e) { LOGGER.warn("Failed to get metric for applicationId {} ", appId); throw new GriffinException.ServiceException("Failed to find metric", e); } } }
MetricServiceImpl implements MetricService { @Override public MetricValue findMetric(Long id) { JobInstanceBean jobInstanceBean = jobInstanceRepo.findByInstanceId(id); if (jobInstanceBean == null) { LOGGER.warn("There are no job instances with id {} ", id); throw new GriffinException .NotFoundException(JOB_INSTANCE_NOT_FOUND); } String appId = jobInstanceBean.getAppId(); try { return metricStore.getMetric(appId); } catch (IOException e) { LOGGER.warn("Failed to get metric for applicationId {} ", appId); throw new GriffinException.ServiceException("Failed to find metric", e); } }  }
MetricServiceImpl implements MetricService { @Override public MetricValue findMetric(Long id) { JobInstanceBean jobInstanceBean = jobInstanceRepo.findByInstanceId(id); if (jobInstanceBean == null) { LOGGER.warn("There are no job instances with id {} ", id); throw new GriffinException .NotFoundException(JOB_INSTANCE_NOT_FOUND); } String appId = jobInstanceBean.getAppId(); try { return metricStore.getMetric(appId); } catch (IOException e) { LOGGER.warn("Failed to get metric for applicationId {} ", appId); throw new GriffinException.ServiceException("Failed to find metric", 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 MetricValue findMetric(Long id) { JobInstanceBean jobInstanceBean = jobInstanceRepo.findByInstanceId(id); if (jobInstanceBean == null) { LOGGER.warn("There are no job instances with id {} ", id); throw new GriffinException .NotFoundException(JOB_INSTANCE_NOT_FOUND); } String appId = jobInstanceBean.getAppId(); try { return metricStore.getMetric(appId); } catch (IOException e) { LOGGER.warn("Failed to get metric for applicationId {} ", appId); throw new GriffinException.ServiceException("Failed to find metric", 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);  }