@Override public V3Bookmark adapt(Bookmark from) { V3Bookmark to = new V3Bookmark(); if (from.isSetLinks()) { to.getLinks().addAll(adaptOut(from.getLinks())); } if (from.isSetActions()) { to.setActions(adaptOut(from.getActions())); } if (from.isSetComment()) { to.setComment(from.getComment()); } if (from.isSetDescription()) { to.setDescription(from.getDescription()); } if (from.isSetId()) { to.setId(from.getId()); } if (from.isSetHref()) { to.setHref(from.getHref()); } if (from.isSetName()) { to.setName(from.getName()); } if (from.isSetValue()) { to.setValue(from.getValue()); } return to; } }
public static void validateAdd(Bookmark bookmark) { if (bookmark == null) { throw new ValidationException("Parameter 'bookmark' is mandatory but was not provided."); } if (bookmark.getName()==null) { throw new ValidationException("Parameter 'bookmark.name' is mandatory but was not provided."); } if (bookmark.getValue()==null) { throw new ValidationException("Parameter 'bookmark.value' is mandatory but was not provided."); } }
/** * Map the generated REST bookmark model to the business entity bookmark model. * @param model The REST bookmark model * @param template The business entity bookmark model template. * @return A business entity bookmark model filled from the REST model. */ @Mapping(from = Bookmark.class, to = org.ovirt.engine.core.common.businessentities.Bookmark.class) public static org.ovirt.engine.core.common.businessentities.Bookmark map(Bookmark model, org.ovirt.engine.core.common.businessentities.Bookmark template) { org.ovirt.engine.core.common.businessentities.Bookmark entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.Bookmark(); if (model.isSetId()) { entity.setId(GuidUtils.asGuid(model.getId())); } if (model.isSetValue()) { entity.setValue(model.getValue()); } if (model.isSetName()) { entity.setName(model.getName()); } return entity; }
@Override public Bookmark adapt(V3Bookmark from) { Bookmark to = new Bookmark(); if (from.isSetLinks()) { to.getLinks().addAll(adaptIn(from.getLinks())); to.setActions(adaptIn(from.getActions())); to.setComment(from.getComment()); to.setDescription(from.getDescription()); to.setId(from.getId()); to.setHref(from.getHref()); to.setHref(from.getHref()); to.setName(from.getName()); to.setValue(from.getValue());
@Override public Response add(Bookmark bookmark) { validateParameters(bookmark, "name"); validateParameters(bookmark, "value"); return performCreate(ActionType.AddBookmark, new BookmarksOperationParameters(map(bookmark)), new BookmarkNameResolver(bookmark.getName())); }
/** * Create an instance of {@link Bookmark } * */ public Bookmark createBookmark() { return new Bookmark(); }
@Test public void testAddIncompleteParameters() { setUriInfo(setUpBasicUriExpectations()); verifyIncompleteException( assertThrows(WebApplicationException.class, () -> collection.add(new Bookmark())), "Bookmark", "add", "name"); }
/** * Map a business entity bookmark model to a generated REST bookmark model. * @param entity The business entity bookmark model. * @param template The REST bookmark model template to use. * @return A REST bookmark model filled from the business entity. */ @Mapping(from = org.ovirt.engine.core.common.businessentities.Bookmark.class, to = Bookmark.class) public static Bookmark map(org.ovirt.engine.core.common.businessentities.Bookmark entity, Bookmark template) { Bookmark model = template != null ? template : new Bookmark(); model.setId(entity.getId().toString()); model.setName(entity.getName()); model.setValue(entity.getValue()); return model; } }