Search in sources :

Example 21 with Label

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

the class LabelDaoTest method testCreateAndGetById.

@Test
public void testCreateAndGetById() {
    Guid guid = Guid.newGuid();
    Label label = new LabelBuilder().name("test label").id(guid).build();
    labelDao.save(label);
    Label read = labelDao.get(guid);
    assertNotNull(read);
    assertEquals(guid, read.getId());
    assertEquals(label.getName(), read.getName());
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 22 with Label

use of org.ovirt.engine.core.common.businessentities.Label 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());
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) Test(org.junit.Test)

Example 23 with Label

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

the class LabelDaoTest method testCreateAndGetWithHost.

@Test
public void testCreateAndGetWithHost() {
    Guid guid = Guid.newGuid();
    Label label = new LabelBuilder().name("test label").id(guid).entity(host).build();
    labelDao.save(label);
    Label read = labelDao.get(guid);
    assertNotNull(read);
    assertEquals(guid, read.getId());
    assertEquals(label.getName(), read.getName());
    assertNotNull(read.getVms());
    assertEquals(0, read.getVms().size());
    assertEquals(1, read.getHosts().size());
    assertEquals(host.getId(), read.getHosts().iterator().next());
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 24 with Label

use of org.ovirt.engine.core.common.businessentities.Label 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());
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) Test(org.junit.Test)

Example 25 with Label

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

the class LabelDaoTest method testUpdateLabelsForHost.

@Test
public void testUpdateLabelsForHost() {
    Label label = createAndSaveLabel("test_label");
    labelDao.addHostToLabels(host.getId(), Lists.newArrayList(label.getId()));
    Label label2 = createAndSaveLabel("test_label_2");
    labelDao.updateLabelsForHost(host.getId(), Lists.newArrayList(label2.getId()));
    List<Label> assignedLabels = labelDao.getAllByEntityIds(Lists.newArrayList(host.getId()));
    assertNotNull(assignedLabels);
    assertEquals(Lists.newArrayList(label2), assignedLabels);
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) Test(org.junit.Test)

Aggregations

Label (org.ovirt.engine.core.common.businessentities.Label)47 Test (org.junit.Test)19 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)19 Guid (org.ovirt.engine.core.compat.Guid)14 LabelActionParameters (org.ovirt.engine.core.common.action.LabelActionParameters)7 VmStatic (org.ovirt.engine.core.common.businessentities.VmStatic)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)3 VM (org.ovirt.engine.core.common.businessentities.VM)3 PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 AffinityLabel (org.ovirt.engine.api.model.AffinityLabel)2 Host (org.ovirt.engine.api.model.Host)2 Vm (org.ovirt.engine.api.model.Vm)2 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 FullEntityOvfData (org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData)2 LunDisk (org.ovirt.engine.core.common.businessentities.storage.LunDisk)2