/** * returns if condition evaluates to true and throws {@link WebApplicationException}(422) if it evaluates to false * * @param condition the condition to assert * @throws WebApplicationException with status code 422 (Unprocessable Entity) if condition is <i>false</i> */ public static void assertTrue(final boolean condition) { RESTAssert.assertTrue(condition, RESTAssert.DEFAULT_STATUS_CODE); }
/** * fails every time; same as assertTrue(false) * * @throws WebApplicationException with status code 422 (Unprocessable Entity) */ public static void fail() { RESTAssert.fail(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); }
/** * 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 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 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 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); }
/** * returns if condition evaluates to true and throws {@link WebApplicationException} if it evaluates to false * * @param condition the condition to assert * @param status the status code to throw * @throws WebApplicationException with given status code if condition is <i>false</i> */ public static void assertTrue(final boolean condition, final StatusType status) { RESTAssert.assertFalse(!condition, status); }
/** * assert that string matches [+-]?[0-9]* * * @param string the string to check * @throws WebApplicationException with status code 422 (Unprocessable Entity) */ public static void assertInt(final String string) { RESTAssert.assertInt(string, RESTAssert.DEFAULT_STATUS_CODE); }
/** * assert that collection has one element * * @param collection the collection to check * @throws WebApplicationException with status code 422 (Unprocessable Entity) */ public static void assertSingleElement(final Collection<?> collection) { RESTAssert.assertSingleElement(collection, RESTAssert.DEFAULT_STATUS_CODE); }
/** * 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 * @throws WebApplicationException with status code 422 (Unprocessable Entity) */ public static void assertEquals(final Object one, final Object two) { RESTAssert.assertEquals(one, two, RESTAssert.DEFAULT_STATUS_CODE); }
/** * assert that string matches the given pattern * * @param string the string to check * @param pattern the pattern to check * @throws WebApplicationException with status code 422 (Unprocessable Entity) */ public static void assertPattern(String string, String pattern) { RESTAssert.assertPattern(string, pattern, 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 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); }
public static final UUID requestId() { final InvocationInstance ii = SecurityContextUtil.getContext().getContent(InvocationInstance.class); RESTAssert.assertNotNull(ii, Status.INTERNAL_SERVER_ERROR); return ii.getMessageId(); }
/** * 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 object is not null * * @param object the object to check * @param status the status code to throw * @throws WebApplicationException with given status code */ public static void assertNotNull(final Object object, final StatusType status) { RESTAssert.assertTrue(object != null, status); }
/** * returns if condition evaluates to false and throws {@link WebApplicationException} if it evaluates to true * * @param condition the condition to assert * @param status the status code to throw * @throws WebApplicationException with given status code if condition is <i>true</i> */ public static void assertFalse(final boolean condition, final StatusType status) { if (condition) { RESTAssert.fail(status); } }
/** * returns if condition evaluates to false and throws {@link WebApplicationException}(422) if it evaluates to true * * @param condition the condition to assert * @throws WebApplicationException with status code 422 (Unprocessable Entity) if condition is <i>true</i> */ public static void assertFalse(final boolean condition) { RESTAssert.assertFalse(condition, RESTAssert.DEFAULT_STATUS_CODE); }
/** * 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); }