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;
}
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());
}
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());
}
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);
}
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);
}
}
Aggregations