AutonomiccsSystemVmJdbcDao extends JdbcDaoSupport { public Long getStartHostServiceVmIdFromPod(Long podId, SystemVmType systemVmType) { try { return getJdbcTemplate().queryForObject(sqlGetStartHostServiceVmIdFromPod, Long.class, podId, systemVmType.getNamePrefix() + "%"); } catch (EmptyResultDataAccessException e) { logger.debug(e); return null; } }  Long getStartHostServiceVmIdFromPod(Long podId, SystemVmType systemVmType);  }
@Test public void getStartHostServiceVmIdFromPodTest() { Mockito.doReturn(0l).when(jdbcTemplate).queryForObject(Mockito.anyString(), Mockito.eq(Long.class), Mockito.anyLong(), Mockito.anyString()); long result = spy.getStartHostServiceVmIdFromPod(0l, SystemVmType.ClusterManagerAgent); Mockito.verify(jdbcTemplate).queryForObject(Mockito.eq(sqlGetStartHostServiceVmIdFromPod), Mockito.eq(Long.class), Mockito.anyLong(), Mockito.anyString()); Assert.assertEquals(0l, result); }
@Test public void getStartHostServiceVmIdFromPodTestWithException() throws Exception { Mockito.doThrow(EmptyResultDataAccessException.class).when(jdbcTemplate).queryForObject(Mockito.anyString(), Mockito.eq(Long.class), Mockito.anyLong(), Mockito.anyString()); Assert.assertEquals(null, spy.getStartHostServiceVmIdFromPod(0l, SystemVmType.ClusterManagerAgent)); Mockito.verify(jdbcTemplate).queryForObject(Mockito.eq(sqlGetStartHostServiceVmIdFromPod), Mockito.eq(Long.class), Mockito.anyLong(), Mockito.anyString()); }