@ThreadSafe public final class BundleAssertions extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
assertHasBoolean(Bundle bundle,
String requiredKey)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasByteArray(Bundle bundle,
String requiredKey)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasInt(Bundle bundle,
String requiredKey)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasInt(Bundle bundle,
String requiredKey,
int lowerBound,
int upperBound)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasKey(Bundle bundle,
String requiredKey)
Asserts
bundle contains a mapping for requiredKey. |
static void |
assertHasKey(PersistableBundle bundle,
String requiredKey)
Asserts
bundle contains a mapping for requiredKey. |
static void |
assertHasLong(Bundle bundle,
String requiredKey)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasLong(Bundle bundle,
String requiredKey,
long lowerBound,
long upperBound)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasParcelable(Bundle bundle,
String requiredKey,
Class<? extends Parcelable> expectedClass)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasString(Bundle bundle,
String requiredKey)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasString(Bundle bundle,
String requiredKey,
boolean isNullAllowed,
boolean isEmptyStringAllowed)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasString(Bundle bundle,
String requiredKey,
String... allowedValues)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertHasStringArray(Bundle bundle,
String requiredKey)
Asserts
bundle contains a value of the correct type for requiredKey. |
static void |
assertKeyCount(Bundle bundle,
int expectedCount)
Asserts
bundle contains exactly count keys. |
static void |
assertKeyCount(PersistableBundle bundle,
int expectedCount)
Asserts
bundle contains exactly count keys. |
static void |
assertSerializable(Bundle bundle)
Asserts whether that a Bundle does not contain private
Serializable classes. |
public static void assertHasKey(@NonNull Bundle bundle, @Nullable String requiredKey) throws AssertionError
bundle contains a mapping for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping for.AssertionError - If bundle doesn't contain requiredKey.public static void assertHasKey(@NonNull PersistableBundle bundle, @Nullable String requiredKey) throws AssertionError
bundle contains a mapping for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping for.AssertionError - If bundle doesn't contain requiredKey.public static void assertHasBoolean(@NonNull Bundle bundle, @Nullable String requiredKey) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to a boolean value.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasByteArray(@NonNull Bundle bundle, @Nullable String requiredKey) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to a byte[] value.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasStringArray(@NonNull Bundle bundle, @Nullable String requiredKey) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to a String[] value.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasInt(@NonNull Bundle bundle, @Nullable String requiredKey) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to an int value.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasInt(@NonNull Bundle bundle, @Nullable String requiredKey, int lowerBound, int upperBound) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to an int value.lowerBound - Inclusive lower bound for requiredKey's value. Must be less than
or equal to upperBound.upperBound - Inclusive upper bound for requiredKey's value. Must be greater
than or equal to lowerBound.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasLong(@NonNull Bundle bundle, @Nullable String requiredKey) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to a long value.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasLong(@NonNull Bundle bundle, @Nullable String requiredKey, long lowerBound, long upperBound) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to an long value.lowerBound - Inclusive lower bound for requiredKey's value. Must be less than
or equal to upperBound.upperBound - Inclusive upper bound for requiredKey's value. Must be greater
than or equal to lowerBound.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasParcelable(@NonNull Bundle bundle, @Nullable String requiredKey, @NonNull Class<? extends Parcelable> expectedClass) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to a non-null Parcelable.expectedClass - Expected class type for the Parcelable requiredKey maps to.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasString(@NonNull Bundle bundle, @Nullable String requiredKey) throws AssertionError
bundle contains a value of the correct type for requiredKey.
Note: Detection of incorrect type mapping only occurs on API level 12 or greater.
bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to a String or null.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasString(@NonNull Bundle bundle, @Nullable String requiredKey, @Nullable String... allowedValues) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to a String value.allowedValues - Set of allowed values for requiredKey's value. null
indicates that all values are allowed.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertHasString(@NonNull Bundle bundle, @Nullable String requiredKey, boolean isNullAllowed, boolean isEmptyStringAllowed) throws AssertionError
bundle contains a value of the correct type for requiredKey.bundle - Bundle to check keys of.requiredKey - Key that bundle must have mapping to a String value.isNullAllowed - If null is allowed for the value.isEmptyStringAllowed - If the empty string is allowed for the value.AssertionError - If bundle doesn't contain requiredKey mapping to the
correct type.public static void assertKeyCount(@NonNull Bundle bundle, int expectedCount) throws AssertionError
bundle contains exactly count keys.bundle - Bundle to check key count of.expectedCount - Expected count of keys in bundle. Must be greater than or equal to 0.AssertionError - If bundle doesn't contain expectedCount keys.public static void assertKeyCount(@NonNull PersistableBundle bundle, int expectedCount) throws AssertionError
bundle contains exactly count keys.bundle - Bundle to check key count of.expectedCount - Expected count of keys in bundle. Must be greater than or equal to 0.AssertionError - If bundle doesn't contain expectedCount keys.public static void assertSerializable(@NonNull Bundle bundle)
Serializable classes.bundle - bundle to check.AssertionError - if bundle contains a Serializable object that isn't
part of the Android platform.