use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method verifyCollection.
@Override
protected void verifyCollection(List<Template> collection) throws Exception {
super.verifyCollection(collection);
for (Template template : collection) {
if (template.getId().equals(GUIDS[2].toString())) {
assertEquals(VERSION_NAME, template.getVersion().getVersionName());
assertEquals(new Integer(2), template.getVersion().getVersionNumber());
assertEquals(template.getVersion().getBaseTemplate().getId(), GUIDS[1].toString());
} else {
assertFalse(template.getVersion().isSetVersionName());
assertEquals(new Integer(1), template.getVersion().getVersionNumber());
assertEquals(template.getVersion().getBaseTemplate().getId(), template.getId());
}
}
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method doTestAddWithClonePermissions.
private void doTestAddWithClonePermissions(Template model, boolean copy) throws Exception {
UriInfo uriInfo = setUpBasicUriExpectations();
uriInfo = addMatrixParameterExpectations(uriInfo, BackendTemplatesResource.CLONE_PERMISSIONS, Boolean.toString(copy));
setUriInfo(uriInfo);
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
setUpGetEntityExpectations(0);
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 0, 1);
setUpGetVirtioScsiExpectations(0, 0);
setUpGetSoundcardExpectations(0, 0, 1);
setUpGetRngDeviceExpectations(0, 0);
setUpGetBallooningExpectations(0, 0);
setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description", "CopyVmPermissions" }, new Object[] { NAMES[0], DESCRIPTIONS[0], copy }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Template);
verifyModel((Template) response.getEntity(), 0);
assertNull(((Template) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddUploadIcon.
@Test
public void testAddUploadIcon() throws Exception {
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 0, 1);
setUpGetSoundcardExpectations(1);
setUpGetBallooningExpectations(0, 0);
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
setUpAddExpectations();
setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description", "VmLargeIcon" }, new Object[] { NAMES[0], DESCRIPTIONS[0], VmIcon.typeAndDataToDataUrl(IconTestHelpler.MEDIA_TYPE, IconTestHelpler.DATA_URL) }, true, true, GUIDS[0], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
final Template restModel = getRestModel(0);
restModel.setLargeIcon(IconTestHelpler.createIconWithData());
Response response = doAdd(restModel);
assertEquals(201, response.getStatus());
verifyModel((Template) response.getEntity(), 0);
assertNull(((Template) response.getEntity()).getCreationStatus());
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method populateVersion.
public static void populateVersion(Template t) {
TemplateVersion templateVersion = new TemplateVersion();
templateVersion.setVersionName(VERSION_NAME);
templateVersion.setVersionNumber(2);
Template base = new Template();
base.setId(GUIDS[1].toString());
templateVersion.setBaseTemplate(base);
t.setVersion(templateVersion);
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddVersion.
@Test
public void testAddVersion() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(2, 2, 1);
setUpGetVirtioScsiExpectations(2, 2);
setUpGetSoundcardExpectations(2, 2, 1);
setUpGetRngDeviceExpectations(2, 2);
setUpGetBallooningExpectations(2, 2);
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
setUpGetEntityExpectations(2);
setUpCreationExpectations(ActionType.AddVmTemplate, AddVmTemplateParameters.class, new String[] { "Name", "Description" }, new Object[] { NAMES[2], DESCRIPTIONS[2] }, true, true, GUIDS[2], asList(GUIDS[2]), asList(new AsyncTaskStatus(AsyncTaskStatusEnum.finished)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[2] }, getEntity(2));
Response response = collection.add(getModel(2));
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Template);
assertEquals(VERSION_NAME, ((Template) response.getEntity()).getVersion().getVersionName());
assertEquals(((Template) response.getEntity()).getVersion().getBaseTemplate().getId(), GUIDS[1].toString());
verifyModel((Template) response.getEntity(), 2);
}
Aggregations