/** * assert that object is not null * * @param object the object to check * @throws WebApplicationException with status code 422 (Unprocessable Entity) */ public static void assertNotNull(final Object object) { RESTAssert.assertNotNull(object, RESTAssert.DEFAULT_STATUS_CODE); }
/** * assert that string matches the given pattern * * @param string the string to check * @param status the status code to throw * @throws WebApplicationException with given status code */ public static void assertPattern(String string, String pattern, final StatusType status) { RESTAssert.assertNotNull(string); RESTAssert.assertNotNull(pattern); RESTAssert.assertTrue(string.matches(pattern), status); }
/** * assert that collection has one element * * @param collection the collection to check * @param status the status code to throw * @throws WebApplicationException with given status code */ public static void assertSingleElement(final Collection<?> collection, final StatusType status) { RESTAssert.assertNotNull(collection, status); RESTAssert.assertTrue(collection.size() == 1, status); }
/** * assert that string is not null nor empty * * @param string the string to check * @param status the status code to throw * @throws WebApplicationException with given status code */ public static void assertNotEmpty(final String string, final StatusType status) { RESTAssert.assertNotNull(string, status); RESTAssert.assertFalse(string.isEmpty(), status); }
/** * assert that collection is not empty * * @param collection the collection to check * @param status the status code to throw * @throws WebApplicationException with given status code */ public static void assertNotEmpty(final Collection<?> collection, final StatusType status) { RESTAssert.assertNotNull(collection, status); RESTAssert.assertFalse(collection.isEmpty(), status); }
/** * assert that objects are equal.<br> * This means they are both <i>null</i> or <code>one.equals(two)</code> returns <i>true</i> * * @param one the first object * @param two the second object * @param status the status code to throw * @throws WebApplicationException with given status code */ @SuppressWarnings("null") public static void assertEquals(final Object one, final Object two, final StatusType status) { if ((one == null) && (two == null)) { return; } RESTAssert.assertNotNull(one, status); RESTAssert.assertTrue(one.equals(two), status); }
public static final UUID requestId() { final InvocationInstance ii = SecurityContextUtil.getContext().getContent(InvocationInstance.class); RESTAssert.assertNotNull(ii, Status.INTERNAL_SERVER_ERROR); return ii.getMessageId(); }
public static String requestId() { final InvocationInstance ii = SecurityContextUtil.getContext().getContent(InvocationInstance.class); RESTAssert.assertNotNull(ii, Status.INTERNAL_SERVER_ERROR); return ii.getMessageId(); }
@Override public String getRequestId() { final InvocationInstance ii = this.getMessageContext().getContent(InvocationInstance.class); RESTAssert.assertNotNull(ii, Response.Status.INTERNAL_SERVER_ERROR); return ii.getMessageId(); }