congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
RESTAssert
Code IndexAdd Tabnine to your IDE (free)

How to use
RESTAssert
in
de.taimos.restutils

Best Java code snippets using de.taimos.restutils.RESTAssert (Showing top 20 results out of 315)

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/spring-cxf-daemon

public static final UUID requestId() {
  final InvocationInstance ii = SecurityContextUtil.getContext().getContent(InvocationInstance.class);
  RESTAssert.assertNotNull(ii, Status.INTERNAL_SERVER_ERROR);
  return ii.getMessageId();
}

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/restutils

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

origin: de.taimos/dvalin-jaxrs

@Override
public String getRequestId() {
  final InvocationInstance ii = this.getMessageContext().getContent(InvocationInstance.class);
  RESTAssert.assertNotNull(ii, Response.Status.INTERNAL_SERVER_ERROR);
  return ii.getMessageId();
}
de.taimos.restutilsRESTAssert

Javadoc

Use this class to assert preconditions in REST Handler

assert methods throw WebApplicationException on failure

Most used methods

  • assertNotNull
    assert that object is not null
  • assertNotEmpty
    assert that collection is not empty
  • assertEquals
    assert that objects are equal. This means they are both null or one.equals(two) returns true
  • assertFalse
    returns if condition evaluates to false and throws WebApplicationException if it evaluates to true
  • assertInt
    assert that string matches [+-]?[0-9]
  • assertPattern
    assert that string matches the given pattern
  • assertSingleElement
    assert that collection has one element
  • assertTrue
    returns if condition evaluates to true and throws WebApplicationException if it evaluates to false
  • fail
    fails every time; same as assertTrue(false)

Popular in Java

  • Reading from database using SQL prepared statement
  • getContentResolver (Context)
  • runOnUiThread (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now