@Test
public void testUpdate() {

    Uri apkUri = Assert.insertApk(context, "com.example", 10);
    String[] allFields = Cols.ALL;
    Cursor cursor = contentResolver.query(apkUri, allFields, null, null, null);
    assertResultCount(1, cursor);
    cursor.moveToFirst();
    Apk apk = new Apk(cursor);
    cursor.close();
    assertEquals("com.example", apk.packageName);
    assertEquals(10, apk.versionCode);
    assertNull(apk.antiFeatures);
    assertNull(apk.features);
    assertNull(apk.added);
    assertNull(apk.hashType);
    apk.antiFeatures = new String[]{"KnownVuln", "Other anti feature"};
    apk.features = new String[]{"one", "two", "three"};
    apk.hashType = "i'm a hash type";
    Date testTime = Utils.parseDate(Utils.formatTime(new Date(System.currentTimeMillis()), null), null);
    apk.added = testTime;
    ApkProvider.Helper.update(context, apk);
    // Should not have inserted anything else, just updated the already existing apk.
    Cursor allCursor = contentResolver.query(ApkProvider.getContentUri(), allFields, null, null, null);
    assertResultCount(1, allCursor);
    allCursor.close();
    Cursor updatedCursor = contentResolver.query(apkUri, allFields, null, null, null);
    assertResultCount(1, updatedCursor);
    updatedCursor.moveToFirst();
    Apk updatedApk = new Apk(updatedCursor);
    updatedCursor.close();
    assertEquals("com.example", updatedApk.packageName);
    assertEquals(10, updatedApk.versionCode);
    assertArrayEquals(new String[]{"KnownVuln", "Other anti feature"}, updatedApk.antiFeatures);
    assertArrayEquals(new String[]{"one", "two", "three"}, updatedApk.features);
    assertEquals(testTime.getYear(), updatedApk.added.getYear());
    assertEquals(testTime.getYear(), updatedApk.added.getYear());
    assertEquals(testTime.getMonth(), updatedApk.added.getMonth());
    assertEquals(testTime.getDay(), updatedApk.added.getDay());
    assertEquals("i'm a hash type", updatedApk.hashType);
}