Search in sources :

Example 6 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendStorageDomainVmResourceTest method testImportNotFound.

@Test
public void testImportNotFound() throws Exception {
    Action action = new Action();
    action.setStorageDomain(new StorageDomain());
    action.getStorageDomain().setId(GUIDS[2].toString());
    action.setCluster(new org.ovirt.engine.api.model.Cluster());
    action.getCluster().setId(GUIDS[1].toString());
    setUpGetEntityExpectations(StorageDomainType.ImportExport, STORAGE_DOMAIN_ID, true);
    try {
        resource.doImport(action);
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        verifyNotFoundException(wae);
    }
}
Also used : Action(org.ovirt.engine.api.model.Action) BackendStorageDomainVmsResourceTest.setUpStorageDomain(org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain) StorageDomain(org.ovirt.engine.api.model.StorageDomain) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 7 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendStorageDomainVmResourceTest method doTestImport.

public void doTestImport(StorageDomain storageDomain, org.ovirt.engine.api.model.Cluster cluster, boolean collapseSnapshots, boolean importAsNewEntity) throws Exception {
    setUpGetEntityExpectations(1, StorageDomainType.ImportExport, GUIDS[2]);
    UriInfo uriInfo = setUpActionExpectations(ActionType.ImportVm, ImportVmParameters.class, new String[] { "ContainerId", "StorageDomainId", "SourceDomainId", "DestDomainId", "StoragePoolId", "ClusterId", "CopyCollapse", "ImportAsNewEntity" }, new Object[] { VM_ID, GUIDS[2], STORAGE_DOMAIN_ID, GUIDS[2], DATA_CENTER_ID, GUIDS[1], collapseSnapshots, importAsNewEntity }, // valid,
    true, // success
    true, // taskReturn
    null, // baseUri
    null, // replay
    false);
    uriInfo = addMatrixParameterExpectations(uriInfo, BackendStorageDomainVmResource.COLLAPSE_SNAPSHOTS, Boolean.toString(collapseSnapshots));
    setUriInfo(uriInfo);
    Action action = new Action();
    action.setStorageDomain(storageDomain);
    action.setCluster(cluster);
    action.setClone(importAsNewEntity);
    verifyActionResponse(resource.doImport(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) UriInfo(javax.ws.rs.core.UriInfo)

Example 8 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendStepResourceTest method testEnd.

@Test
public void testEnd() throws Exception {
    setUriInfo(setUpActionExpectations(ActionType.EndExternalStep, EndExternalStepParameters.class, new String[] { "Id", "Status" }, new Object[] { GUIDS[0], true }, true, true));
    Action action = new Action();
    action.setSucceeded(true);
    verifyActionResponse(resource.end(action));
}
Also used : Action(org.ovirt.engine.api.model.Action) EndExternalStepParameters(org.ovirt.engine.core.common.action.EndExternalStepParameters) Test(org.junit.Test)

Example 9 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendStorageDomainDiskResourceTest method testIncompleteExport.

@Test
public void testIncompleteExport() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    try {
        resource.export(new Action());
        fail("expected WebApplicationException on incomplete parameters");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "Action", "export", "storageDomain.id|name");
    }
}
Also used : Action(org.ovirt.engine.api.model.Action) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 10 with Action

use of org.ovirt.engine.api.model.Action in project ovirt-engine by oVirt.

the class BackendStorageDomainImageResourceTest method testImport.

@Test
public void testImport() throws Exception {
    setUpEntityQueryExpectations(QueryType.GetStoragePoolsByStorageDomainId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { DESTINATION_DOMAIN_ID }, getStoragePoolList());
    setUriInfo(setUpActionExpectations(ActionType.ImportRepoImage, ImportRepoImageParameters.class, new String[] { "SourceRepoImageId", "SourceStorageDomainId", "StoragePoolId", "StorageDomainId" }, new Object[] { IMAGE_ID.toString(), DOMAIN_ID, STORAGE_POOL_ID, DESTINATION_DOMAIN_ID }, true, true, null, null, true));
    Action action = new Action();
    action.setStorageDomain(new StorageDomain());
    action.getStorageDomain().setId(DESTINATION_DOMAIN_ID.toString());
    verifyActionResponse(resource.doImport(action), "storagedomains/" + DOMAIN_ID + "/images/" + IMAGE_ID, false);
}
Also used : Action(org.ovirt.engine.api.model.Action) StorageDomain(org.ovirt.engine.api.model.StorageDomain) ImportRepoImageParameters(org.ovirt.engine.core.common.action.ImportRepoImageParameters) Test(org.junit.Test)

Aggregations

Action (org.ovirt.engine.api.model.Action)100 Test (org.junit.Test)70 WebApplicationException (javax.ws.rs.WebApplicationException)17 Response (javax.ws.rs.core.Response)17 StorageDomain (org.ovirt.engine.api.model.StorageDomain)14 Vm (org.ovirt.engine.api.model.Vm)9 AbstractBackendSubResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)9 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)7 RunVmOnceParams (org.ovirt.engine.core.common.action.RunVmOnceParams)6 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)5 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)5 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)4 ExportRepoImageParameters (org.ovirt.engine.core.common.action.ExportRepoImageParameters)4 VmOperationParameterBase (org.ovirt.engine.core.common.action.VmOperationParameterBase)4 UpdateVdsActionParameters (org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters)4 GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)3 Option (org.ovirt.engine.api.model.Option)3 BackendStorageDomainVmsResourceTest.setUpStorageDomain (org.ovirt.engine.api.restapi.resource.BackendStorageDomainVmsResourceTest.setUpStorageDomain)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 ArrayList (java.util.ArrayList)2