@Test(enabled = false)
public void testCreateAndSetMemoryWhenNotAlreadyExists() throws Exception {
MachineUtils machineUtils = createMock(MachineUtils.class);
VirtualBoxManager manager = createMock(VirtualBoxManager.class);
IVirtualBox vBox = createMock(IVirtualBox.class);
String vmName = "jclouds-image-my-ubuntu-image";
StorageController ideController = StorageController.builder().name("IDE Controller").bus(StorageBus.IDE).build();
VmSpec vmSpec = VmSpec.builder().id(vmName).name(vmName).osTypeId("").memoryMB(1024).controller(ideController)
.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();