Search in sources :

Example 71 with Snapshot

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

the class DiskSnapshotsValidatorTest method diskSnapshotsCannotBePreviewed.

@Test
public void diskSnapshotsCannotBePreviewed() {
    Snapshot activeSnapshot = getActiveSnapshot();
    when(snapshotDao.get(any())).thenReturn(activeSnapshot);
    when(diskImageDao.get(disk1.getImageId())).thenReturn(disk1);
    when(diskImageDao.get(disk2.getImageId())).thenReturn(disk2);
    assertThat(validator.canDiskSnapshotsBePreviewed(activeSnapshot.getId()), failsWith(EngineMessage.CANNOT_PREVIEW_ACTIVE_SNAPSHOT));
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Test(org.junit.Test)

Example 72 with Snapshot

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

the class VmStaticDaoTest method testRemoveWithoutPermissions.

@Test
public void testRemoveWithoutPermissions() {
    for (Snapshot s : dbFacade.getSnapshotDao().getAll()) {
        dbFacade.getSnapshotDao().remove(s.getId());
    }
    PermissionDao permissionsDao = dbFacade.getPermissionDao();
    int numberOfPermissionsBeforeRemove = permissionsDao.getAllForEntity(getExistingEntityId()).size();
    dao.remove(getExistingEntityId(), false);
    VmStatic result = dao.get(getExistingEntityId());
    assertNull(result);
    assertEquals("vm permissions changed during remove although shouldnt have.", numberOfPermissionsBeforeRemove, permissionsDao.getAllForEntity(getExistingEntityId()).size());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 73 with Snapshot

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

the class VmStaticDaoTest method testRemove.

@Test
@Override
public void testRemove() {
    for (Snapshot s : dbFacade.getSnapshotDao().getAll()) {
        dbFacade.getSnapshotDao().remove(s.getId());
    }
    dao.remove(getExistingEntityId());
    VmStatic result = dao.get(getExistingEntityId());
    assertNull(result);
    PermissionDao permissionsDao = dbFacade.getPermissionDao();
    assertEquals("vm permissions wasn't removed", 0, permissionsDao.getAllForEntity(getExistingEntityId()).size());
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 74 with Snapshot

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

the class SnapshotDaoTest method getOneSnapshotsByMemoryDump.

@Test
public void getOneSnapshotsByMemoryDump() {
    Snapshot snapshot = new Snapshot();
    snapshot.setMemoryDiskId(EXISTING_MEMORY_DUMP_DISK_ID);
    snapshot.setMetadataDiskId(Guid.newGuid());
    assertEquals(1, dao.getNumOfSnapshotsByDisks(snapshot));
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Test(org.junit.Test)

Example 75 with Snapshot

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

the class SnapshotDaoTest method getOneSnapshotsByMemoryConf.

@Test
public void getOneSnapshotsByMemoryConf() {
    Snapshot snapshot = new Snapshot();
    snapshot.setMemoryDiskId(Guid.newGuid());
    snapshot.setMetadataDiskId(EXISTING_MEMORY_CONF_DISK_ID);
    assertEquals(1, dao.getNumOfSnapshotsByDisks(snapshot));
}
Also used : Snapshot(org.ovirt.engine.core.common.businessentities.Snapshot) Test(org.junit.Test)

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