Class List Method List File List

# Class: VertxUnit::TestContext

Inherits:
  Object
  - Object
  - VertxUnit::TestContext
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb

## Overview

The test context is used for performing test assertions and manage the completion of the test. This context is provided by vertx-unit as argument of the test case.

## Instance Method Summary (collapse)

- - (self) assert_equals(expected = nil, actual = nil, message = nil)
  Assert the expected argument is equals to the actual argument.
- - (self) assert_false(condition = nil, message = nil)
  Assert the specified condition is false.
- - (self) assert_in_range(expected = nil, actual = nil, delta = nil, message = nil)
  Asserts that the expected double argument is equals to the actual double argument within a positive delta.
- - (self) assert_not_equals(first = nil, second = nil, message = nil)
  Assert the first argument is not equals to the second argument.
- - (self) assert_not_null(expected = nil, message = nil)
  Assert the expected argument is not null.
- - (self) assert_null(expected = nil, message = nil)
  Assert the expected argument is null.
- - (self) assert_true(condition = nil, message = nil)
  Assert the specified condition is true.
- - (::VertxUnit::Async) async
  Create and returns a new async object, the returned async controls the completion of the test.
- - (void) fail(param_1 = nil)
  Throw a failure with the specified failure cause.
- - (Object) get(key = nil)
  Get some data from the context.
- - (Object) put(key = nil, value = nil)
  Put some data in the context.
- - (Object) remove(key = nil)
  Remove some data from the context.

## Instance Method Details

### - (`self`) assert_equals(expected = nil, actual = nil, message = nil)

Assert the `expected` argument is equals to the `actual` argument. If the arguments are not equals an assertion error is thrown otherwise the execution continue.

Parameters:

- expected (`Object`) (defaults to: `nil`) —
  the object the actual object is supposedly equals to
- actual (`Object`) (defaults to: `nil`) —
  the actual object to test
- message (`String`) (defaults to: `nil`) —
  the failure message

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 114

    def assert_equals(expected=nil,actual=nil,message=nil)
      if (expected.class == String  || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && (actual.class == String  || actual.class == Hash || actual.class == Array || actual.class == NilClass || actual.class == TrueClass || actual.class == FalseClass || actual.class == Fixnum || actual.class == Float) && !block_given? && message == nil
        @j_del.java_method(:assertEquals, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(expected),::Vertx::Util::Utils.to_object(actual))
        return self
      elsif (expected.class == String  || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && (actual.class == String  || actual.class == Hash || actual.class == Array || actual.class == NilClass || actual.class == TrueClass || actual.class == FalseClass || actual.class == Fixnum || actual.class == Float) && message.class == String && !block_given?
        @j_del.java_method(:assertEquals, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_object(expected),::Vertx::Util::Utils.to_object(actual),message)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling assert_equals(expected,actual,message)"
    end

### - (`self`) assert_false(condition = nil, message = nil)

Assert the specified `condition` is `false`. If the condition is `true`, an assertion error is thrown otherwise the execution continue.

Parameters:

- condition (`true`, `false`) (defaults to: `nil`) —
  the condition to assert
- message (`String`) (defaults to: `nil`) —
  the failure message

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 98

    def assert_false(condition=nil,message=nil)
      if (condition.class == TrueClass || condition.class == FalseClass) && !block_given? && message == nil
        @j_del.java_method(:assertFalse, [Java::boolean.java_class]).call(condition)
        return self
      elsif (condition.class == TrueClass || condition.class == FalseClass) && message.class == String && !block_given?
        @j_del.java_method(:assertFalse, [Java::boolean.java_class,Java::java.lang.String.java_class]).call(condition,message)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling assert_false(condition,message)"
    end

### - (`self`) assert_in_range(expected = nil, actual = nil, delta = nil, message = nil)

Asserts that the `expected` double argument is equals to the `actual` double argument within a positive delta. If the arguments do not satisfy this, an assertion error is thrown otherwise the execution continue.

Parameters:

- expected (`Float`) (defaults to: `nil`) —
  the object the actual object is supposedly equals to
- actual (`Float`) (defaults to: `nil`) —
  the actual object to test
- delta (`Float`) (defaults to: `nil`) —
  the maximum delta
- message (`String`) (defaults to: `nil`) —
  the failure message

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 132

    def assert_in_range(expected=nil,actual=nil,delta=nil,message=nil)
      if expected.class == Float && actual.class == Float && delta.class == Float && !block_given? && message == nil
        @j_del.java_method(:assertInRange, [Java::double.java_class,Java::double.java_class,Java::double.java_class]).call(::Vertx::Util::Utils.to_double(expected),::Vertx::Util::Utils.to_double(actual),::Vertx::Util::Utils.to_double(delta))
        return self
      elsif expected.class == Float && actual.class == Float && delta.class == Float && message.class == String && !block_given?
        @j_del.java_method(:assertInRange, [Java::double.java_class,Java::double.java_class,Java::double.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_double(expected),::Vertx::Util::Utils.to_double(actual),::Vertx::Util::Utils.to_double(delta),message)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling assert_in_range(expected,actual,delta,message)"
    end

### - (`self`) assert_not_equals(first = nil, second = nil, message = nil)

Assert the `first` argument is not equals to the `second` argument. If the arguments are equals an assertion error is thrown otherwise the execution continue.

Parameters:

- first (`Object`) (defaults to: `nil`) —
  the first object to test
- second (`Object`) (defaults to: `nil`) —
  the second object to test
- message (`String`) (defaults to: `nil`) —
  the failure message

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 148

    def assert_not_equals(first=nil,second=nil,message=nil)
      if (first.class == String  || first.class == Hash || first.class == Array || first.class == NilClass || first.class == TrueClass || first.class == FalseClass || first.class == Fixnum || first.class == Float) && (second.class == String  || second.class == Hash || second.class == Array || second.class == NilClass || second.class == TrueClass || second.class == FalseClass || second.class == Fixnum || second.class == Float) && !block_given? && message == nil
        @j_del.java_method(:assertNotEquals, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(first),::Vertx::Util::Utils.to_object(second))
        return self
      elsif (first.class == String  || first.class == Hash || first.class == Array || first.class == NilClass || first.class == TrueClass || first.class == FalseClass || first.class == Fixnum || first.class == Float) && (second.class == String  || second.class == Hash || second.class == Array || second.class == NilClass || second.class == TrueClass || second.class == FalseClass || second.class == Fixnum || second.class == Float) && message.class == String && !block_given?
        @j_del.java_method(:assertNotEquals, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_object(first),::Vertx::Util::Utils.to_object(second),message)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling assert_not_equals(first,second,message)"
    end

### - (`self`) assert_not_null(expected = nil, message = nil)

Assert the `expected` argument is not `null`. If the argument is `null`, an assertion error is thrown otherwise the execution continue.

Parameters:

- expected (`Object`) (defaults to: `nil`) —
  the argument being asserted to be not null
- message (`String`) (defaults to: `nil`) —
  the failure message

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 68

    def assert_not_null(expected=nil,message=nil)
      if (expected.class == String  || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && !block_given? && message == nil
        @j_del.java_method(:assertNotNull, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(expected))
        return self
      elsif (expected.class == String  || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && message.class == String && !block_given?
        @j_del.java_method(:assertNotNull, [Java::java.lang.Object.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_object(expected),message)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling assert_not_null(expected,message)"
    end

### - (`self`) assert_null(expected = nil, message = nil)

Assert the `expected` argument is `null`. If the argument is not, an assertion error is thrown otherwise the execution continue.

Parameters:

- expected (`Object`) (defaults to: `nil`) —
  the argument being asserted to be null
- message (`String`) (defaults to: `nil`) —
  the failure message

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 53

    def assert_null(expected=nil,message=nil)
      if (expected.class == String  || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && !block_given? && message == nil
        @j_del.java_method(:assertNull, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(expected))
        return self
      elsif (expected.class == String  || expected.class == Hash || expected.class == Array || expected.class == NilClass || expected.class == TrueClass || expected.class == FalseClass || expected.class == Fixnum || expected.class == Float) && message.class == String && !block_given?
        @j_del.java_method(:assertNull, [Java::java.lang.Object.java_class,Java::java.lang.String.java_class]).call(::Vertx::Util::Utils.to_object(expected),message)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling assert_null(expected,message)"
    end

### - (`self`) assert_true(condition = nil, message = nil)

Assert the specified `condition` is `true`. If the condition is `false`, an assertion error is thrown otherwise the execution continue.

Parameters:

- condition (`true`, `false`) (defaults to: `nil`) —
  the condition to assert
- message (`String`) (defaults to: `nil`) —
  the failure message

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 83

    def assert_true(condition=nil,message=nil)
      if (condition.class == TrueClass || condition.class == FalseClass) && !block_given? && message == nil
        @j_del.java_method(:assertTrue, [Java::boolean.java_class]).call(condition)
        return self
      elsif (condition.class == TrueClass || condition.class == FalseClass) && message.class == String && !block_given?
        @j_del.java_method(:assertTrue, [Java::boolean.java_class,Java::java.lang.String.java_class]).call(condition,message)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling assert_true(condition,message)"
    end

### - (`::VertxUnit::Async`) async

Create and returns a new async object, the returned async controls the completion of the test. Calling the Async#complete completes the async operation.

The test case will complete when all the async objects have their Async#complete method called at least once.

This method shall be used for creating asynchronous exit points for the executed test.

Returns:

- (`::VertxUnit::Async`) —
  the async instance

Raises:

- (`ArgumentError`)

    183
    184
    185
    186
    187
    188
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 183

    def async
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:async, []).call(),::VertxUnit::Async)
      end
      raise ArgumentError, "Invalid arguments when calling async()"
    end

### - (`void`) fail - (`void`) fail(message) - (`void`) fail(cause)

This method returns an undefined value.

Throw a failure with the specified failure `cause`.

Overloads:

- - (`void`) fail(message)

  Parameters:

  - message (`String`) —
    the failure message
- - (`void`) fail(cause)

  Parameters:

  - cause (`Exception`) —
    the failure cause

Raises:

- (`ArgumentError`)

    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 165

    def fail(param_1=nil)
      if !block_given? && param_1 == nil
        return @j_del.java_method(:fail, []).call()
      elsif param_1.class == String && !block_given?
        return @j_del.java_method(:fail, [Java::java.lang.String.java_class]).call(param_1)
      elsif param_1.is_a?(Exception) && !block_given?
        return @j_del.java_method(:fail, [Java::JavaLang::Throwable.java_class]).call(::Vertx::Util::Utils.to_throwable(param_1))
      end
      raise ArgumentError, "Invalid arguments when calling fail(param_1)"
    end

### - (`Object`) get(key = nil)

Get some data from the context.

Parameters:

- key (`String`) (defaults to: `nil`) —
  the key of the data

Returns:

- (`Object`) —
  the data

Raises:

- (`ArgumentError`)

    21
    22
    23
    24
    25
    26
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 21

    def get(key=nil)
      if key.class == String && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:get, [Java::java.lang.String.java_class]).call(key))
      end
      raise ArgumentError, "Invalid arguments when calling get(key)"
    end

### - (`Object`) put(key = nil, value = nil)

Put some data in the context.

This can be used to share data between different tests and before/after phases.

Parameters:

- key (`String`) (defaults to: `nil`) —
  the key of the data
- value (`Object`) (defaults to: `nil`) —
  the data

Returns:

- (`Object`) —
  the previous object when it exists

Raises:

- (`ArgumentError`)

    33
    34
    35
    36
    37
    38
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 33

    def put(key=nil,value=nil)
      if key.class == String && (value.class == String  || value.class == Hash || value.class == Array || value.class == NilClass || value.class == TrueClass || value.class == FalseClass || value.class == Fixnum || value.class == Float) && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:put, [Java::java.lang.String.java_class,Java::java.lang.Object.java_class]).call(key,::Vertx::Util::Utils.to_object(value)))
      end
      raise ArgumentError, "Invalid arguments when calling put(key,value)"
    end

### - (`Object`) remove(key = nil)

Remove some data from the context.

Parameters:

- key (`String`) (defaults to: `nil`) —
  the key to remove

Returns:

- (`Object`) —
  the removed object when it exists

Raises:

- (`ArgumentError`)

    42
    43
    44
    45
    46
    47
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-unit/src/main/resources/vertx-unit/test_context.rb', line 42

    def remove(key=nil)
      if key.class == String && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:remove, [Java::java.lang.String.java_class]).call(key))
      end
      raise ArgumentError, "Invalid arguments when calling remove(key)"
    end