/** * assert that string is not null nor empty * * @param string the string to check * @throws WebApplicationException with status code 422 (Unprocessable Entity) */ public static void assertNotEmpty(final String string) { RESTAssert.assertNotEmpty(string, RESTAssert.DEFAULT_STATUS_CODE); }
/** * assert that collection is not empty * * @param collection the collection to check * @throws WebApplicationException with status code 422 (Unprocessable Entity) */ public static void assertNotEmpty(final Collection<?> collection) { RESTAssert.assertNotEmpty(collection, RESTAssert.DEFAULT_STATUS_CODE); }
/** * assert that string matches [+-]?[0-9]* * * @param string the string to check * @param status the status code to throw * @throws WebApplicationException with given status code */ public static void assertInt(final String string, final StatusType status) { RESTAssert.assertNotEmpty(string); RESTAssert.assertPattern(string, "[+-]?[0-9]*", status); }
@POST public Response createTicket(T ticket) { RESTAssert.assertNotEmpty(ticket.getRequesterMail()); RESTAssert.assertNotEmpty(ticket.getRequesterMail()); RESTAssert.assertNotEmpty(ticket.getSubject()); RESTAssert.assertNotEmpty(ticket.getBody()); Ticket tick = new Ticket(); tick.setRequesterName(ticket.getRequesterName()); tick.setRequesterEMail(ticket.getRequesterMail()); tick.setSubject(ticket.getSubject()); tick.setComment(ticket.getBody()); this.customConversion(tick, ticket); this.createTicket(tick); return Response.accepted().build(); }