AutonomiccsSystemVmsGuru implements VirtualMachineGuru, InitializingBean { protected StringBuilder configureBasicVmProfile(VirtualMachineProfile profile, DeployDestination dest) { StringBuilder buf = profile.getBootArgsBuilder(); buf.append(" template=domP"); buf.append(" host=").append(ApiServiceConfiguration.ManagementHostIPAdr.value()); buf.append(" name=").append(profile.getVirtualMachine().getHostName()); buf.append(" zone=").append(dest.getDataCenter().getId()); buf.append(" pod=").append(dest.getPod().getId()); buf.append(" guid=autonomiccsSystemVm.").append(profile.getId()); buf.append(" autonomiccsSystemVm_vm=").append(profile.getId()); return buf; }  @Override void afterPropertiesSet(); @Override boolean finalizeCommandsOnStart(Commands arg0, VirtualMachineProfile arg1); @Override boolean finalizeDeployment(Commands cmds, VirtualMachineProfile profile, DeployDestination dest, ReservationContext context); @Override void finalizeExpunge(VirtualMachine vm); @Override boolean finalizeStart(VirtualMachineProfile arg0, long arg1, Commands arg2, ReservationContext arg3); @Override void finalizeStop(VirtualMachineProfile arg0, Answer arg1); @Override boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context); @Override void prepareStop(VirtualMachineProfile arg0);  }
@Test public void configureBasicVmProfileTest() { StringBuilder buf = new StringBuilder(); VirtualMachine vm = Mockito.mock(VirtualMachine.class); Mockito.when(vm.getHostName()).thenReturn("vmHostName"); DataCenter dc = Mockito.mock(DataCenter.class); Mockito.when(dc.getId()).thenReturn(0l); Pod pod = Mockito.mock(Pod.class); Mockito.when(pod.getId()).thenReturn(0l); DeployDestination dest = Mockito.mock(DeployDestination.class); Mockito.when(dest.getDataCenter()).thenReturn(dc); Mockito.when(dest.getPod()).thenReturn(pod); VirtualMachineProfile profile = Mockito.mock(VirtualMachineProfile.class); Mockito.when(profile.getBootArgsBuilder()).thenReturn(buf); Mockito.when(profile.getVirtualMachine()).thenReturn(vm); Mockito.when(profile.getId()).thenReturn(123l); StringBuilder result = spy.configureBasicVmProfile(profile, dest); Assert.assertEquals(" template=domP host=localhost name=vmHostName zone=0 pod=0 guid=autonomiccsSystemVm.123 autonomiccsSystemVm_vm=123", result.toString()); InOrder inOrder = Mockito.inOrder(profile, vm, dest, dc, pod); inOrder.verify(profile).getBootArgsBuilder(); inOrder.verify(profile).getVirtualMachine(); inOrder.verify(vm).getHostName(); inOrder.verify(dest).getDataCenter(); inOrder.verify(dc).getId(); inOrder.verify(dest).getPod(); inOrder.verify(pod).getId(); inOrder.verify(profile, Mockito.times(2)).getId(); }