Search in sources :

Example 16 with Tag

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

the class BackendTagsResourceTest method testAddTagNamedParent.

@Test
public void testAddTagNamedParent() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetTagByTagName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[PARENT_IDX] }, getEntity(PARENT_IDX));
    setUpCreationExpectations(ActionType.AddTag, TagsOperationParameters.class, new String[] { "Tag.TagName", "Tag.ParentId" }, new Object[] { NAMES[0], PARENT_GUID }, true, true, null, QueryType.GetTagByTagName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[0] }, getEntity(0));
    Tag model = getModel(0);
    model.getParent().setId(null);
    model.getParent().setName(NAMES[PARENT_IDX]);
    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 17 with Tag

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

the class BackendTagsResourceTest method testAddIncompleteParameters.

@Test
public void testAddIncompleteParameters() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    try {
        collection.add(new Tag());
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Tag", "add", "name");
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Tag(org.ovirt.engine.api.model.Tag) Test(org.junit.Test)

Example 18 with Tag

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

the class BackendTagsResourceTest method testListLimitResults.

@Test
public void testListLimitResults() throws Exception {
    UriInfo uriInfo = setUpUriExpectationsWithMax(false);
    setUpQueryExpectations("");
    collection.setUriInfo(uriInfo);
    List<Tag> results = getCollection();
    assertNotNull(collection);
    assertEquals(3, results.size());
}
Also used : Tag(org.ovirt.engine.api.model.Tag) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 19 with Tag

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

the class BackendTagsResourceTest method testAddTag.

@Test
public void testAddTag() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AddTag, TagsOperationParameters.class, new String[] { "Tag.TagName", "Tag.ParentId" }, new Object[] { NAMES[0], PARENT_GUID }, true, true, null, QueryType.GetTagByTagName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { NAMES[0] }, getEntity(0));
    Response response = collection.add(getModel(0));
    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 20 with Tag

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

the class AbstractBackendAssignedTagsResourceTest method testAddTag.

@Test
public void testAddTag() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    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.setId(GUIDS[0].toString());
    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)

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