MetricService { public boolean update(Metric metric) throws Exception { LOG.info("Metric update {}", metric); try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) { MetricMapper mapper = sqlSession.getMapper(MetricMapper.class); mapper.update(metric); sqlSession.commit(); } catch (Exception e) { LOG.error(e.getMessage(), e); throw new Exception(e); } return true; } MetricService(); List<Metric> selectAll(); boolean deleteById(String id); boolean insert(Metric metric); Metric selectById(String id); boolean update(Metric metric); List<Metric> selectByPrimaryKeySelective(Metric metric);  }
@Test public void testUpdate() throws Exception { Metric metric = new Metric(); metric.setId("test_application_1234"); metric.setKey("test_score"); metric.setValue((float) 0.666667); metric.setWorkerIndex("test_worker-2"); metric.setTimestamp(new BigInteger("1569139525098")); metric.setStep(0); metric.setIsNan(false); boolean result = metricService.insert(metric); assertTrue(result); metric.setId("test_application_1234"); metric.setKey("test_scoreNew"); metric.setValue((float) 0.766667); metric.setWorkerIndex("test_worker-New"); metric.setTimestamp(new BigInteger("2569139525098")); metric.setStep(1); metric.setIsNan(true); boolean editResult = metricService.update(metric); assertTrue(editResult); Metric metricDb2 = metricService.selectByPrimaryKeySelective(metric).get(0); compareMetrics(metric, metricDb2); }