private static void verifyModelWithIso(Cdrom model, String isoPath) { assertEquals(Guid.Empty.toString(), model.getId()); assertTrue(model.isSetVm()); assertEquals(VM_ID.toString(), model.getVm().getId()); assertTrue(model.isSetFile()); assertEquals(isoPath, model.getFile().getId()); }
@Test public void testCdRomLinks() throws Exception { Cdrom cdrom = new Cdrom(); cdrom.setId(CDROM_ID); cdrom.setVm(new Vm()); cdrom.getVm().setId(VM_ID); LinkHelper.addLinks(cdrom); assertEquals(CDROM_HREF, cdrom.getHref()); }
@Test public void testAddIncompleteParameters() throws Exception { Cdrom model = new Cdrom(); model.setName(NAMES[0]); model.setFile(new File()); setUriInfo(setUpBasicUriExpectations()); try { collection.add(model); fail("expected WebApplicationException on incomplete parameters"); } catch (WebApplicationException wae) { verifyIncompleteException(wae, "Cdrom", "add", "file.id"); } }
@Override public Cdrom addParents(Cdrom entity) { Vm vm = new Vm(); vm.setId(vmId.toString()); entity.setVm(vm); return entity; }
@Override public Cdrom update(Cdrom cdrom) { validateParameters(cdrom, "file"); boolean current = ParametersHelper.getBooleanParameter(httpHeaders, uriInfo, CURRENT, true, false); if (current) { ChangeDiskCommandParameters parameters = new ChangeDiskCommandParameters(vmId, cdrom.getFile().getId()); performAction(VdcActionType.ChangeDisk, parameters); } else { VM vm = getVm(); vm = map(cdrom, vm); VmManagementParametersBase parameters = new VmManagementParametersBase(vm); performAction(VdcActionType.UpdateVm, parameters); } return get(); }
private Cdrom getCdrom() { Cdrom model = new Cdrom(); model.setFile(new File()); model.getFile().setId(ISO_PATH); return model; }