Search in sources :

Example 6 with Tags

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

Example 7 with Tags

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

Example 8 with Tags

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

Example 9 with Tags

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

Example 10 with 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()));
}
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