Search in sources :

Example 26 with Label

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

the class LabelDaoTest method testCreateAndDeleteById.

@Test
public void testCreateAndDeleteById() {
    Guid guid = Guid.newGuid();
    Label label = new LabelBuilder().name("test label").id(guid).host(host.getId()).build();
    labelDao.save(label);
    labelDao.remove(label.getId());
    Label read = labelDao.get(guid);
    assertNull(read);
}
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 27 with Label

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

Example 28 with Label

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

the class LabelDaoTest method testCreateAndGetAll.

@Test
public void testCreateAndGetAll() {
    Guid guid = Guid.newGuid();
    Label label = new LabelBuilder().name("test label").id(guid).build();
    labelDao.save(label);
    List<Label> readList = labelDao.getAll();
    assertNotNull(readList);
    Label read = readList.get(0);
    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 29 with Label

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

the class LabelDaoTest method testAddHostToLabels.

@Test
public void testAddHostToLabels() {
    Label label = createAndSaveLabel("test_label");
    Label label2 = createAndSaveLabel("test_label_2");
    List<Label> labelsToAssign = Lists.newArrayList(label, label2);
    List<Guid> guidsForLabelsToAssign = labelsToAssign.stream().map(Label::getId).collect(Collectors.toList());
    labelDao.addHostToLabels(host.getId(), guidsForLabelsToAssign);
    List<Label> assignedLabels = labelDao.getAllByEntityIds(Lists.newArrayList(host.getId()));
    assertNotNull(assignedLabels);
    assertTrue(labelsToAssign.containsAll(assignedLabels) && assignedLabels.containsAll(labelsToAssign));
}
Also used : Label(org.ovirt.engine.core.common.businessentities.Label) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 30 with Label

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

the class AffinityLabelListModel method remove.

private void remove() {
    if (getWindow() != null) {
        return;
    }
    ConfirmationModel model = new ConfirmationModel();
    setConfirmWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().removeAffinityLabelsTitle());
    model.setHelpTag(HelpTag.remove_affinity_groups);
    // $NON-NLS-1$
    model.setHashName("remove_affinity_labels");
    ArrayList<String> list = new ArrayList<>();
    for (Label affinityLabel : getSelectedItems()) {
        list.add(affinityLabel.getName());
    }
    model.setItems(list);
    // $NON-NLS-1$
    model.getCommands().add(UICommand.createDefaultOkUiCommand("OnRemove", this));
    // $NON-NLS-1$
    model.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Also used : ArrayList(java.util.ArrayList) Label(org.ovirt.engine.core.common.businessentities.Label) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

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