use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddSetAndUploadIconFailure.
@Test
public void testAddSetAndUploadIconFailure() throws Exception {
final Template restModel = getRestModel(0);
restModel.setLargeIcon(IconTestHelpler.createIconWithData());
restModel.setSmallIcon(IconTestHelpler.createIcon(GUIDS[2]));
try {
collection.add(restModel);
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 getModel.
static Template getModel(int index) {
Template model = new Template();
model.setName(NAMES[index]);
model.setDescription(DESCRIPTIONS[index]);
model.setVm(new Vm());
model.getVm().setId(GUIDS[1].toString());
model.setCluster(new org.ovirt.engine.api.model.Cluster());
model.getCluster().setId(GUIDS[2].toString());
if (index == 2) {
populateVersion(model);
}
return model;
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method doTestAddAsync.
private void doTestAddAsync(AsyncTaskStatusEnum asyncStatus, CreationStatus creationStatus) throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpGetGraphicsExpectations(1);
setUpGetConsoleExpectations(0, 1);
setUpGetVirtioScsiExpectations(0);
setUpGetSoundcardExpectations(0, 1);
setUpGetRngDeviceExpectations(0);
setUpGetBallooningExpectations(new Integer[] { 0 });
setUpGetEntityExpectations(QueryType.GetVmByVmId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[1] }, setUpVm(GUIDS[1]));
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(asyncStatus)), QueryType.GetVmTemplate, GetVmTemplateParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Response response = collection.add(getModel(0));
assertEquals(202, response.getStatus());
assertTrue(response.getEntity() instanceof Template);
verifyModel((Template) response.getEntity(), 0);
Template created = (Template) response.getEntity();
assertNotNull(created.getCreationStatus());
assertEquals(creationStatus.value(), created.getCreationStatus());
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddIncompleteParameters.
@Test
public void testAddIncompleteParameters() throws Exception {
Template model = new Template();
model.setName(NAMES[0]);
setUriInfo(setUpBasicUriExpectations());
try {
collection.add(model);
fail("expected WebApplicationException on incomplete parameters");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Template", "add", "vm.id|name");
}
}
use of org.ovirt.engine.api.model.Template in project ovirt-engine by oVirt.
the class BackendTemplatesResourceTest method testAddUseExistingIcons.
@Test
public void testAddUseExistingIcons() 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" }, 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));
final Template restModel = getRestModel(0);
restModel.setSmallIcon(IconTestHelpler.createIcon(GUIDS[2]));
restModel.setLargeIcon(IconTestHelpler.createIcon(GUIDS[3]));
Response response = doAdd(restModel);
assertEquals(201, response.getStatus());
verifyModel((Template) response.getEntity(), 0);
assertNull(((Template) response.getEntity()).getCreationStatus());
}
Aggregations