use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testMoveTagRoot.
@Test
public void testMoveTagRoot() {
// let's have two top level tag under root
Tags level1obj1 = createTag("level1obj1", "");
level1obj1.setTagId(Guid.newGuid());
level1obj1.setParentId(tagsDirector.getRootTag().getTagId());
tagsDirector.addTag(level1obj1);
Tags level1obj2 = createTag("level1obj2", "");
level1obj2.setTagId(Guid.newGuid());
level1obj2.setParentId(tagsDirector.getRootTag().getTagId());
tagsDirector.addTag(level1obj2);
// now none of these should have any children
assertEquals(0, tagsDirector.getTagById(level1obj1.getTagId()).getChildren().size());
assertEquals(0, tagsDirector.getTagById(level1obj2.getTagId()).getChildren().size());
assertEquals(2, tagsDirector.getRootTag().getChildren().size());
// should be all right so far.
// now let's do the trick: move the second level tag to under the other first level tag
tagsDirector.moveTag(level1obj1.getTagId(), level1obj2.getTagId());
// and now let's recheck, the first top level should have 0 children, the second should have 1
assertEquals(1, tagsDirector.getTagById(level1obj2.getTagId()).getChildren().size());
assertEquals(1, tagsDirector.getRootTag().getChildren().size());
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testGetTagByNameNotExists.
@Test
public void testGetTagByNameNotExists() {
Tags fromTagsDirector = tagsDirector.getTagByTagName("does not exist");
assertNull(fromTagsDirector);
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testGetRootWithHierarchy.
@Test
public void testGetRootWithHierarchy() {
Tags tag = createTag("tag1", "desc1");
tagsDirector.addTag(tag);
Tags tags = tagsDirector.getRootTag();
assertNotNull(tags);
assertEquals(TagsDirector.ROOT_TAG_ID, tags.getTagId());
assertEquals(1, tags.getChildren().size());
assertEquals("tag1", tags.getChildren().get(0).getTagName());
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testGetTagIdAndChildrenIds.
@Test
public void testGetTagIdAndChildrenIds() {
Tags tag = createTag("tag1", "desc1");
Tags tag2 = createTag("tag2", "desc2");
tag.getChildren().add(tag2);
tag2.setParentId(tag.getParentId());
tagsDirector.addTag(tag);
String idsStr = tagsDirector.getTagIdAndChildrenIds(tag.getTagId());
String[] ids = idsStr.split("[,]");
assertEquals(2, ids.length);
assertEquals(ids[0], "'" + tag.getTagId().toString() + "'");
assertEquals(ids[1], "'" + tag2.getTagId().toString() + "'");
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testGetTagIdAndChildrenIdsByName.
@Test
public void testGetTagIdAndChildrenIdsByName() {
Tags tag = createTag("tag1", "desc1");
Tags tag2 = createTag("tag2", "desc2");
tag.getChildren().add(tag2);
tag2.setParentId(tag.getParentId());
tagsDirector.addTag(tag);
String idsStr = tagsDirector.getTagIdAndChildrenIds(tag.getTagName());
String[] ids = idsStr.split("[,]");
assertEquals(2, ids.length);
assertEquals(ids[0], "'" + tag.getTagId().toString() + "'");
assertEquals(ids[1], "'" + tag2.getTagId().toString() + "'");
}
Aggregations