Java Assert assertCheckStrAndQuery(String str, String query)

Here you can find the source of assertCheckStrAndQuery(String str, String query)

Description

Checks that str is not null, and query is not null, not empty, and is a single word.

License

Open Source License

Declaration

private static void assertCheckStrAndQuery(String str, String query) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    static final String QUERY_CANNOT_BE_EMPTY_MESSAGE = "query cannot be empty";
    static final String QUERY_LEN_SHOULD_BE_ONE_MESSAGE = "query parameter should be a single word";
    static final String QUERY_CANNOT_BE_NULL_MESSAGE = "query cannot be null";
    static final String STR_CANNOT_BE_NULL_MESSAGE = "str cannot be null";
    private static final String WHITESPACE_DELIMITER = "\\s+";

    /**//w  ww  .j  a  v a 2s  .co m
     * Checks that str is not null, and query is not null, not empty, and is a single word.
     */
    private static void assertCheckStrAndQuery(String str, String query) {
        assert str != null : STR_CANNOT_BE_NULL_MESSAGE;
        assert query != null : QUERY_CANNOT_BE_NULL_MESSAGE;
        assert !query.isEmpty() : QUERY_CANNOT_BE_EMPTY_MESSAGE;
        assert query.split(WHITESPACE_DELIMITER).length == 1 : QUERY_LEN_SHOULD_BE_ONE_MESSAGE;
    }
}

Related

  1. assertAssertionsEnabled()
  2. assertAttributeNameIsLegal(final String attributeName)
  3. assertBounds(final long reqOff, final long reqLen, final long allocSize)
  4. assertByThrowing(boolean condition, String errorMessage)
  5. assertCharactersNotInString(final String illegalChars, final char... chars)
  6. assertClassDoesNotExist(String className)
  7. assertClassExists(String className)
  8. assertColor(int color)
  9. assertComparison(T actual, T expected)