@Test
public void testCreateMediumWhenDiskDoesNotExists() throws Exception {
HardDisk hardDisk = createTestHardDisk();
VirtualBoxManager manager = createNiceMock(VirtualBoxManager.class);
MachineUtils machineUtils = createMock(MachineUtils.class);
IMachine machine = createMock(IMachine.class);
IVirtualBox vBox = createMock(IVirtualBox.class);
IMedium medium = createMock(IMedium.class);
IProgress progress = createNiceMock(IProgress.class);
StringBuilder errorBuilder = new StringBuilder();
errorBuilder.append("org.virtualbox_4_2.VBoxException: VirtualBox error: ");
errorBuilder.append("Could not find file for the medium ");
errorBuilder.append("'/Users/johndoe/jclouds-virtualbox-test/testadmin.vdi' (0x80BB0001)");
String errorMessage = errorBuilder.toString();
expect(manager.getVBox()).andReturn(vBox).anyTimes();
VBoxException notFoundException = new VBoxException(createNiceMock(Throwable.class), errorMessage);
expect(vBox.openMedium(adminDiskPath, DeviceType.HardDisk, AccessMode.ReadWrite, false)).andThrow(notFoundException);
expect(vBox.createHardDisk(diskFormat, adminDiskPath)).andReturn(medium);
expect(medium.createBaseStorage(anyLong(), anyLong())).andReturn(progress);