Search in sources :

Example 6 with Template

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);
}
Also used : UpdateVmTemplateParameters(org.ovirt.engine.core.common.action.UpdateVmTemplateParameters) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 7 with Template

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);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 8 with Template

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());
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 9 with Template

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());
}
Also used : Response(javax.ws.rs.core.Response) AsyncTaskStatus(org.ovirt.engine.core.common.businessentities.AsyncTaskStatus) Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Example 10 with Template

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);
}
Also used : Template(org.ovirt.engine.api.model.Template) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) Test(org.junit.Test)

Aggregations

Template (org.ovirt.engine.api.model.Template)57 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)32 Test (org.junit.Test)21 Response (javax.ws.rs.core.Response)16 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)12 Vm (org.ovirt.engine.api.model.Vm)11 WebApplicationException (javax.ws.rs.WebApplicationException)6 VmPool (org.ovirt.engine.api.model.VmPool)4 Cluster (org.ovirt.engine.api.model.Cluster)3 InstanceType (org.ovirt.engine.api.model.InstanceType)3 TimeZone (org.ovirt.engine.api.model.TimeZone)3 GetVmTemplateParameters (org.ovirt.engine.core.common.queries.GetVmTemplateParameters)3 ArrayList (java.util.ArrayList)2 Boot (org.ovirt.engine.api.model.Boot)2 Host (org.ovirt.engine.api.model.Host)2 OperatingSystem (org.ovirt.engine.api.model.OperatingSystem)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 Tag (org.ovirt.engine.api.model.Tag)2 TemplateVersion (org.ovirt.engine.api.model.TemplateVersion)2 Templates (org.ovirt.engine.api.model.Templates)2