AutonomiccsSystemVmDeploymentService implements InitializingBean { protected long getNextSystemVmId() { Long id = autonomiccsSystemVmDao.getNextInSequence(Long.class, "id"); if(id == null){ throw new CloudRuntimeException("It was not possible to find an id to create a system VM."); } return id; }  HostVO searchForRandomHostInCloudToDeployAutonomiccsSystemVm(); HostVO searchForRandomHostInPodToDeployAutonomiccsSystemVm(HostPodVO pod); HostVO searchForAnotherRandomHostToStartSystemVm(VMInstanceVO vmInstance); AutonomiccsSystemVm deploySystemVmWithJava(Long hostId, SystemVmType systemVmType); @Override void afterPropertiesSet();  }
@Test public void getNextSystemVmIdTest() { Mockito.doReturn(0l).when(autonomiccsSystemVmDao).getNextInSequence(Mockito.eq(Long.class), Mockito.eq("id")); spy.getNextSystemVmId(); Mockito.verify(autonomiccsSystemVmDao).getNextInSequence(Mockito.eq(Long.class), Mockito.eq("id")); }
@Test(expected = CloudRuntimeException.class) public void getNextSystemVmIdTestLongNull() { Mockito.doReturn(null).when(autonomiccsSystemVmDao).getNextInSequence(Mockito.eq(Long.class), Mockito.eq("id")); spy.getNextSystemVmId(); Mockito.verify(autonomiccsSystemVmDao).getNextInSequence(Mockito.eq(Long.class), Mockito.eq("id")); }