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);
}
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));
}
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());
}
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));
}
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));
}
Aggregations