.cleanUpMode(CleanupMode.Full).build();
MasterSpec machineSpec = MasterSpec.builder()
.iso(IsoSpec.builder().sourcePath("some.iso").installationScript("").build()).vm(vmSpec)
.network(NetworkSpec.builder().build()).build();
IMachine createdMachine = createMock(IMachine.class);
ISession session = createMock(ISession.class);
expect(manager.getVBox()).andReturn(vBox).anyTimes();
String flags = "";
List<String> groups = Lists.newArrayList();
String group = "";
expect(vBox.composeMachineFilename(vmName, group, flags, "/tmp/workingDir")).andReturn("settingsFile");
StringBuilder errorMessageBuilder = new StringBuilder();
errorMessageBuilder.append("VirtualBox error: Could not find a registered machine with UUID {");
errorMessageBuilder.append("'jclouds-image-virtualbox-iso-to-machine-test'} (0x80BB0001)");
String errorMessage = errorMessageBuilder.toString();
VBoxException vBoxException = new VBoxException(createNiceMock(Throwable.class), errorMessage);
expect(vBox.findMachine(vmName)).andThrow(vBoxException);
expect(vBox.createMachine(anyString(), eq(vmName), groups, anyString(), anyString())).andReturn(createdMachine)
.anyTimes();
vBox.registerMachine(createdMachine);
expect(vBox.findMachine(vmName)).andReturn(createdMachine).anyTimes();
expect(manager.getSessionObject()).andReturn(session);
expect(session.getMachine()).andReturn(createdMachine);
createdMachine.lockMachine(session, LockType.Write);
createdMachine.setMemorySize(1024l);
createdMachine.saveSettings();
session.unlockMachine();
// TODO: this mock test is not finished.
replay(manager, createdMachine, vBox, session);
new CreateAndRegisterMachineFromIsoIfNotAlreadyExists(Suppliers.ofInstance(manager), machineUtils,