use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testUpdateParent.
@Test
public void testUpdateParent() {
Tags tag1 = createTag("tag1", "desc1");
Tags tag2 = createTag("tag2", "desc2");
Tags tag3 = createTag("tag3", "desc3");
Tags tag4 = createTag("tag4", "desc4");
tagsDirector.addTag(tag1);
tagsDirector.addTag(tag2);
tagsDirector.addTag(tag3);
tagsDirector.addTag(tag4);
// Emulates the REST API behavior of getting all the tags prior to updating
ArrayList<Tags> tags = tagsDirector.getAllTags();
Tags tagToChange = tags.stream().filter(t -> t.getTagName().equals("tag1")).findFirst().orElse(null);
tagToChange.setParentId(tag2.getTagId());
tagsDirector.updateTag(tagToChange);
// Emulates the REST API behavior of getting all the tags after updating
tags = tagsDirector.getAllTags();
Tags changedTag = tags.stream().filter(t -> t.getTagName().equals("tag1")).findFirst().orElse(null);
assertEquals(tag2.getTagId(), changedTag.getParentId());
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testUpdate.
/**
* Test to check that bz https://bugzilla.redhat.com/722203 got solved. The test is a java translation of an
* automation test that takes 4 tags, adds them to the tags director, changes one of the tags parent to be the other
* tag, updates the tag, and queries the tags.
*/
@Test
public void testUpdate() {
Tags tag = createTag("tag1", "desc1");
tagsDirector.addTag(tag);
tag.setTagName("new name");
tagsDirector.updateTag(tag);
Tags fromDirector = tagsDirector.getTagById(tag.getTagId());
assertEquals(tag.getTagName(), fromDirector.getTagName());
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testUpdateParentTag.
@Test
public void testUpdateParentTag() {
Tags tag = createTag("tag1", "desc1");
tag.setTagId(Guid.newGuid());
tagsDirector.addTag(tag);
Tags rootTag = tagsDirector.getRootTag();
tag = rootTag.getChildren().get(0);
assertEquals("tag1", tag.getTagName());
// now let's add another tag
Tags sub = createTag("subtag1", "subdesc");
sub.setTagId(Guid.newGuid());
sub.setParentId(tag.getTagId());
tagsDirector.addTag(sub);
// so now the root tag must have 1 child
assertEquals(1, tagsDirector.getRootTag().getChildren().size());
assertEquals(1, tagsDirector.getTagById(tag.getTagId()).getChildren().size());
// get the parent, and rename it
tag.setTagName("subtag1_up");
tagsDirector.updateTag(tag);
// now let's see the number of children in the tag objects
// this is the assertion that fails without fix for #732640
assertEquals(1, tagsDirector.getRootTag().getChildren().size());
assertEquals(1, tagsDirector.getTagById(tag.getTagId()).getChildren().size());
// let's check the same thing on overwriting description
tag.setDescription("TEST TEST TEST TEST");
tagsDirector.updateTag(tag);
// and all the checks once again just to make sure
assertEquals(1, tagsDirector.getRootTag().getChildren().size());
assertEquals(1, tagsDirector.getTagById(tag.getTagId()).getChildren().size());
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testGetRootTag.
@Test
public void testGetRootTag() {
Tags tags = tagsDirector.getRootTag();
assertNotNull(tags);
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testDirectDescetor.
@Test
public void testDirectDescetor() {
Tags tag1 = createTag("tag1", "desc1");
Tags tag2 = createTag("tag2", "desc2");
tagsDirector.addTag(tag1);
tagsDirector.addTag(tag2);
tagsDirector.moveTag(tag2.getTagId(), tag1.getTagId());
assertTrue(tagsDirector.isTagDescestorOfTag(tag1.getTagId(), tag2.getTagId()));
}
Aggregations