org.omnaest.utils.assertion
Class Assert
java.lang.Object
org.omnaest.utils.assertion.Assert
public class Assert
- extends Object
The Assert class offers assert methods which throw RuntimeExceptions if constraints are not fulfilled.
Be aware of the special behavior regarding to String instances which are used to identify messages.
- Author:
- Omnaest
|
Method Summary |
static boolean |
areEqual(Object object1,
Object object2)
|
static boolean |
areEqual(Object object1,
Object object2,
String message)
|
static void |
fails()
|
static void |
fails(Exception cause)
|
static void |
fails(String message)
|
static void |
fails(String message,
Exception cause)
|
static boolean |
isFalse(boolean expression)
|
static boolean |
isFalse(boolean expression,
String message)
|
static boolean |
isInterimTimeLowerThan(int durationLimit,
TimeUnit timeUnit,
DurationCapture durationCapture,
Object[] intervalKeys)
Asserts that the DurationCapture.getInterimTimeInMilliseconds(Object...) is lower than the given duration limit for
the given TimeUnit and interval keys. |
static boolean |
isNotEmpty(Collection<?> collection)
|
static boolean |
isNotEmpty(Collection<?> collection,
String message)
|
static boolean |
isNotNull(Object object)
|
static boolean |
isNotNull(Object object,
Object... objects)
|
static boolean |
isNotNull(Object object,
String message)
Returns true if the given Object is not null, otherwise an IllegalArgumentException is thrown |
static boolean |
isNotNull(String message,
Object object1,
Object object2,
Object... objects)
|
static boolean |
isTrue(boolean... expressions)
|
static boolean |
isTrue(boolean expression)
|
static boolean |
isTrue(boolean expression,
String message)
|
static boolean |
isTrue(String message,
boolean... expressions)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Assert
public Assert()
fails
public static void fails()
- Throws:
Assert.FailedOperationException
fails
public static void fails(String message)
- Parameters:
message -
- Throws:
Assert.FailedOperationException
fails
public static void fails(String message,
Exception cause)
- Parameters:
message - cause -
- Throws:
Assert.FailedOperationException
fails
public static void fails(Exception cause)
- Parameters:
cause -
- Throws:
Assert.FailedOperationException
isNotNull
public static boolean isNotNull(Object object)
- Parameters:
object -
isNotNull
public static boolean isNotNull(Object object,
Object... objects)
- Parameters:
object - objects - - See Also:
isNotNull(Object)
isNotNull
public static boolean isNotNull(Object object,
String message)
- Returns true if the given
Object is not null, otherwise an IllegalArgumentException is thrown
- Parameters:
object - message -
- Throws:
IllegalArgumentException- See Also:
isNotNull(String, Object, Object, Object...)
isNotNull
public static boolean isNotNull(String message,
Object object1,
Object object2,
Object... objects)
- Parameters:
message - object1 - object2 - objects -
- Returns:
- See Also:
isNotNull(Object, String)
isTrue
public static boolean isTrue(boolean expression)
- Parameters:
expression -
isTrue
public static boolean isTrue(boolean... expressions)
- Parameters:
expressions -
isTrue
public static boolean isTrue(boolean expression,
String message)
- Parameters:
expression - message -
isTrue
public static boolean isTrue(String message,
boolean... expressions)
- Parameters:
message - expressions -
isFalse
public static boolean isFalse(boolean expression)
- Parameters:
expression -
isFalse
public static boolean isFalse(boolean expression,
String message)
- Parameters:
expression - message -
isNotEmpty
public static boolean isNotEmpty(Collection<?> collection)
- Parameters:
collection -
isNotEmpty
public static boolean isNotEmpty(Collection<?> collection,
String message)
- Parameters:
collection - message -
areEqual
public static boolean areEqual(Object object1,
Object object2)
- Parameters:
object1 - object2 -
areEqual
public static boolean areEqual(Object object1,
Object object2,
String message)
- Parameters:
object1 - object2 - message -
isInterimTimeLowerThan
public static boolean isInterimTimeLowerThan(int durationLimit,
TimeUnit timeUnit,
DurationCapture durationCapture,
Object[] intervalKeys)
- Asserts that the
DurationCapture.getInterimTimeInMilliseconds(Object...) is lower than the given duration limit for
the given TimeUnit and interval keys.
- Parameters:
durationLimit - timeUnit - TimeUnitdurationCapture - DurationCaptureintervalKeys -
- Returns:
- true if the assertion fulfilled the requirement
Copyright © 2013. All Rights Reserved.