private void verifyDisk(Disk disk) { assertNotNull(disk); assertEquals(disk.getId(), DISK_ID); assertNotNull(disk.getVm()); assertEquals(disk.getVm().getId(), VM_ID); verifyLinks(disk); }
@Test public void testDiskAdd() throws Exception { PowerShellDisksResource diskResource = new PowerShellDisksResource(VM_ID, poolMap, parser, "get-vm", uriProvider, httpHeaders); setUpHttpHeaderExpectations("Expect", null); Disk disk = new Disk(); disk.setType(DiskType.SYSTEM.value()); disk.setSize(DISK_SIZE_BYTES); String command = MessageFormat.format(ADD_DISK_COMMAND, DISK_SIZE, VM_ID) + ASYNC_ENDING + " " + ASYNC_TASKS; setUriInfo( setUpCmdExpectations( asArray(command), asArray(formatDisk(DISK_NAME)), "disks", DISK_ID, false)); Response response = diskResource.add(disk); Disk created = (Disk) response.getEntity(); verifyDisk(created); assertEquals(202, response.getStatus()); assertEquals(CreationStatus.PENDING.value(), created.getCreationStatus().getState()); verifyLink(created, "creation_status"); }
@Test public void testDiskAddBlocking() throws Exception { PowerShellDisksResource diskResource = new PowerShellDisksResource(VM_ID, poolMap, parser, "get-vm", uriProvider, httpHeaders); setUpHttpHeaderExpectations("Expect", "201-created"); Disk disk = new Disk(); disk.setType(DiskType.SYSTEM.value()); disk.setSize(DISK_SIZE_BYTES); String command = MessageFormat.format(ADD_DISK_COMMAND, DISK_SIZE, VM_ID); setUriInfo(setUpCmdExpectations(command, formatDisk(DISK_NAME), "disks", DISK_ID)); Response response = diskResource.add(disk); verifyDisk((Disk) response.getEntity()); assertEquals(201, response.getStatus()); }