Search in sources :

Example 91 with Snapshot

use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.

the class GetAllVmSnapshotsByVmIdQueryTest method testExecuteQueryCommand.

@Test
public void testExecuteQueryCommand() {
    IdQueryParameters params = getQueryParameters();
    when(params.getId()).thenReturn(vmId);
    GetAllVmSnapshotsByVmIdQuery<IdQueryParameters> query = getQuery();
    query.executeQueryCommand();
    @SuppressWarnings("unchecked") List<Snapshot> snapshots = query.getQueryReturnValue().getReturnValue();
    // Assert the correct disks are returned
    assertTrue("snapshot should be in the return value", snapshots.contains(snapshot));
    assertEquals("there should be exactly one snapshot returned", 1, snapshots.size());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AbstractUserQueryTest(org.ovirt.engine.core.bll.AbstractUserQueryTest) Test(org.junit.Test)

Example 92 with Snapshot

use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.

the class GetAllVmSnapshotsWithLeasesFromConfigurationByVmIdQueryTest method testExecuteQueryCommand.

@Test
public void testExecuteQueryCommand() {
    IdQueryParameters params = getQueryParameters();
    when(params.getId()).thenReturn(vmId);
    disk1.setId(Guid.newGuid());
    disk2.setId(Guid.newGuid());
    VM vm = new VM();
    vm.setId(vmId);
    vm.setImages(new ArrayList<>(Arrays.asList(disk1, disk2)));
    doReturn(vm).when(snapshotVmConfigurationHelper).getVmFromConfiguration(any(), any(), any());
    getQuery().executeQueryCommand();
    Map<Snapshot, Guid> snapshots = getQuery().getQueryReturnValue().getReturnValue();
    // Assert the correct disks are returned
    assertEquals("there should be exactly one snapshot returned", 1, snapshots.keySet().size());
    assertTrue("snapshot should be in the return value", snapshots.containsKey(snapshot));
    Snapshot snap = (Snapshot) snapshots.keySet().toArray()[0];
    assertEquals("snapshot should contain a list of 2 diskImages", 2, snap.getDiskImages().size());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) VM(org.ovirt.engine.core.common.businessentities.VM) Guid(org.ovirt.engine.core.compat.Guid) AbstractUserQueryTest(org.ovirt.engine.core.bll.AbstractUserQueryTest) Test(org.junit.Test)

Example 93 with Snapshot

use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.

the class RestoreAllSnapshotsCommandTest method validateFailsOnSnapshotTypeRegularNotInPreview.

@Test
public void validateFailsOnSnapshotTypeRegularNotInPreview() {
    mockSnapshotExists();
    mockSnapshot = new Snapshot();
    when(snapshotDao.exists(nullable(Guid.class), nullable(Guid.class))).thenReturn(true);
    mockSnapshotFromDb();
    mockSnapshot.setType(SnapshotType.REGULAR);
    mockSnapshot.setStatus(SnapshotStatus.OK);
    ValidateTestUtils.runAndAssertValidateFailure(spyCommand, EngineMessage.ACTION_TYPE_FAILED_VM_SNAPSHOT_NOT_IN_PREVIEW);
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 94 with Snapshot

use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.

the class SnapshotVmConfigurationHelperTest method createSnapshot.

private Snapshot createSnapshot(Guid existingSnapshotId) {
    Snapshot snapshot = new Snapshot();
    snapshot.setId(existingSnapshotId);
    snapshot.setVmId(existingVmId);
    snapshot.setVmConfiguration(EXISTING_VM_NAME);
    return snapshot;
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot)

Example 95 with Snapshot

use of org.ovirt.engine.core.common.businessentities.Snapshot in project ovirt-engine by oVirt.

the class SnapshotsValidatorTest method setUp.

@Before
public void setUp() {
    vmId = Guid.newGuid();
    snapshot = new Snapshot();
    snapshot.setId(Guid.newGuid());
    snapshot.setType(Snapshot.SnapshotType.REGULAR);
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Before(org.junit.Before)

Aggregations

Snapshot (org.ovirt.engine.core.common.businessentities.Snapshot)96 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)33 VM (org.ovirt.engine.core.common.businessentities.VM)32 Guid (org.ovirt.engine.core.compat.Guid)30 Test (org.junit.Test)21 ArrayList (java.util.ArrayList)15 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)12 List (java.util.List)11 SnapshotStatus (org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotStatus)9 Collections (java.util.Collections)8 Date (java.util.Date)8 Set (java.util.Set)8 Collectors (java.util.stream.Collectors)8 SnapshotType (org.ovirt.engine.core.common.businessentities.Snapshot.SnapshotType)8 EngineException (org.ovirt.engine.core.common.errors.EngineException)8 ActionType (org.ovirt.engine.core.common.action.ActionType)7 DiskStorageType (org.ovirt.engine.core.common.businessentities.storage.DiskStorageType)6 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5