AutonomiccsSystemVmsGuru implements VirtualMachineGuru, InitializingBean { protected void configurePassword(StringBuilder buf) { if (Boolean.valueOf(configurationDao.getValue("system.vm.random.password"))) { buf.append(" vmpassword=").append(configurationDao.getValue("system.vm.password")); } }  @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 configurePasswordTest() { StringBuilder buf = new StringBuilder(); Mockito.doReturn("true").when(configurationDao).getValue(Mockito.eq("system.vm.random.password")); Mockito.doReturn("123").when(configurationDao).getValue(Mockito.eq("system.vm.password")); spy.configurePassword(buf); Assert.assertEquals(" vmpassword=123", buf.toString()); }
@Test public void configurePasswordTestNotRandomPassword() { StringBuilder buf = new StringBuilder(); Mockito.doReturn("false").when(configurationDao).getValue(Mockito.eq("system.vm.random.password")); spy.configurePassword(buf); Assert.assertEquals(StringUtils.EMPTY, buf.toString()); }