org.assertj.android.api.util.ArrayMapAssert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-android Show documentation
Show all versions of assertj-android Show documentation
A set of AssertJ assertion helpers geared toward testing Android.
The newest version!
package org.assertj.android.api.util;
import android.annotation.TargetApi;
import android.util.ArrayMap;
import org.assertj.core.api.AbstractMapAssert;
import static android.os.Build.VERSION_CODES.KITKAT;
import static org.assertj.core.api.Assertions.assertThat;
@TargetApi(KITKAT)
public class ArrayMapAssert
extends AbstractMapAssert, ArrayMap, K, V> {
public ArrayMapAssert(ArrayMap actual) {
super(actual, ArrayMapAssert.class);
}
public ArrayMapAssert hasKeyAt(int index, K key) {
isNotNull();
K actualKey = actual.keyAt(index);
assertThat(actualKey) //
.overridingErrorMessage("Expected key <%s> at index <%s> but was <%s>.", key, actualKey,
index) //
.isEqualTo(key);
return this;
}
public ArrayMapAssert hasValueAt(int index, V value) {
isNotNull();
V actualValue = actual.valueAt(index);
assertThat(actualValue) //
.overridingErrorMessage("Expected value <%s> but was <%s> at index <%s>.", value,
actualValue, index) //
.isEqualTo(value);
return this;
}
}