Class JUnitAssertions<T extends JUnitAssertions<T>>

    • Field Detail

      • includeLog

        protected final boolean includeLog
      • statusCodeAsserted

        protected boolean statusCodeAsserted
    • Method Detail

      • self

        protected T self()
      • isEqual

        public T isEqual​(Object actual,
                         Object expected,
                         String message)
        Asserts that the actual value is equal to the expected value.
        Specified by:
        isEqual in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        actual - the actual value
        expected - the expected value
        message - custom failure message
        Returns:
        this assertion helper
      • isNotEqual

        public T isNotEqual​(Object actual,
                            Object expected,
                            String message)
        Asserts that the actual value is not equal to the expected value.
        Specified by:
        isNotEqual in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        actual - the actual value
        expected - the expected value
        message - custom failure message
        Returns:
        this assertion helper
      • isTrue

        public T isTrue​(boolean condition,
                        String message)
        Asserts that the condition is true.
        Specified by:
        isTrue in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        condition - the condition to check
        message - custom failure message
        Returns:
        this assertion helper
      • isFalse

        public T isFalse​(boolean condition,
                         String message)
        Asserts that the condition is false.
        Specified by:
        isFalse in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        condition - the condition to check
        message - custom failure message
        Returns:
        this assertion helper
      • statusCode

        public T statusCode​(int expected)
        Asserts that the current secure response has the expected status code.
        Specified by:
        statusCode in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        expected - the expected status code
        Returns:
        this assertion helper
      • statusCode

        public T statusCode​(int expected,
                            String message)
        Asserts that the current secure response has the expected status code.
        Specified by:
        statusCode in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        expected - the expected status code
        message - custom failure message
        Returns:
        this assertion helper
      • exists

        public T exists​(String path,
                        String message)
        Asserts that the current secure response contains the given path.
        Specified by:
        exists in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        path - the response path to check
        message - custom failure message
        Returns:
        this assertion helper
      • notExists

        public T notExists​(String path,
                           String message)
        Asserts that the current secure response does not contain the given path.
        Specified by:
        notExists in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        path - the response path to check
        message - custom failure message
        Returns:
        this assertion helper
      • pathEquals

        public T pathEquals​(String path,
                            Object expected)
        Asserts that the value at the given response path is equal to the expected value.
        Specified by:
        pathEquals in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        path - the response path to check
        expected - the expected value
        Returns:
        this assertion helper
      • pathEquals

        public T pathEquals​(String path,
                            Object expected,
                            String message)
        Asserts that the value at the given response path is equal to the expected value.
        Specified by:
        pathEquals in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        path - the response path to check
        expected - the expected value
        message - custom failure message
        Returns:
        this assertion helper
      • allMatch

        public T allMatch​(String path,
                          Predicate<Number> predicate,
                          String message)
        Asserts that every numeric value returned by the response path matches the predicate.
        Specified by:
        allMatch in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        path - response path that resolves to a list of numeric values
        predicate - predicate applied to each value
        message - custom failure message. Use {} for the value.
        Returns:
        this assertion helper
      • allMatch

        public T allMatch​(String path,
                          BiPredicate<Object,​Integer> predicate,
                          String message)
        Asserts that every numeric value returned by the response path matches the predicate.
        Specified by:
        allMatch in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        path - response path that resolves to a list of numeric values
        predicate - predicate applied to each value and index
        message - custom failure message. Use {} placeholders for value and index.
        Returns:
        this assertion helper
      • allMatch

        public <V> T allMatch​(String path,
                              Class<V> type,
                              BiPredicate<V,​Integer> predicate,
                              String message)
        Asserts that every value returned by the response path matches the predicate.
        Specified by:
        allMatch in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Type Parameters:
        V - expected value type
        Parameters:
        path - response path that resolves to a list of values
        type - expected value type
        predicate - predicate applied to each value and index
        message - custom failure message. Use {} placeholders for value and index.
        Returns:
        this assertion helper
      • verify

        public JUnitContext verify​(int statusCode)
        Verifies the expected status code and returns the test context.

        In hard mode, this fails immediately on status code mismatch. In soft mode, collected soft assertions are verified and the expected status code is added only when no status code assertion was already collected.

        Specified by:
        verify in interface JPostmanAssertions<JUnitContext,​T extends JUnitAssertions<T>>
        Parameters:
        statusCode - expected status code
        Returns:
        current test context
      • assertWithLog

        protected T assertWithLog​(Runnable assertion)
        Executes an assertion and wraps failures with optional secure log context.
        Parameters:
        assertion - assertion to execute
        Returns:
        this assertion helper
      • wrap

        protected AssertionError wrap​(AssertionError error)
        Wraps an assertion error with optional secure log context.
        Parameters:
        error - original assertion error
        Returns:
        wrapped assertion error