public void map(Disk disk, String snapshotId) { disk.setSnapshot(new Snapshot()); disk.getSnapshot().setId(snapshotId); }
@Test public void testPreviewSnapshot() { setUriInfo(setUpActionExpectations(ActionType.TryBackToAllSnapshotsOfVm, TryBackToAllSnapshotsOfVmParameters.class, new String[] { "VmId", "DstSnapshotId" }, new Object[] { GUIDS[0], GUIDS[1] })); Action action = new Action(); Snapshot snapshot = new Snapshot(); snapshot.setId(GUIDS[1].toString()); action.setSnapshot(snapshot); Response response = resource.previewSnapshot(action); verifyActionResponse(response); Action actionResponse = (Action)response.getEntity(); assertTrue(actionResponse.isSetStatus()); assertEquals(CreationStatus.COMPLETE.value(), actionResponse.getStatus()); }
@Mapping(from = org.ovirt.engine.core.common.businessentities.Snapshot.class, to = Snapshot.class) public static Snapshot map(org.ovirt.engine.core.common.businessentities.Snapshot entity, Snapshot template) { Snapshot model = template != null ? template : new Snapshot(); model.setId(entity.getId().toString()); if (entity.getDescription() != null) { model.setDescription(entity.getDescription()); } if (entity.getCreationDate() != null) { model.setDate(DateMapper.map(entity.getCreationDate(), null)); } if (entity.getStatus() != null) { model.setSnapshotStatus(map(entity.getStatus(), null)); } if (entity.getType() != null) { model.setSnapshotType(map(entity.getType(), null)); } model.setPersistMemorystate(entity.containsMemory()); return model; }
@Test public void testAttachDiskSnapshot() { setUriInfo(setUpBasicUriExpectations()); Guid snapshotId = Guid.newGuid(); Disk model = getModel(); model.setSnapshot(new Snapshot()); model.getSnapshot().setId(snapshotId.toString()); model.setId(DISK_ID.toString()); //means this is an existing disk --> attach setUpCreationExpectations( ActionType.AttachDiskToVm, AttachDetachVmDiskParameters.class, new String[] { "VmId", "EntityInfo", "SnapshotId" }, new Object[] { VM_ID, new EntityInfo(VdcObjectType.Disk, DISK_ID), snapshotId }, true, true, null, null, null, QueryType.GetDiskByDiskId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DISK_ID }, asList(getEntity(0)) ); Response response = collection.add(model); assertEquals(201, response.getStatus()); }
model.getSnapshot().setId(entity.getSnapshotId().toString());
to.setId(from.getId());