use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplateResourceTest method testUpdateUseExistingIcons.
@Test
public void testUpdateUseExistingIcons() throws Exception {
setUpGetGraphicsExpectations(1);
setUpUpdateExpectations();
setUpGetBallooningExpectations();
setUriInfo(setUpActionExpectations(ActionType.UpdateVmTemplate, UpdateVmTemplateParameters.class, new String[] {}, new Object[] {}, true, true));
final Template model = getRestModel(0);
model.setSmallIcon(IconTestHelpler.createIcon(GUIDS[2]));
model.setLargeIcon(IconTestHelpler.createIcon(GUIDS[3]));
verifyModel(resource.update(model), 0);
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplateResourceTest method testUpdateSetAndUploadIconFailure.
@Test
public void testUpdateSetAndUploadIconFailure() throws Exception {
final Template model = getRestModel(0);
model.setSmallIcon(IconTestHelpler.createIcon(GUIDS[2]));
model.setLargeIcon(IconTestHelpler.createIconWithData());
try {
verifyModel(resource.update(model), 0);
fail("expected WebApplicationException");
} catch (WebApplicationException wae) {
verifyFault(wae, BAD_REQUEST);
}
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddNamedVm.
@Test
public void testAddNamedVm() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetEntityExpectations(QueryType.GetVmByVmNameForDataCenter, GetVmByVmNameForDataCenterParameters.class, new String[] { "Name" }, new Object[] { NAMES[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" }, new Object[] { NAMES[0], DESCRIPTIONS[0] }, 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));
Template model = getModel(0);
model.getVm().setId(null);
model.getVm().setName(NAMES[1]);
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 testAddNamedVmFiltered.
@Test
public void testAddNamedVmFiltered() throws Exception {
setUpFilteredQueryExpectations();
setUriInfo(setUpBasicUriExpectations());
setUpHttpHeaderExpectations("Expect", "201-created");
setUpGetEntityExpectations(QueryType.GetVmByVmNameForDataCenter, GetVmByVmNameForDataCenterParameters.class, new String[] { "Name" }, new Object[] { NAMES[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" }, new Object[] { NAMES[0], DESCRIPTIONS[0] }, 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));
Template model = getModel(0);
model.getVm().setId(null);
model.getVm().setName(NAMES[1]);
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 testAddWithClonePermissionsClone.
@Test
public void testAddWithClonePermissionsClone() throws Exception {
Template model = getModel(0);
doTestAddWithClonePermissions(model, true);
}
Aggregations