use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class LabelDaoTest method testCreateAndGetLabelWithTwoItems.
@Test
public void testCreateAndGetLabelWithTwoItems() {
VmStatic vm = createAndSaveVm();
Label label = new LabelBuilder().name("test label").id(Guid.newGuid()).entities(host, vm).build();
labelDao.save(label);
List<Label> read = labelDao.getAllByEntityIds(Lists.newArrayList(host.getId(), vm.getId()));
assertNotNull(read);
assertEquals(1, read.size());
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class LabelDaoTest method testCreateAndGetByIds.
@Test
public void testCreateAndGetByIds() {
Label label = new LabelBuilder().name("test label").id(Guid.newGuid()).entity(host).build();
labelDao.save(label);
VmStatic vm = createAndSaveVm();
VmStatic vm2 = createAndSaveVm();
Label label2 = new LabelBuilder().name("test label 2").id(Guid.newGuid()).entity(vm).build();
labelDao.save(label2);
label = new LabelBuilder().name("test label not in result").id(Guid.newGuid()).entity(vm2).build();
labelDao.save(label);
List<Label> read = labelDao.getAllByIds(Lists.newArrayList(label.getId(), label2.getId()));
assertNotNull(read);
assertEquals(2, read.size());
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class LabelDaoTest method testAddVmToLabels.
@Test
public void testAddVmToLabels() {
Label label = createAndSaveLabel("test_label");
Label label2 = createAndSaveLabel("test_label_2");
VmStatic vm = createAndSaveVm();
List<Label> labelsToAssign = Lists.newArrayList(label, label2);
List<Guid> guidsForLabelsToAssign = labelsToAssign.stream().map(Label::getId).collect(Collectors.toList());
labelDao.addVmToLabels(vm.getId(), guidsForLabelsToAssign);
List<Label> assignedLabels = labelDao.getAllByEntityIds(Lists.newArrayList(vm.getId()));
assertNotNull(assignedLabels);
assertTrue(labelsToAssign.containsAll(assignedLabels) && assignedLabels.containsAll(labelsToAssign));
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class LabelDaoTest method createAndSaveVm.
private VmStatic createAndSaveVm() {
VmStatic vm = new VmStatic();
vm.setId(Guid.newGuid());
vmDao.save(vm);
return vm;
}
use of org.ovirt.engine.core.common.businessentities.VmStatic in project ovirt-engine by oVirt.
the class VmManager method init.
@PostConstruct
public void init() {
setPowerOffTimeout(System.nanoTime());
VmStatic vmStatic = vmStaticDao.get(vmId);
// vmStatic is null for externally managed VMs
if (vmStatic != null) {
updateStaticFields(vmStatic);
}
}
Aggregations