Class BctUtils

java.lang.Object
org.apache.juneau.junit.bct.BctUtils

public class BctUtils extends Object
Bean-Centric Testing utility methods.

This class contains static utility methods specific to the Bean-Centric Testing framework. For general-purpose utility methods, use the classes in org.apache.juneau.commons.utils package.

See Also:
  • Method Details

    • assertEqualsFailed

      public static org.opentest4j.AssertionFailedError assertEqualsFailed(Object expected, Object actual, Supplier<String> messageSupplier)
      Creates an AssertionFailedError for failed equality assertions.

      This method constructs a properly formatted assertion failure with expected and actual values for use in test frameworks. The message follows JUnit's standard format for assertion failures.

      Example:

      if (!eq(expected, actual)) { throw assertEqualsFailed(expected, actual, () -> "Custom context message with arg {0}", arg); }

      Parameters:
      expected - The expected value.
      actual - The actual value that was encountered.
      messageSupplier - Optional supplier for additional context message.
      Returns:
      A new AssertionFailedError with formatted message and values.
    • tokenize

      public static List<org.apache.juneau.junit.bct.NestedTokenizer.Token> tokenize(String fields)
      Tokenizes a string into a list of NestedTokenizer.Token objects.

      This method delegates to NestedTokenizer.tokenize(String) to parse structured field strings into tokens. It's commonly used for parsing field lists and nested property expressions.

      Example:

      var tokens = tokenize("name,address{street,city},age"); // Parses nested field expressions

      Parameters:
      fields - The field string to tokenize.
      Returns:
      A list of parsed tokens.
      See Also:
      • NestedTokenizer.tokenize(String)