public class

AssertModule

extends Object
java.lang.Object
   ↳ org.mule.munit.AssertModule
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Module for asserting in Munit tests.

Summary

Fields
private Queue<Object> expectedPayload
Public Constructors
AssertModule()
Public Methods
void addExpected(Object value)

Assert module keeps a queue of expected payloads, so you can call assertNotSame and assertOnEquals

inside a inbound flow you created for your tests.

void assertFalse(String message, Boolean condition)

Check if an expression is false.

void assertNotNull(String message, Object payload)

Assert for a Not Null payload.

void assertNotSame(String message, Object expected, Object value)
Assert two objects are not equal
void assertNull(String message, Object payload)

Assert Null Payload.

void assertOnEquals(String message, Object expected, Object value)

Check that two objects are equal.

void assertThat(String message, Object payloadIs, Object payload)

Assert that the payload is equal to an expected value.

void assertTrue(String message, Boolean condition)

Assert for a true expression.

void fail(String message)

Fail assertion.

void resetCalls()

Resets the module

Object set(Object payload)

Defines the payload for testing.

NullPayload setNullPayload()

Defines a Null payload for testing.

void validateCalls()

Checks that all the expected calls to assert has been done

[Expand]
Inherited Methods
From class java.lang.Object

Fields

private Queue<Object> expectedPayload

Public Constructors

public AssertModule ()

Public Methods

public void addExpected (Object value)

Assert module keeps a queue of expected payloads, so you can call assertNotSame and assertOnEquals

inside a inbound flow you created for your tests. The expected payload is taken from the peek of the queue

Parameters
value Description message to be shown in case of failure.

public void assertFalse (String message, Boolean condition)

Check if an expression is false.

Parameters
message Description message to be shown in case of failure.
condition Boolean expression

public void assertNotNull (String message, Object payload)

Assert for a Not Null payload.

Parameters
message Description message to be shown in case of failure.
payload Payload

public void assertNotSame (String message, Object expected, Object value)

Assert two objects are not equal

Parameters
message Description message
expected Expected value. If not provided the expected value is taken from the expected value Queue.
value Real value

public void assertNull (String message, Object payload)

Assert Null Payload.

Parameters
message Description message to be shown in case of failure.
payload Payload

public void assertOnEquals (String message, Object expected, Object value)

Check that two objects are equal.

Parameters
message Description message to be shown in case of failure.
expected Expected value. If not provided the expected value is taken from the expected value Queue.
value Real value

public void assertThat (String message, Object payloadIs, Object payload)

Assert that the payload is equal to an expected value.

The payloadIs-ref can be any Object/expression.

The assertion Fails if the payload is not equal to the payloadIs-ref

Parameters
message Description message to be shown in case of failure.
payloadIs Expected Value
payload Payload

public void assertTrue (String message, Boolean condition)

Assert for a true expression.

Parameters
message Description message to be shown in case of failure.
condition Boolean expression

public void fail (String message)

Fail assertion.

Parameters
message Description message to be shown in case of failure.

public void resetCalls ()

Resets the module

public Object set (Object payload)

Defines the payload for testing.

Parameters
payload Payload
Returns
  • The testing payload

public NullPayload setNullPayload ()

Defines a Null payload for testing.

Returns
  • Null payload

public void validateCalls ()

Checks that all the expected calls to assert has been done