Martin Betak has uploaded a new change for review.

Change subject: restapi: Enable eject of cdrom via REST
......................................................................

restapi: Enable eject of cdrom via REST

Modified parameter validation to allow for files witout set id.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1135970
Change-Id: Ia11068f319bcb5cf0ff1facedd9cb99ce4c9e5d0
Signed-off-by: Martin Betak <[email protected]>
---
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomsResource.java
M 
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
2 files changed, 17 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/75/32375/1

diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomsResource.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomsResource.java
index 03112eb..13419ff 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomsResource.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendCdRomsResource.java
@@ -55,7 +55,7 @@
 
     @Override
     protected String[] getRequiredUpdateFields() {
-        return new String[] { "file.id" };
+        return new String[] { "file" };
     }
 
     @Override
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
index c79298f..9508119 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendCdRomResourceTest.java
@@ -32,6 +32,7 @@
 public class BackendCdRomResourceTest
         extends AbstractBackendSubResourceTest<CdRom, VM, 
BackendDeviceResource<CdRom, CdRoms, VM>> {
 
+    protected static final String EJECT_ISO = "";
     protected static BackendCdRomsResource collection = getCollection();
 
     public BackendCdRomResourceTest() {
@@ -147,18 +148,19 @@
     }
 
     @Test
-    public void testChangeCdIncompleteParameters() throws Exception {
-        setUriInfo(setUpBasicUriExpectations());
-        resource.setUriInfo(setUpBasicUriExpectations());
+    public void testEjectCd() throws Exception {
+        setUriInfo(setUpChangeCdUriMatrixExpectations());
+        setUpGetEntityExpectations(1, VMStatus.Up);
+        setUpActionExpectations(VdcActionType.ChangeDisk,
+                                ChangeDiskCommandParameters.class,
+                                new String[] {"CdImagePath"},
+                                new Object[] {EJECT_ISO},
+                                true,
+                                true);
         CdRom update = getUpdate();
-        update.getFile().setId(null);
-        control.replay();
-        try {
-            resource.update(update);
-            fail("expected WebApplicationException on incomplete parameters");
-        } catch (WebApplicationException wae) {
-             verifyIncompleteException(wae, "CdRom", "update", "file.id");
-        }
+        update.getFile().setId(EJECT_ISO);
+        CdRom cdrom = resource.update(update);
+        assertEquals(EJECT_ISO, cdrom.getFile().getId());
     }
 
     @Test
@@ -251,14 +253,14 @@
     @Test
     public void testUpdateIncompleteParameters() throws Exception {
         setUriInfo(setUpBasicUriExpectations());
-        CdRom update = getUpdate();
-        update.getFile().setId(null);
+        CdRom update = new CdRom();
+        update.setFile(null);
         control.replay();
         try {
             resource.update(update);
             fail("expected WebApplicationException on incomplete parameters");
         } catch (WebApplicationException wae) {
-             verifyIncompleteException(wae, "CdRom", "update", "file.id");
+             verifyIncompleteException(wae, "CdRom", "update", "file");
         }
     }
 


-- 
To view, visit http://gerrit.ovirt.org/32375
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia11068f319bcb5cf0ff1facedd9cb99ce4c9e5d0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Betak <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to