Search in sources :

Example 1 with Tags

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

Example 2 with Tags

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

Example 3 with Tags

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

Example 4 with Tags

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() + "'");
}
Also used : Tags(org.ovirt.engine.core.common.businessentities.Tags) Test(org.junit.Test)

Example 5 with Tags

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() + "'");
}
Also used : Tags(org.ovirt.engine.core.common.businessentities.Tags) Test(org.junit.Test)

Aggregations

Tags (org.ovirt.engine.core.common.businessentities.Tags)68 Test (org.junit.Test)34 ArrayList (java.util.ArrayList)8 Guid (org.ovirt.engine.core.compat.Guid)5 HashSet (java.util.HashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Before (org.junit.Before)2 TagsTemplateMap (org.ovirt.engine.core.common.businessentities.TagsTemplateMap)2 TagsVdsMap (org.ovirt.engine.core.common.businessentities.TagsVdsMap)2 TagsVmMap (org.ovirt.engine.core.common.businessentities.TagsVmMap)2 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Date (java.util.Date)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1 Named (javax.inject.Named)1 Singleton (javax.inject.Singleton)1 Response (javax.ws.rs.core.Response)1 Tag (org.ovirt.engine.api.model.Tag)1