AutonomiccsSystemVmDeploymentService implements InitializingBean { public AutonomiccsSystemVm deploySystemVmWithJava(Long hostId, SystemVmType systemVmType) { AutonomiccsSystemVm vmInstance = deploySystemVm(hostId, systemVmType); String managementIp = vmInstance.getManagementIpAddress(); sshUtils.executeCommandOnHostViaSsh(managementIp, "aptitude update"); sshUtils.executeCommandOnHostViaSsh(managementIp, commandToInstallOpenJDK7); return vmInstance; }  HostVO searchForRandomHostInCloudToDeployAutonomiccsSystemVm(); HostVO searchForRandomHostInPodToDeployAutonomiccsSystemVm(HostPodVO pod); HostVO searchForAnotherRandomHostToStartSystemVm(VMInstanceVO vmInstance); AutonomiccsSystemVm deploySystemVmWithJava(Long hostId, SystemVmType systemVmType); @Override void afterPropertiesSet();  }
@Test public void deploySystemVmWithJavaTest() { AutonomiccsSystemVm vmInstance = Mockito.mock(AutonomiccsSystemVm.class); Mockito.doReturn(vmInstance).when(spy).deploySystemVm(Mockito.anyLong(), Mockito.any(SystemVmType.class)); Mockito.doReturn("managementIp").when(vmInstance).getManagementIpAddress(); Mockito.doNothing().when(sshUtils).executeCommandOnHostViaSsh(Mockito.eq("managementIp"), Mockito.eq("aptitude update")); Mockito.doNothing().when(sshUtils).executeCommandOnHostViaSsh(Mockito.eq("managementIp"), Mockito.eq(commandToInstallOpenJDK7)); AutonomiccsSystemVm result = spy.deploySystemVmWithJava(0l, SystemVmType.ClusterManagerStartHostService); Mockito.verify(spy).deploySystemVm(Mockito.anyLong(), Mockito.any(SystemVmType.class)); Mockito.verify(vmInstance).getManagementIpAddress(); Mockito.verify(sshUtils).executeCommandOnHostViaSsh(Mockito.eq("managementIp"), Mockito.eq("aptitude update")); Mockito.verify(sshUtils).executeCommandOnHostViaSsh(Mockito.eq("managementIp"), Mockito.eq(commandToInstallOpenJDK7)); Assert.assertEquals(vmInstance, result); }