Class BctAssertions
This class extends the functionality provided by the JUnit Assertions class, with particular emphasis on the Bean-Centric Testing (BCT) framework. BCT enables sophisticated assertion patterns for testing object properties, collections, maps, and complex nested structures with minimal code.
Bean-Centric Testing (BCT) Framework:
The BCT framework consists of several key components:
- BeanConverter: Core interface for object conversion and property access
- BasicBeanConverter: Default implementation with extensible type handlers
- Assertion Methods: High-level testing methods that leverage the converter framework
Primary BCT Assertion Methods:
- assertBean(Object, String, String)
- Tests object properties with nested syntax support and collection iteration
- assertBeans(Collection, String, String...)
- Tests collections of objects by extracting and comparing specific fields
- assertMapped(Object, java.util.function.BiFunction, String, String)
- Tests custom property access using BiFunction for non-standard objects
- assertList(List, Object...)
- Tests list/collection elements with varargs for expected values
BCT Advanced Features:
- Nested Property Syntax: "address{street,city}" for testing nested objects
- Collection Iteration: "#{address{street,city}}" syntax for testing all elements
- Universal Size Properties: "length" and "size" work on all collection types
- Array/List Access: Numeric indices for element-specific testing
- Method Chaining: Fluent setters can be tested directly
- Direct Field Access: Public fields accessed without getters
- Map Key Access: Including special "<null>" syntax for null keys
Converter Extensibility:
The BCT framework is built on the extensible BasicBeanConverter which allows:
- Custom Stringifiers: Type-specific string conversion logic
- Custom Listifiers: Collection-type conversion for iteration
- Custom Swappers: Object transformation before conversion
- Custom PropertyExtractors: Property extraction
- Configurable Settings: Formatting, delimiters, and display options
Usage Examples:
Basic Property Testing:
    
Collection and Array Testing:
    
Collection Testing:
    
Custom Property Access:
    
Performance and Thread Safety:
The BCT framework is designed for high performance with:
- Caching: Type-to-handler mappings cached for fast lookup
- Thread Safety: All operations are thread-safe for concurrent testing
- Minimal Allocation: Efficient object reuse and minimal temporary objects
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptionstatic AssertionArgsargs()Creates a newAssertionArgsinstance for configuring assertion behavior.static voidassertBean(Object actual, String fields, String expected) Asserts that the fields/properties on the specified bean are the specified values after being converted to strings.static voidassertBean(AssertionArgs args, Object actual, String fields, String expected) Same asassertBean(Object, String, String)but with configurable assertion behavior.static voidassertBeans(Object actual, String fields, String... expected) Asserts that multiple beans in a collection have the expected property values.static voidassertBeans(AssertionArgs args, Object actual, String fields, String... expected) Same asassertBeans(Object, String, String...)but with configurable assertion behavior.static voidassertContains(String expected, Object actual) Asserts that the string representation of an object contains the expected substring.static voidassertContains(AssertionArgs args, String expected, Object actual) Same asassertContains(String, Object)but with configurable assertion behavior.static voidassertContainsAll(Object actual, String... expected) Asserts that the string representation of an object contains all specified substrings.static voidassertContainsAll(AssertionArgs args, Object actual, String... expected) Same asassertContainsAll(Object, String...)but with configurable assertion behavior.static voidassertEmpty(Object value) Asserts that a collection-like object or Optional is not null and empty.static voidassertEmpty(AssertionArgs args, Object value) Same asassertEmpty(Object)but with configurable assertion behavior.static voidassertList(Object actual, Object... expected) Asserts that a List or List-like object contains the expected values using flexible comparison logic.static voidassertList(AssertionArgs args, Object actual, Object... expected) Same asassertList(Object, Object...)but with configurable assertion behavior.static voidAsserts that a Map contains the expected key/value pairs using flexible comparison logic.static voidassertMap(AssertionArgs args, Map<?, ?> actual, Object... expected) Same asassertMap(Map, Object...)but with configurable assertion behavior.static <T> voidassertMapped(AssertionArgs args, T actual, BiFunction<T, String, Object> function, String properties, String expected) Same asassertMapped(Object, BiFunction, String, String)but with configurable assertion behavior.static <T> voidassertMapped(T actual, BiFunction<T, String, Object> function, String properties, String expected) Asserts that mapped property access on an object returns expected values using a custom BiFunction.static voidassertMatchesGlob(String pattern, Object value) Asserts that an object's string representation matches the specified glob-style pattern.static voidassertMatchesGlob(AssertionArgs args, String pattern, Object value) Same asassertMatchesGlob(String, Object)but with configurable assertion behavior.static voidassertNotEmpty(Object value) Asserts that a collection-like object or Optional is not null and not empty.static voidassertNotEmpty(AssertionArgs args, Object value) Same asassertNotEmpty(Object)but with configurable assertion behavior.static voidassertSize(int expected, Object actual) Asserts that a collection-like object or string is not null and of the specified size.static voidassertSize(AssertionArgs args, int expected, Object actual) Same asassertSize(int, Object)but with configurable assertion behavior.static voidassertString(String expected, Object actual) Asserts that an object's string representation exactly matches the expected value.static voidassertString(AssertionArgs args, String expected, Object actual) Same asassertString(String, Object)but with configurable assertion behavior.
- 
Method Details- 
argsCreates a newAssertionArgsinstance for configuring assertion behavior.AssertionArgs provides fluent configuration for customizing assertion behavior, including: - Custom Messages: Static strings, parameterized with MessageFormat, or dynamic suppliers
- Custom Bean Converters: Override default object-to-string conversion behavior
- Timeout Configuration: Set timeouts for operations that may take time
 Usage Examples:// Static message assertBean (args ().setMessage("User validation failed" ),user ,"name,age" ,"John,30" );// Parameterized message assertBean (args ().setMessage("Test failed for user {0}" ,userId ),user ,"status" ,"ACTIVE" );// Dynamic message with supplier assertBean (args ().setMessage(() ->"Test failed at " + Instant.now ()),result ,"success" ,"true" );// Custom bean converter var converter = BasicBeanConverter.builder () .defaultSettings() .addStringifier(LocalDate.class ,date ->date .format(DateTimeFormatter.ISO_LOCAL_DATE )) .build();assertBean (args ().setBeanConverter(converter ),event ,"date" ,"2023-12-01" );- Returns:
- A new AssertionArgs instance for fluent configuration
- See Also:
 
- Custom Messages: Static strings, parameterized with 
- 
assertBeanAsserts that the fields/properties on the specified bean are the specified values after being converted to strings.This is the primary method for Bean-Centric Tests (BCT), supporting extensive property validation patterns including nested objects, collections, arrays, method chaining, direct field access, collection iteration with "#{property}" syntax, and universal"length" /"size" properties for all collection types.The method uses the BasicBeanConverter.DEFAULTconverter internally for object introspection and value extraction. The converter provides sophisticated property access through theBeanConverterinterface, supporting multiple fallback mechanisms for accessing object properties and values.Basic Usage:// Test multiple properties assertBean (myBean ,"prop1,prop2,prop3" ,"val1,val2,val3" );// Test single property assertBean (myBean ,"name" ,"John" );Nested Property Testing:// Test nested bean properties assertBean (myBean ,"name,address{street,city,state}" ,"John,{123 Main St,Springfield,IL}" );// Test arbitrarily deep nesting assertBean (myBean ,"name,person{address{geo{lat,lon}}}" ,"John,{{{40.7,-74.0}}}" );Array, List, and Stream Testing:// Test array/list elements by index - items is a String[] or List<String> assertBean (myBean ,"items{0,1,2}" ,"{item1,item2,item3}" );// Test nested properties within array elements - orders is a List<Order> where Order has getId() and getTotal() assertBean (myBean ,"orders{0{id,total}}" ,"{{123,99.95}}" );// Test array length property - items can be any array or collection type assertBean (myBean ,"items{length}" ,"{5}" );// Works with any iterable type including Streams - userStream returns a Stream<User> where User has getName() assertBean (myBean ,"userStream{#{name}}" ,"[{Alice},{Bob}]" );Collection Iteration Syntax:// Test properties across ALL elements in a collection using #{...} syntax - userList is a List<User> where User has getName() assertBean (myBean ,"userList{#{name}}" ,"[{John},{Jane},{Bob}]" );// Test multiple properties from each element - orderList is a List<Order> where Order has getId() and getStatus() assertBean (myBean ,"orderList{#{id,status}}" ,"[{123,ACTIVE},{124,PENDING}]" );// Works with nested properties within each element - customers is a List<Customer> where Customer has getAddress() returning Address with getCity() assertBean (myBean ,"customers{#{address{city}}}" ,"[{{New York}},{{Los Angeles}}]" );// Works with arrays and any iterable collection type (including Streams) assertBean (config ,"itemArray{#{type}}" ,"[{String},{Integer},{Boolean}]" );assertBean (data ,"statusSet{#{name}}" ,"[{ACTIVE},{PENDING},{CANCELLED}]" );assertBean (processor ,"dataStream{#{value}}" ,"[{A},{B},{C}]" );Universal Collection Size Properties:// Both 'length' and 'size' work universally across all collection types assertBean (myBean ,"myArray{length}" ,"{5}" );// Arrays assertBean (myBean ,"myArray{size}" ,"{5}" );// Also works for arrays assertBean (myBean ,"myList{size}" ,"{3}" );// Collections assertBean (myBean ,"myList{length}" ,"{3}" );// Also works for collections assertBean (myBean ,"myMap{size}" ,"{7}" );// Maps assertBean (myBean ,"myMap{length}" ,"{7}" );// Also works for maps Class Name Testing:// Test class properties (prefer simple names for maintainability) assertBean (myBean ,"obj{class{simpleName}}" ,"{{MyClass}}" );// Test full class names when needed assertBean (myBean ,"obj{class{name}}" ,"{{com.example.MyClass}}" );Method Chaining Support:// Test fluent setter chains (returns same object) assertBean (item .setType("foo" ).setFormat("bar" ).setDefault("baz" ),"type,format,default" ,"foo,bar,baz" );Advanced Collection Analysis:// Combine size/length, metadata, and content iteration in single assertions - users is a List<User> assertBean (myBean ,"users{length,class{simpleName},#{name}}" ,"{3,{ArrayList},[{John},{Jane},{Bob}]}" );// Comprehensive collection validation with multiple iteration patterns - items is a List<Product> where Product has getName() and getPrice() assertBean (order ,"items{size,#{name},#{price}}" ,"{3,[{Laptop},{Phone},{Tablet}],[{999.99},{599.99},{399.99}]}" );// Perfect for validation testing - verify error count and details; errors is a List<ValidationError> where ValidationError has getField() and getCode() assertBean (result ,"errors{length,#{field},#{code}}" ,"{2,[{email},{password}],[{E001},{E002}]}" );// Mixed collection types with consistent syntax - results and metadata are different collection types assertBean (response ,"results{size},metadata{length}" ,"{25},{4}" );Direct Field Access:// Test public fields directly (no getters required) assertBean (myBean ,"f1,f2,f3" ,"val1,val2,val3" );// Test field properties with chaining assertBean (myBean ,"f1{length},f2{class{simpleName}}" ,"{5},{{String}}" );Map Testing:// Test map values by key assertBean (myBean ,"configMap{timeout,retries}" ,"{30000,3}" );// Test map size assertBean (myBean ,"settings{size}" ,"{5}" );// Test null keys using special <null> syntax assertBean (myBean ,"mapWithNullKey{<null>}" ,"{nullKeyValue}" );Collection and Boolean Values:// Test boolean values assertBean (myBean ,"enabled,visible" ,"true,false" );// Test enum collections assertBean (myBean ,"statuses" ,"[ACTIVE,PENDING]" );Value Syntax Rules:- Simple values: "value" for direct property values
- Nested values: "{value}" for single-level nested properties
- Deep nested values: "{{value}}" ,"{{{value}}}" for multiple nesting levels
- Array/Collection values: "[item1,item2]" for collections
- Collection iteration: "#{property}" iterates over ALL collection elements, returns"[{val1},{val2}]" 
- Universal size properties: "length" and"size" work on arrays, collections, and maps
- Boolean values: "true" ,"false" 
- Null values: "null" 
 Property Access Priority:- Collection/Array access: Numeric indices for arrays/lists (e.g., "0" ,"1" )
- Universal size properties: "length" and"size" for arrays, collections, and maps
- Map key access: Direct key lookup for Map objects (including "<null>" for null keys)
- is{Property}() methods (for boolean properties)
- get{Property}() methods
- Public fields (direct field access)
 - Parameters:
- actual- The bean object to test. Must not be null.
- fields- Comma-delimited list of property names to test. Supports nested syntax with {}.
- expected- Comma-delimited list of expected values. Must match the order of fields.
- Throws:
- NullPointerException- if the bean is null
- AssertionError- if any property values don't match expected values
- See Also:
 
- Simple values: 
- 
assertBeanSame asassertBean(Object, String, String)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- actual- The bean to test. Must not be null.
- fields- A comma-delimited list of bean property names (supports nested syntax).
- expected- The expected property values as a comma-delimited string.
- See Also:
 
- 
assertBeansAsserts that multiple beans in a collection have the expected property values.This method validates that each bean in a collection has the specified property values, using the same property access logic as assertBean(Object, String, String). It's perfect for testing collections of similar objects or validation results.Basic Usage:// Test list of user beans assertBeans (userList ,"name,age" ,"John,25" ,"Jane,30" ,"Bob,35" );Complex Property Testing:// Test nested properties across multiple beans - orderList is a List<Order> where Order has getId() and getCustomer() returning Customer with getName() and getEmail() assertBeans (orderList ,"id,customer{name,email}" ,"1,{John,john@example.com}" ,"2,{Jane,jane@example.com}" );// Test collection properties within beans - cartList is a List<ShoppingCart> where ShoppingCart has getItems() returning List<Product> and getTotal() assertBeans (cartList ,"items{0{name}},total" ,"{{Laptop}},999.99" ,"{{Phone}},599.99" );Validation Testing:// Test validation results assertBeans (validationErrors ,"field,message,code" ,"email,Invalid email format,E001" ,"age,Must be 18 or older,E002" );Collection Iteration Testing:// Test collection iteration within beans (#{...} syntax) assertBeans (departmentList ,"name,employees{#{name}}" ,"Engineering,[{Alice},{Bob},{Charlie}]" ,"Marketing,[{David},{Eve}]" );Parser Result Testing:// Test parsed object collections var parsed = JsonParser.DEFAULT .parse(jsonArray , MyBean[].class);assertBeans (Arrays.asList (parsed ),"prop1,prop2" ,"val1,val2" ,"val3,val4" );- Parameters:
- actual- The collection of beans to check. Must not be null.
- fields- A comma-delimited list of bean property names (supports nested syntax).
- expected- Array of expected value strings, one per bean. Each string contains comma-delimited values matching the fields.
- Throws:
- AssertionError- if the collection size doesn't match values array length or if any bean properties don't match
- See Also:
 
- 
assertBeanspublic static void assertBeans(AssertionArgs args, Object actual, String fields, String... expected) Same asassertBeans(Object, String, String...)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- actual- The collection of beans to test. Must not be null.
- fields- A comma-delimited list of bean property names (supports nested syntax).
- expected- Array of expected value strings, one per bean.
- See Also:
 
- 
assertMappedpublic static <T> void assertMapped(T actual, BiFunction<T, String, Object> function, String properties, String expected) Asserts that mapped property access on an object returns expected values using a custom BiFunction.This is designed for testing objects that don't follow standard JavaBean patterns or require custom property access logic. The BiFunction allows complete control over how properties are retrieved from the target object. This method creates an intermediate LinkedHashMap to collect all property values before using the same logic as assertBean for comparison. This ensures consistent ordering and supports the full nested property syntax. The BasicBeanConverter.DEFAULTis used for value stringification and nested property access.- Type Parameters:
- T- The type of object being tested
- Parameters:
- actual- The object to test properties on
- function- The BiFunction that extracts property values. Receives (- object ,- propertyName ) and returns the property value.
- properties- Comma-delimited list of property names to test
- expected- Comma-delimited list of expected values (exceptions become simple class names)
- Throws:
- AssertionError- if any mapped property values don't match expected values
- See Also:
 
- 
assertMappedpublic static <T> void assertMapped(AssertionArgs args, T actual, BiFunction<T, String, Object> function, String properties, String expected) Same asassertMapped(Object, BiFunction, String, String)but with configurable assertion behavior.- Type Parameters:
- T- The object type being tested.
- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- actual- The object to test. Must not be null.
- function- Custom property access function.
- properties- A comma-delimited list of property names.
- expected- The expected property values as a comma-delimited string.
- See Also:
 
- 
assertContainsAsserts that the string representation of an object contains the expected substring.This method converts the actual object to its string representation using the current BeanConverterand then checks if it contains the expected substring. This is useful for testing partial content matches without requiring exact string equality.Usage Examples:// Test that error message contains key information assertContains ("FileNotFoundException" ,exception );// Test that object string representation contains expected data assertContains ("status=ACTIVE" ,user );// Test partial JSON/XML content assertContains ("\"name\":\"John\"" ,jsonResponse );- Parameters:
- expected- The substring that must be present in the actual object's string representation
- actual- The object to test. Must not be null.
- Throws:
- AssertionError- if the actual object is null or its string representation doesn't contain the expected substring
- See Also:
 
- 
assertContainsSame asassertContains(String, Object)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- expected- The substring that must be present.
- actual- The object to test. Must not be null.
- See Also:
 
- 
assertContainsAllAsserts that the string representation of an object contains all specified substrings.This method is similar to assertContains(String, Object)but tests for multiple required substrings. All provided substrings must be present in the actual object's string representation for the assertion to pass.Usage Examples:// Test that error contains multiple pieces of information assertContainsAll (exception ,"FileNotFoundException" ,"config.xml" ,"/etc" );// Test that user object contains expected fields assertContainsAll (user ,"name=John" ,"age=30" ,"status=ACTIVE" );// Test log output contains all required entries assertContainsAll (logOutput ,"INFO" ,"Started" ,"Successfully" );- Parameters:
- actual- The object to test. Must not be null.
- expected- Multiple substrings that must all be present in the actual object's string representation
- Throws:
- AssertionError- if the actual object is null or its string representation doesn't contain all expected substrings
- See Also:
 
- 
assertContainsAllSame asassertContainsAll(Object, String...)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- actual- The object to test. Must not be null.
- expected- Multiple substrings that must all be present.
- See Also:
 
- 
assertEmptyAsserts that a collection-like object or Optional is not null and empty.This method validates that the provided object is empty according to its type: - Optional: Must be empty (not present)
- Map: Must have no entries
- Collection-like objects: Must be convertible to an empty List via BeanConverter.listify(Object)
 Supported Types:Any object that can be converted to a List, including: - Collections (List, Set, Queue, etc.)
- Arrays (primitive and object arrays)
- Iterables, Iterators, Streams
- Maps (converted to list of entries)
- Optional objects
 Usage Examples:// Test empty collections assertEmpty (Collections.emptyList ());assertEmpty (new ArrayList<>());// Test empty arrays assertEmpty (new String[0]);// Test empty Optional assertEmpty (Optional.empty ());// Test empty Map assertEmpty (new HashMap<>());- Parameters:
- value- The object to test. Must not be null.
- Throws:
- AssertionError- if the object is null or not empty
- See Also:
 
- 
assertEmptySame asassertEmpty(Object)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- value- The object to test. Must not be null.
- See Also:
 
- 
assertListAsserts that a List or List-like object contains the expected values using flexible comparison logic.Testing Non-List Collections:// Test a Set using l() conversion Set<String>mySet =new TreeSet<>(Arrays.asList ("a" ,"b" ,"c" ));assertList (l (mySet ),"a" ,"b" ,"c" );// Test an array using l() conversion String[]myArray = {"x" ,"y" ,"z" };assertList (l (myArray ),"x" ,"y" ,"z" );// Test a Stream using l() conversion Stream<String>myStream = Stream.of ("foo" ,"bar" );assertList (l (myStream ),"foo" ,"bar" );Comparison Modes:The method supports three different ways to compare expected vs actual values: 1. String Comparison (Readable Format):// Elements are converted to strings using the bean converter and compared as strings assertList (List.of (1, 2, 3),"1" ,"2" ,"3" );assertList (List.of ("a" ,"b" ),"a" ,"b" );2. Predicate Testing (Functional Validation):// Use Predicate<T> for functional testing Predicate<Integer>greaterThanOne =x ->x > 1;assertList (List.of (2, 3, 4),greaterThanOne ,greaterThanOne ,greaterThanOne );// Mix predicates with other comparison types Predicate<String>startsWithA =s ->s .startsWith("a" );assertList (List.of ("apple" ,"banana" ),startsWithA ,"banana" );3. Object Equality (Direct Comparison):// Non-String, non-Predicate objects use Objects.equals () comparisonassertList (List.of (1, 2, 3), 1, 2, 3);// Integer objects assertList (List.of (myBean1 ,myBean2 ),myBean1 ,myBean2 );// Custom objects - Parameters:
- actual- The List to test. Must not be null.
- expected- Multiple arguments of expected values. Can be Strings (readable format comparison), Predicates (functional testing), or Objects (direct equality).
- Throws:
- AssertionError- if the List size or contents don't match expected values
 
- 
assertMapAsserts that a Map contains the expected key/value pairs using flexible comparison logic.Map Entry Serialization:Map entries are serialized to strings as key/value pairs in the format "key=value" . Nested maps and collections are supported with appropriate formatting.Testing Nested Maps and Collections:// Test simple map entries Map<String,String>simpleMap = Map.of ("a" ,"1" ,"b" ,"2" );assertMap (simpleMap ,"a=1" ,"b=2" );// Test nested maps Map<String,Map<String,Integer>>nestedMap = Map.of ("a" , Map.of ("b" , 1));assertMap (nestedMap ,"a={b=1}" );// Test maps with arrays/collections Map<String,Map<String,Integer[]>>mapWithArrays = Map.of ("a" , Map.of ("b" ,new Integer[]{1,2}));assertMap (mapWithArrays ,"a={b=[1,2]}" );Comparison Modes:The method supports the same comparison modes as assertList(Object, Object...):1. String Comparison (Readable Format):// Map entries are converted to strings and compared as strings assertMap (Map.of ("key1" ,"value1" ),"key1=value1" );assertMap (Map.of ("count" , 42),"count=42" );2. Predicate Testing (Functional Validation):// Use Predicate<Map.Entry<K,V>> for functional testing Predicate<Map.Entry<String,Integer>>valueGreaterThanTen =entry ->entry .getValue() > 10;assertMap (Map.of ("count" , 42),valueGreaterThanTen );3. Object Equality (Direct Comparison):// Non-String, non-Predicate objects use Objects.equals () comparisonassertMap (Map.of ("key" ,myObject ),expectedEntry );Map Ordering Behavior:The Listifiers.mapListifier()method ensures deterministic ordering for map entries:- SortedMap(TreeMap, etc.): Preserves existing sort order
- LinkedHashMap: Preserves insertion order
- HashMapand other unordered Maps: Converts to- TreeMapfor natural key ordering
 This ensures predictable test results regardless of the original map implementation. - Parameters:
- actual- The Map to test. Must not be null.
- expected- Multiple arguments of expected map entries. Can be Strings (readable format comparison), Predicates (functional testing), or Objects (direct equality).
- Throws:
- AssertionError- if the Map size or contents don't match expected values
- See Also:
 
- 
assertMapSame asassertMap(Map, Object...)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- actual- The Map to test. Must not be null.
- expected- Multiple arguments of expected map entries.
- See Also:
 
- 
assertListSame asassertList(Object, Object...)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- actual- The List to test. Must not be null.
- expected- Multiple arguments of expected values.
- See Also:
 
- 
assertNotEmptyAsserts that a collection-like object or Optional is not null and not empty.This method validates that the provided object is not empty according to its type: - Optional: Must be present (not empty)
- Map: Must have at least one entry
- Collection-like objects: Must convert to a non-empty List via BeanConverter.listify(Object)
 Supported Types:Any object that can be converted to a List, including: - Collections (List, Set, Queue, etc.)
- Arrays (primitive and object arrays)
- Iterables, Iterators, Streams
- Maps (converted to list of entries)
- Optional objects
 Usage Examples:// Test non-empty collections assertNotEmpty (List.of ("item1" ,"item2" ));assertNotEmpty (new ArrayList<>(Arrays.asList ("a" )));// Test non-empty arrays assertNotEmpty (new String[]{"value" });// Test present Optional assertNotEmpty (Optional.of ("value" ));// Test non-empty Map assertNotEmpty (Map.of ("key" ,"value" ));- Parameters:
- value- The object to test. Must not be null.
- Throws:
- AssertionError- if the object is null or empty
- See Also:
 
- 
assertNotEmptySame asassertNotEmpty(Object)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- value- The object to test. Must not be null.
- See Also:
 
- 
assertSizeAsserts that a collection-like object or string is not null and of the specified size.This method can validate the size of various types of objects: - String: Validates character length
- Collection-like objects: Any object that can be converted to a List via the underlying converter
 Usage Examples:// Test string length assertSize (5,"hello" );// Test collection size assertSize (3, List.of ("a" ,"b" ,"c" ));// Test array size assertSize (2,new String[]{"x" ,"y" });- Parameters:
- expected- The expected size/length.
- actual- The object to test. Must not be null.
- Throws:
- AssertionError- if the object is null or not the expected size.
 
- 
assertSizeSame asassertSize(int, Object)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- expected- The expected size/length.
- actual- The object to test. Must not be null.
- See Also:
 
- 
assertStringAsserts that an object's string representation exactly matches the expected value.This method converts the actual object to its string representation using the current BeanConverterand performs an exact equality comparison with the expected string. This is useful for testing complete string output, formatted objects, or converted values.Usage Examples:// Test exact string conversion assertString ("John,30,true" ,user );// Assuming user converts to this format // Test formatted dates or numbers assertString ("2023-12-01" ,localDate );// Test complex object serialization assertString ("{name=John,age=30}" ,userMap );// Test array/collection formatting assertString ("[red,green,blue]" ,colors );- Parameters:
- expected- The exact string that the actual object should convert to
- actual- The object to test. Must not be null.
- Throws:
- AssertionError- if the actual object is null or its string representation doesn't exactly match expected
- See Also:
 
- 
assertStringSame asassertString(String, Object)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- expected- The expected string value.
- actual- The object to test. Must not be null.
- See Also:
 
- 
assertMatchesGlobAsserts that an object's string representation matches the specified glob-style pattern.This method converts the actual object to its string representation using the current BeanConverterand then tests it against the provided glob-style pattern. This is useful for testing string formats with simple wildcard patterns.Pattern Syntax:The pattern uses glob-style wildcards: - *matches any sequence of characters (including none)
- ?matches exactly one character
- All other characters are treated literally
 Usage Examples:// Test filename patterns assertMatchesGlob ("user_*_temp" ,filename );// Test single character wildcards assertMatchesGlob ("file?.txt" ,fileName );// Test combined patterns assertMatchesGlob ("log_*_?.txt" ,logFile );- Parameters:
- pattern- The glob-style pattern to match against.
- value- The object to test. Must not be null.
- Throws:
- AssertionError- if the value is null or its string representation doesn't match the pattern
- See Also:
- 
- for exact string matching
- for substring matching
- for pattern compilation details
 
 
- 
assertMatchesGlobSame asassertMatchesGlob(String, Object)but with configurable assertion behavior.- Parameters:
- args- Assertion configuration. See- args()for usage examples.
- pattern- The glob-style pattern to match against.
- value- The object to test. Must not be null.
- See Also:
 
 
-