HostResourcesService { public HostResources createAndConfigureHostResources(HostVO hostVo) { HostResources hResources = new HostResources(); hResources.setHostId(hostVo.getId()); hResources.setHostName(hostVo.getName()); hResources.setSpeed(hostVo.getSpeed()); hResources.setCpus(hostVo.getCpus()); hResources.setTotalMemoryInBytes(hostVo.getTotalMemory()); return hResources; }  HostResources createAndConfigureHostResources(HostVO hostVo); HostResources createHostResources(HostVO hostVO);  }
@Test public void createAndConfigureHostResourcesTest() { HostVO hostVo = Mockito.mock(HostVO.class); Mockito.when(hostVo.getId()).thenReturn(1l); Mockito.when(hostVo.getName()).thenReturn("test"); Mockito.when(hostVo.getSpeed()).thenReturn(2000l); Mockito.when(hostVo.getCpus()).thenReturn(4); Mockito.when(hostVo.getTotalMemory()).thenReturn(8000l); HostResources host = hostResourcesService.createAndConfigureHostResources(hostVo); Assert.assertEquals(1l, host.getHostId()); Assert.assertEquals("test", host.getHostName()); Assert.assertEquals(2000l, host.getSpeed()); Assert.assertEquals(4, host.getCpus().intValue()); Assert.assertEquals(8000l, host.getTotalMemoryInBytes()); }