ResourceChecker { public HostPodVO checkIfPodExists(final Long hostPodId) { logger.debug("Checking if pod " + hostPodId + " exists"); final HostPodVO pod = hostPodDao.findById(hostPodId); if (pod == null) { throw new InvalidParameterValueException("Can't find pod by id " + hostPodId); } return pod; } private  ResourceChecker(final Builder builder); static Builder builder(); DataCenterVO checkIfDataCenterExists(final Long dataCenterId); void checkIfDataCenterIsUsable(final DataCenter dataCenter, final Account account); HostPodVO checkIfPodExists(final Long hostPodId); void checkIfPodIsUsable(final DataCenter dataCenter, final HostPodVO hostPod);  }
@Test(expected = InvalidParameterValueException.class) public void test_checkIfPodExists_whenPodDoesNotExist() throws Exception { when(hostPodDao.findById(1L)).thenReturn(null); final ResourceChecker resourceChecker = buildResourceChecker(); resourceChecker.checkIfPodExists(1L); }
@Test public void test_checkIfPodExists_whenPodDoesExist() throws Exception { final HostPodVO hostPod = new HostPodVO(); when(hostPodDao.findById(1L)).thenReturn(hostPod); final ResourceChecker resourceChecker = buildResourceChecker(); assertThat(resourceChecker.checkIfPodExists(1L), is(hostPod)); }