AdministrationAgent implements InitializingBean { protected void checkIfHostIsUpAndEnabled(long hostId) { if (!hostService.isHostUpAndEnabled(hostId)) { throw new CloudRuntimeException(String.format("Host [id=%d] is not Up and/or Enabled", hostId)); } }  void receiveClusterToBeManaged(Long clusterId); Long searchClusterToBeManaged(); List<ClusterResourcesUp> createAllClustersResourcesUp(); @Override void afterPropertiesSet();  }
@Test(expected = CloudRuntimeException.class) public void checkIfHostIsUpAndEnabledTestExpectCloudRuntimeException() { Mockito.doReturn(false).when(hostService).isHostUpAndEnabled(Mockito.anyLong()); administrationAgent.checkIfHostIsUpAndEnabled(Mockito.anyLong()); Mockito.verify(hostService).isHostUpAndEnabled(Mockito.anyLong()); }
@Test public void checkIfHostIsUpAndEnabledTestDoesNotExpectCloudRuntimeException() { Mockito.doReturn(true).when(hostService).isHostUpAndEnabled(Mockito.anyLong()); administrationAgent.checkIfHostIsUpAndEnabled(Mockito.anyLong()); Mockito.verify(hostService).isHostUpAndEnabled(Mockito.anyLong()); }