### Question:
ContainsValues implements Predicate<Cursor> { @Override public boolean satisfiedBy(Cursor testedInstance) { for (String key : mValues.keySet()) { int columnIdx = testedInstance.getColumnIndex(key); if (columnIdx < 0) { return false; } if (testedInstance.getType(columnIdx) == Cursor.FIELD_TYPE_BLOB) { if (!Arrays.equals(mValues.getAsByteArray(key), testedInstance.getBlob(columnIdx))) { return false; } } else { String stringValue = mValues.getAsString(key); if (stringValue != null && !stringValue.equals(testedInstance.getString(columnIdx)) || stringValue == null && !testedInstance.isNull(columnIdx)) { return false; } } } return true; } ContainsValues(ContentValues values); @Override boolean satisfiedBy(Cursor testedInstance);  }### Answer:
@Test public void test() { ContentValues values = new ContentValues(); values.put("a", 123); values.put("b", "stringValue"); values.put("c", new byte[] { 3, 2, 1 }); values.putNull("d"); MatrixCursor cursor = new MatrixCursor(new String[] { "c", "b", "a", "d", "f" }); cursor.addRow(new Seq<>(new byte[] { 3, 2, 1 }, "stringValue", 123, null, "xyz")); cursor.addRow(new Seq<>(new byte[] { 3, 2, 1 }, "stringValue", "123", null, "xyz")); cursor.addRow(new Seq<>(new byte[] { 3, 2 }, "stringValue", 123, null, "xyz")); cursor.addRow(new Seq<>(new byte[] { 3, 2, 1 }, "stringValueX", 123, null, "xyz")); cursor.addRow(new Seq<>(new byte[] { 3, 2, 1 }, "stringValue", 1234, null, "xyz")); cursor.addRow(new Seq<>(new byte[] { 3, 2, 1 }, "stringValue", 123, "123", "xyz")); cursor.addRow(new Seq<>(321, "stringValueX", "1234", "123", "xyz")); cursor.addRow(new Seq<>(new byte[] { 3, 2, 1, 0 }, "stringValueX", 1234, "123", "xyz")); cursor.moveToFirst(); assertThat(new ContainsValues(values), is(satisfiedBy(cursor))); cursor.moveToNext(); assertThat(new ContainsValues(values), is(satisfiedBy(cursor))); cursor.moveToNext(); assertThat(new ContainsValues(values), is(not(satisfiedBy(cursor)))); cursor.moveToNext(); assertThat(new ContainsValues(values), is(not(satisfiedBy(cursor)))); cursor.moveToNext(); assertThat(new ContainsValues(values), is(not(satisfiedBy(cursor)))); cursor.moveToNext(); assertThat(new ContainsValues(values), is(not(satisfiedBy(cursor)))); cursor.moveToNext(); assertThat(new ContainsValues(values), is(not(satisfiedBy(cursor)))); cursor.moveToNext(); assertThat(new ContainsValues(values), is(not(satisfiedBy(cursor)))); }
@Test public void testMissingColumns() { ContentValues values = new ContentValues(); values.put("a", 123); values.put("b", "stringValue"); values.put("c", new byte[] { 3, 2, 1 }); values.putNull("d"); MatrixCursor cursor = new MatrixCursor(new String[] { "c", "b" }); cursor.addRow(new Seq<>(new byte[] { 3, 2, 1 }, "stringValue")); cursor.moveToFirst(); assertThat(new ContainsValues(values), is(not(satisfiedBy(cursor)))); }