AutonomiccsSystemVmDeploymentService implements InitializingBean { protected VMTemplateVO getSystemVmTemplate(HostVO host) { VMTemplateVO systemVmTemplate = autonomiccsSystemVmTemplateService.findAutonomiccsSystemVmTemplate(host.getHypervisorType()); if (systemVmTemplate == null) { throw new CloudRuntimeException(String.format("Could not find a System VM template for the host hypervisors [%s]", host.getHypervisorType())); } return systemVmTemplate; }  HostVO searchForRandomHostInCloudToDeployAutonomiccsSystemVm(); HostVO searchForRandomHostInPodToDeployAutonomiccsSystemVm(HostPodVO pod); HostVO searchForAnotherRandomHostToStartSystemVm(VMInstanceVO vmInstance); AutonomiccsSystemVm deploySystemVmWithJava(Long hostId, SystemVmType systemVmType); @Override void afterPropertiesSet();  }
@Test public void getSystemVmTemplateTest() { VMTemplateVO systemVmTemplate = Mockito.mock(VMTemplateVO.class); HostVO host = Mockito.mock(HostVO.class); Mockito.doReturn(systemVmTemplate).when(autonomiccsSystemVmTemplateService).findAutonomiccsSystemVmTemplate(Mockito.any(HypervisorType.class)); VMTemplateVO result = spy.getSystemVmTemplate(host); Mockito.verify(autonomiccsSystemVmTemplateService).findAutonomiccsSystemVmTemplate(Mockito.any(HypervisorType.class)); Assert.assertEquals(systemVmTemplate, result); }
@Test(expected = CloudRuntimeException.class) public void getSystemVmTemplateTestNullVMTemplateVO() { HostVO host = Mockito.mock(HostVO.class); Mockito.doReturn(null).when(autonomiccsSystemVmTemplateService).findAutonomiccsSystemVmTemplate(Mockito.any(HypervisorType.class)); spy.getSystemVmTemplate(host); Mockito.verify(autonomiccsSystemVmTemplateService).findAutonomiccsSystemVmTemplate(Mockito.any(HypervisorType.class)); }