Hello Federico Simoncelli, I'd like you to do a code review. Please visit
http://gerrit.ovirt.org/19357 to review the following change. Change subject: restapi: Fix botches merge ...................................................................... restapi: Fix botches merge Reintroduced acked changes to test files that were mistakenly removed in a bad merge of If351d209d7828f0d59926bb98da9317567976d41. Relates-To: https://bugzilla.redhat.com/show_bug.cgi?id=990962 Signed-off-by: Federico Simoncelli <fsimo...@redhat.com> Signed-off-by: Allon Mureinik <amure...@redhat.com> Change-Id: Ia5667a149b7ad832aab6457cb333fa781952c411 --- M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendDiskResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainDiskResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateDiskResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmDiskResourceTest.java 4 files changed, 119 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/57/19357/1 diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendDiskResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendDiskResourceTest.java index c57e4d7..2a95cb8 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendDiskResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendDiskResourceTest.java @@ -18,6 +18,7 @@ import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.compat.Guid; +import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; @@ -65,6 +66,29 @@ verifyActionResponse(r, "/disks/" + PARENT_ID, false); } + @Test + public void testBadGuid() throws Exception { + control.replay(); + try { + new BackendStorageDomainVmResource(null, "foo"); + fail("expected WebApplicationException"); + } catch (WebApplicationException wae) { + verifyNotFoundException(wae); + } + } + + @Test + public void testIncompleteExport() throws Exception { + setUriInfo(setUpBasicUriExpectations()); + try { + control.replay(); + resource.doExport(new Action()); + fail("expected WebApplicationException on incomplete parameters"); + } catch (WebApplicationException wae) { + verifyIncompleteException(wae, "Action", "doExport", "storageDomain.id|name"); + } + } + @Override protected org.ovirt.engine.core.common.businessentities.Disk getEntity(int index) { DiskImage entity = new DiskImage(); diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainDiskResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainDiskResourceTest.java index b8a3498..822ee5e 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainDiskResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStorageDomainDiskResourceTest.java @@ -1,11 +1,18 @@ package org.ovirt.engine.api.restapi.resource; +import static org.ovirt.engine.api.restapi.resource.AbstractBackendDisksResourceTest.PARENT_ID; + import java.util.ArrayList; import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; import org.junit.Test; +import org.ovirt.engine.api.model.Action; import org.ovirt.engine.api.model.Disk; +import org.ovirt.engine.api.model.StorageDomain; +import org.ovirt.engine.core.common.action.ExportRepoImageParameters; +import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.DiskInterface; import org.ovirt.engine.core.common.businessentities.ImageStatus; @@ -15,6 +22,7 @@ import org.ovirt.engine.core.common.queries.IdQueryParameters; import org.ovirt.engine.core.common.queries.VdcQueryType; import org.ovirt.engine.core.compat.Guid; + public class BackendStorageDomainDiskResourceTest extends AbstractBackendSubResourceTest<Disk, org.ovirt.engine.core.common.businessentities.Disk, BackendDiskResource> { @@ -60,6 +68,47 @@ } } + @Test + public void testExport() throws Exception { + setUriInfo(setUpActionExpectations(VdcActionType.ExportRepoImage, + ExportRepoImageParameters.class, + new String[]{"ImageGroupID", "DestinationDomainId"}, + new Object[]{DISK_ID, GUIDS[3]}, true, true, null, null, true)); + + Action action = new Action(); + action.setStorageDomain(new StorageDomain()); + action.getStorageDomain().setId(GUIDS[3].toString()); + + verifyActionResponse(resource.doExport(action)); + } + + private void verifyActionResponse(Response r) throws Exception { + verifyActionResponse(r, "/disks/" + PARENT_ID, false); + } + + @Test + public void testBadGuid() throws Exception { + control.replay(); + try { + new BackendStorageDomainVmResource(null, "foo"); + fail("expected WebApplicationException"); + } catch (WebApplicationException wae) { + verifyNotFoundException(wae); + } + } + + @Test + public void testIncompleteExport() throws Exception { + setUriInfo(setUpBasicUriExpectations()); + try { + control.replay(); + resource.doExport(new Action()); + fail("expected WebApplicationException on incomplete parameters"); + } catch (WebApplicationException wae) { + verifyIncompleteException(wae, "Action", "doExport", "storageDomain.id|name"); + } + } + @Override protected org.ovirt.engine.core.common.businessentities.Disk getEntity(int index) { return getEntity(index, false); diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateDiskResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateDiskResourceTest.java index 19a7491..0a4688e 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateDiskResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateDiskResourceTest.java @@ -120,6 +120,29 @@ } @Test + public void testBadGuid() throws Exception { + control.replay(); + try { + new BackendStorageDomainVmResource(null, "foo"); + fail("expected WebApplicationException"); + } catch (WebApplicationException wae) { + verifyNotFoundException(wae); + } + } + + @Test + public void testIncompleteExport() throws Exception { + setUriInfo(setUpBasicUriExpectations()); + try { + control.replay(); + resource.doExport(new Action()); + fail("expected WebApplicationException on incomplete parameters"); + } catch (WebApplicationException wae) { + verifyIncompleteException(wae, "Action", "doExport", "storageDomain.id|name"); + } + } + + @Test public void testCopyBySdId() throws Exception { setUpEntityQueryExpectations(VdcQueryType.GetDiskByDiskId, IdQueryParameters.class, diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmDiskResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmDiskResourceTest.java index eaa4607..92e65a6 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmDiskResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmDiskResourceTest.java @@ -190,6 +190,29 @@ verifyActionResponse(resource.doExport(action)); } + @Test + public void testBadGuid() throws Exception { + control.replay(); + try { + new BackendStorageDomainVmResource(null, "foo"); + fail("expected WebApplicationException"); + } catch (WebApplicationException wae) { + verifyNotFoundException(wae); + } + } + + @Test + public void testIncompleteExport() throws Exception { + setUriInfo(setUpBasicUriExpectations()); + try { + control.replay(); + resource.doExport(new Action()); + fail("expected WebApplicationException on incomplete parameters"); + } catch (WebApplicationException wae) { + verifyIncompleteException(wae, "Action", "doExport", "storageDomain.id|name"); + } + } + protected DiskImage setUpStatisticalExpectations() throws Exception { DiskImage entity = control.createMock(DiskImage.class); expect(entity.getId()).andReturn(DISK_ID).anyTimes(); -- To view, visit http://gerrit.ovirt.org/19357 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia5667a149b7ad832aab6457cb333fa781952c411 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <amure...@redhat.com> Gerrit-Reviewer: Federico Simoncelli <fsimo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches