/** * Bi-directional Cdrom->VmTemplate not required as * template device collections are always read-only */ @Mapping(from = VmTemplate.class, to = Cdrom.class) public static Cdrom map(VmTemplate entity, Cdrom template) { Cdrom model = template != null ? template : new Cdrom(); model.setId(CDROM_ID.toString()); if (!StringUtils.isEmpty(entity.getIsoPath())) { model.setFile(new File()); model.getFile().setId(entity.getIsoPath()); } return model; } }
@Mapping(from = VM.class, to = Cdrom.class) public static Cdrom map(VM entity, Cdrom template) { Cdrom model = template != null ? template : new Cdrom(); model.setId(CDROM_ID.toString()); if (!StringUtils.isEmpty(entity.getStaticData().getIsoPath())) { model.setFile(new File()); model.getFile().setId(entity.getStaticData().getIsoPath()); } return model; }
private Cdrom getCdrom(String path) { Cdrom cdrom = new Cdrom(); cdrom.setFile(new File()); cdrom.getFile().setId(path); return cdrom; }
private Cdrom getCdrom() { Cdrom model = new Cdrom(); model.setFile(new File()); model.getFile().setId(ISO_PATH); return model; }
@Test public void testUpdateIncompleteParameters() { setUriInfo(setUpBasicUriExpectations()); Cdrom cdrom = new Cdrom(); cdrom.setFile(null); verifyIncompleteException( assertThrows(WebApplicationException.class, () -> resource.update(cdrom)), "Cdrom", "update", "file"); }
@Test public void testAddIncompleteParameters() { Cdrom model = new Cdrom(); model.setName(NAMES[0]); model.setFile(new File()); setUriInfo(setUpBasicUriExpectations()); verifyIncompleteException( assertThrows(WebApplicationException.class, () -> collection.add(model)), "Cdrom", "add", "file.id"); }
@Test public void testStartWithCdRomAndFloppy() { setUpWindowsGetEntityExpectations(1, false); setUriInfo(setUpActionExpectations(ActionType.RunVmOnce, RunVmOnceParams.class, new String[] { "VmId", "DiskPath", "FloppyPath" }, new Object[] { GUIDS[0], ISO_ID, FLOPPY_ID })); Action action = new Action(); action.setVm(new Vm()); action.getVm().setCdroms(new Cdroms()); action.getVm().getCdroms().getCdroms().add(new Cdrom()); action.getVm().getCdroms().getCdroms().get(0).setFile(new File()); action.getVm().getCdroms().getCdroms().get(0).getFile().setId(ISO_ID); action.getVm().setFloppies(new Floppies()); action.getVm().getFloppies().getFloppies().add(new Floppy()); action.getVm().getFloppies().getFloppies().get(0).setFile(new File()); action.getVm().getFloppies().getFloppies().get(0).getFile().setId(FLOPPY_ID); verifyActionResponse(resource.start(action)); }
to.setFile(adaptIn(from.getFile()));