Search in sources :

Example 1 with Tag

use of org.ovirt.engine.api.model.Tag in project ovirt-engine by oVirt.

the class BackendApiResource method createRootTag.

private Tag createRootTag() {
    Tag tag = new Tag();
    String id = "00000000-0000-0000-0000-000000000000";
    tag.setId(id);
    tag.setHref(getAbsolutePath("tags", id));
    return tag;
}
Also used : Tag(org.ovirt.engine.api.model.Tag)

Example 2 with Tag

use of org.ovirt.engine.api.model.Tag in project ovirt-engine by oVirt.

the class BackendTagsResourceTest method testAddTagNoParent.

@Test
public void testAddTagNoParent() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    Tags entity = getEntity(0);
    entity.setParentId(Guid.Empty);
    setUpCreationExpectations(ActionType.AddTag, TagsOperationParameters.class, new String[] { "Tag.TagName", "Tag.ParentId" }, new Object[] { NAMES[0], Guid.Empty }, true, true, null, QueryType.GetTagByTagName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[0] }, entity);
    Tag model = getModel(0);
    model.setParent(null);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Tag);
    verifyModel((Tag) response.getEntity(), 0, Guid.Empty.toString());
}
Also used : Response(javax.ws.rs.core.Response) Tag(org.ovirt.engine.api.model.Tag) Tags(org.ovirt.engine.core.common.businessentities.Tags) Test(org.junit.Test)

Example 3 with Tag

use of org.ovirt.engine.api.model.Tag in project ovirt-engine by oVirt.

the class BackendTagResource method update.

@Override
public Tag update(Tag incoming) {
    if (parent.isSetParentName(incoming)) {
        incoming.getParent().setId(parent.getParentId(incoming));
    }
    Tag existingTag = get();
    String existingTagParentId = existingTag.isSetParent() ? existingTag.getParent().getId() : null;
    if (isSetParent(incoming) && !incoming.getParent().getId().equals(existingTagParentId)) {
        moveTag(asGuid(incoming.getParent().getId()));
    }
    return performUpdate(incoming, new QueryIdResolver<>(QueryType.GetTagByTagId, IdQueryParameters.class), ActionType.UpdateTag, new UpdateParametersProvider());
}
Also used : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) Tag(org.ovirt.engine.api.model.Tag)

Example 4 with Tag

use of org.ovirt.engine.api.model.Tag in project ovirt-engine by oVirt.

the class AbstractBackendAssignedTagsResourceTest method testAddTagByName.

@Test
public void testAddTagByName() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetAllTags, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpTags());
    setUpCreationExpectations(attachAction, attachParams, new String[] { "TagId", "EntitiesId" }, new Object[] { GUIDS[0], asList(PARENT_GUID) }, true, true, null, QueryType.GetTagByTagId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, setUpTags().get(0));
    Tag model = new Tag();
    model.setName(NAMES[0]);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Tag);
    verifyModel((Tag) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) Tag(org.ovirt.engine.api.model.Tag) Test(org.junit.Test)

Example 5 with Tag

use of org.ovirt.engine.api.model.Tag in project ovirt-engine by oVirt.

the class AbstractBackendAssignedTagsResourceTest method doTestBadAddTag.

private void doTestBadAddTag(boolean valid, boolean success, String detail) throws Exception {
    setUriInfo(setUpActionExpectations(attachAction, attachParams, new String[] { "TagId", "EntitiesId" }, new Object[] { GUIDS[0], asList(PARENT_GUID) }, valid, success));
    Tag model = new Tag();
    model.setId(GUIDS[0].toString());
    try {
        collection.add(model);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyFault(wae, detail);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Tag(org.ovirt.engine.api.model.Tag)

Aggregations

Tag (org.ovirt.engine.api.model.Tag)21 Test (org.junit.Test)15 Response (javax.ws.rs.core.Response)5 WebApplicationException (javax.ws.rs.WebApplicationException)4 Template (org.ovirt.engine.api.model.Template)2 UriInfo (javax.ws.rs.core.UriInfo)1 Host (org.ovirt.engine.api.model.Host)1 User (org.ovirt.engine.api.model.User)1 Vm (org.ovirt.engine.api.model.Vm)1 V3Link (org.ovirt.engine.api.v3.types.V3Link)1 V3SpecialObjects (org.ovirt.engine.api.v3.types.V3SpecialObjects)1 Tags (org.ovirt.engine.core.common.businessentities.Tags)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1