/** * 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); }
/** * 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); }
/** * 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 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); }
/** * 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); }