Class Assert
The Assert class provides utility methods for assertion events.
Constructor Summary
This class does not have a constructor, so you cannot create it directly.
Method Summary
| Method | Description |
|---|
| static areEqual(Object, Object) | Propagates an assertion if the specified objects are not equal. |
| static areEqual(Object, Object, String) | Propagates an assertion using the specified message if the specified objects are not equal. |
| static areNotEqual(Object, Object) | Propagates an assertion if the specified objects are equal. |
| static areNotEqual(Object, Object, String) | Propagates an assertion using the specified message if the specified objects are equal. |
| static areSame(Object, Object) | Propagates an assertion if the specified objects are not the same. |
| static areSame(Object, Object, String) | Propagates an assertion using the specified message if the specified objects are not the same. |
| static fail() | Propagates a failure assertion. |
| static fail(String) | Propagates a failure assertion using the specified message. |
| static isEmpty(Object) | Propagates an assertion if the specified check does not evaluate to an empty object. |
| static isEmpty(Object, String) | Propagates an assertion using the specified message if the specified check does not evaluate to an empty object. |
| static isFalse(Boolean) | Propagates an assertion if the specified check does not evaluate to false. |
| static isFalse(Boolean, String) | Propagates an assertion using the specified message if the specified check does not evaluate to false. |
| static isInstanceOf(Object, Object) | Propagates an assertion if the specified object ‘arg’ is not an instance of the specified class ‘clazz’. |
| static isInstanceOf(Object, Object, String) | Propagates an assertion using the specified message if the specified object is not an instance of the specified class. |
| static isNotEmpty(Object) | Propagates an assertion if the specified object is empty. |
| static isNotEmpty(Object, String) | Propagates an assertion using the specified message if the specified object is empty. |
| static isNotNull(Object) | Propagates an assertion if the specified object is null. |
| static isNotNull(Object, String) | Propagates an assertion using the specified message if the specified object is null. |
| static isNull(Object) | Propagates an assertion if the specified object is not null. |
| static isNull(Object, String) | Propagates an assertion using the specified message if the specified object is not null. |
| static isTrue(Boolean) | Propagates an assertion if the specified check does not evaluate to true. |
| static isTrue(Boolean, String) | Propagates an assertion using the specified message if the specified check does not evaluate to true. |
Methods inherited from class Object
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
Method Details
areEqual(Object, Object)
- static areEqual(arg1: Object, arg2: Object): void
Propagates an assertion
if the specified objects are not equal.
Parameters:
- arg1 - the first object to check.
- arg2 - the second object to check.
areEqual(Object, Object, String)
- static areEqual(arg1: Object, arg2: Object, msg: String): void
Propagates an assertion using the specified message
if the specified objects are not equal.
Parameters:
- arg1 - the first object to check.
- arg2 - the second object to check.
- msg - the assertion message.
areNotEqual(Object, Object)
- static areNotEqual(arg1: Object, arg2: Object): void
Propagates an assertion
if the specified objects are equal.
Parameters:
- arg1 - the first object to check.
- arg2 - the second object to check.
areNotEqual(Object, Object, String)
- static areNotEqual(arg1: Object, arg2: Object, msg: String): void
Propagates an assertion using the specified message
if the specified objects are equal.
Parameters:
- arg1 - the first object to check.
- arg2 - the second object to check.
- msg - the assertion message.
areSame(Object, Object)
- static areSame(arg1: Object, arg2: Object): void
Propagates an assertion
if the specified objects are not the same.
Parameters:
- arg1 - the first object to check.
- arg2 - the second object to check.
areSame(Object, Object, String)
- static areSame(arg1: Object, arg2: Object, msg: String): void
Propagates an assertion using the specified message
if the specified objects are not the same.
Parameters:
- arg1 - the first object to check.
- arg2 - the second object to check.
- msg - the assertion message.
fail()
- static fail(): void
Propagates a failure assertion.
fail(String)
- static fail(msg: String): void
Propagates a failure assertion using the
specified message.
Parameters:
- msg - the assertion message.
isEmpty(Object)
- static isEmpty(arg: Object): void
Propagates an assertion
if the specified check does not evaluate to
an empty object.
Parameters:
- arg - the object to check.
isEmpty(Object, String)
- static isEmpty(arg: Object, msg: String): void
Propagates an assertion using the specified message
if the specified check does not evaluate to
an empty object.
Parameters:
- arg - the object to check.
- msg - the assertion message.
isFalse(Boolean)
- static isFalse(check: Boolean): void
Propagates an assertion if the
specified check does not evaluate to false.
Parameters:
- check - the condition to check.
isFalse(Boolean, String)
- static isFalse(check: Boolean, msg: String): void
Propagates an assertion using the specified message
if the specified check does not evaluate to false.
Parameters:
- check - the condition to check.
- msg - the assertion message.
isInstanceOf(Object, Object)
- static isInstanceOf(clazz: Object, arg: Object): void
Propagates an assertion if the specified object 'arg' is not an instance
of the specified class 'clazz'.
For example, the following call does not propagate an assertion:
1var test = new dw.util.HashMap();
2 dw.util.Assert.isInstanceOf(dw.util.HashMap, test);
But the following call will propagate an assertion:
1var test = new dw.util.Set();
2 dw.util.Assert.isInstanceOf(dw.util.HashMap, test);
Note that 'clazz' can only be a Demandware API Scripting class.
Parameters:
- clazz - the scripting class to use to check the object.
- arg - the object to check.
isInstanceOf(Object, Object, String)
- static isInstanceOf(clazz: Object, arg: Object, msg: String): void
Propagates an assertion using the specified message
if the specified object is not an instance of the specified class.
For example, the following call does not propagate an assertion:
1var test = new dw.util.HashMap();
2 dw.util.Assert.isInstanceOf(dw.util.HashMap, test);
But the following call will propagate an assertion:
1var test = new dw.util.Set();
2 dw.util.Assert.isInstanceOf(dw.util.HashMap, test);
Note that 'clazz' can only be a Demandware API Scripting class.
Parameters:
- clazz - the scripting class to use to check the object.
- arg - the object to check.
- msg - the assertion message.
isNotEmpty(Object)
- static isNotEmpty(arg: Object): void
Propagates an assertion
if the specified object is empty.
Parameters:
- arg - the object to check.
isNotEmpty(Object, String)
- static isNotEmpty(arg: Object, msg: String): void
Propagates an assertion using the specified message
if the specified object is empty.
Parameters:
- arg - the object to check.
- msg - the assertion message.
isNotNull(Object)
- static isNotNull(arg: Object): void
Propagates an assertion if the
specified object is null.
Parameters:
- arg - the object to check.
isNotNull(Object, String)
- static isNotNull(arg: Object, msg: String): void
Propagates an assertion using the specified message
if the specified object is null.
Parameters:
- arg - the object to check.
- msg - the assertion message.
isNull(Object)
- static isNull(arg: Object): void
Propagates an assertion
if the specified object is not null.
Parameters:
- arg - the object to check.
isNull(Object, String)
- static isNull(arg: Object, msg: String): void
Propagates an assertion using the specified message
if the specified object is not null.
Parameters:
- arg - the object to check.
- msg - the assertion message.
isTrue(Boolean)
- static isTrue(check: Boolean): void
Propagates an assertion if the
specified check does not evaluate to true.
Parameters:
- check - the condition to check.
isTrue(Boolean, String)
- static isTrue(check: Boolean, msg: String): void
Propagates an assertion using the specified message
if the specified check does not evaluate to true.
Parameters:
- check - the condition to check.
- msg - the assertion message.