AutonomiccsSystemVmDeploymentService implements InitializingBean { protected void loadAutonomiccsSystemVmServiceOffering() { try{ autonomiccsSystemVmServiceOffering = autonomiccsServiceOfferingService.searchAutonomiccsServiceOffering(); } catch (CloudRuntimeException ex) { logger.debug("Autonomiccs system VMs service offering not in database; we will create one.", ex); autonomiccsServiceOfferingService.createAutonomiccsServiceOffering(); autonomiccsSystemVmServiceOffering = autonomiccsServiceOfferingService.searchAutonomiccsServiceOffering(); } }  HostVO searchForRandomHostInCloudToDeployAutonomiccsSystemVm(); HostVO searchForRandomHostInPodToDeployAutonomiccsSystemVm(HostPodVO pod); HostVO searchForAnotherRandomHostToStartSystemVm(VMInstanceVO vmInstance); AutonomiccsSystemVm deploySystemVmWithJava(Long hostId, SystemVmType systemVmType); @Override void afterPropertiesSet();  }
@Test public void loadAutonomiccsSystemVmServiceOfferingTest() { Mockito.doReturn(null).when(autonomiccsServiceOfferingService).searchAutonomiccsServiceOffering(); spy.loadAutonomiccsSystemVmServiceOffering(); Mockito.verify(autonomiccsServiceOfferingService).searchAutonomiccsServiceOffering(); }
@Test public void loadAutonomiccsSystemVmServiceOfferingTestCatchCloudRuntimeException() { Mockito.doThrow(new CloudRuntimeException("exception")).doReturn(null).when(autonomiccsServiceOfferingService).searchAutonomiccsServiceOffering(); spy.loadAutonomiccsSystemVmServiceOffering(); Mockito.verify(autonomiccsServiceOfferingService, Mockito.times(2)).searchAutonomiccsServiceOffering(); Mockito.verify(autonomiccsServiceOfferingService).createAutonomiccsServiceOffering(); }