Class MapAssert<K,V>
java.lang.Object
cloud.opencode.base.test.assertion.MapAssert<K,V>
- Type Parameters:
K- the key type | 键类型V- the value type | 值类型
Map Assert - Fluent assertions for Map instances
Map断言 - Map实例的流式断言
Provides comprehensive assertion methods for Map types including
size checks, key/value containment, and predicate-based matching.
为 Map 类型提供全面的断言方法,包括大小检查、键/值包含和基于谓词的匹配。
Features | 主要功能:
- Fluent assertion API for maps - Map的流式断言API
- Size, key, value containment checks - 大小、键、值包含检查
- Key-value pair assertions - 键值对断言
- Predicate-based matching (allKeysMatch, allValuesMatch) - 基于谓词的匹配
Usage Examples | 使用示例:
MapAssert.assertThat(map)
.isNotEmpty()
.hasSize(3)
.containsKey("name")
.containsEntry("age", 30)
.doesNotContainKey("password");
Security | 安全性:
- Thread-safe: No (not designed for concurrent use) - 线程安全: 否(非设计用于并发使用)
- Null-safe: Yes (validates non-null map) - 空值安全: 是(验证非空Map)
- Since:
- JDK 25, opencode-base-test V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionallKeysMatch(Predicate<K> predicate) Asserts that all keys match the given predicate.allValuesMatch(Predicate<V> predicate) Asserts that all values match the given predicate.static <K,V> MapAssert <K, V> assertThat(Map<K, V> actual) Creates assertion for a map.containsEntry(K key, V value) Asserts that the map contains the specified key-value entry.containsKey(K key) Asserts that the map contains the specified key.containsKeys(K... keys) Asserts that the map contains all specified keys.containsValue(V value) Asserts that the map contains the specified value.doesNotContainEntry(K key, V value) Asserts that the map does not contain the specified key-value entry.doesNotContainKey(K key) Asserts that the map does not contain the specified key.doesNotContainValue(V value) Asserts that the map does not contain the specified value.hasSize(int expectedSize) Asserts that the map has the specified size.hasSizeGreaterThan(int size) Asserts that the map has size greater than the specified value.hasSizeLessThan(int size) Asserts that the map has size less than the specified value.isEmpty()Asserts that the map is empty.Asserts that the map equals the expected map.Asserts that the map is not empty.Asserts that the map is not null.isNull()Asserts that the map is null.
-
Method Details
-
assertThat
-
isNull
-
isNotNull
-
isEmpty
-
isNotEmpty
-
hasSize
-
hasSizeGreaterThan
-
hasSizeLessThan
-
containsKey
-
doesNotContainKey
-
containsValue
-
doesNotContainValue
-
containsEntry
-
doesNotContainEntry
-
containsKeys
Asserts that the map contains all specified keys. 断言Map包含所有指定键。- Parameters:
keys- the keys | 键- Returns:
- this | 此对象
-
allKeysMatch
-
allValuesMatch
-
isEqualTo
-