RemoteDataStore extends DataManager { public boolean savePayloads(@NonNull Set<RemoteDataPayload> payloads) { if (payloads.isEmpty()) { return true; } final SQLiteDatabase db = getWritableDatabase(); if (db == null) { Logger.error("RemoteDataStore - Unable to save remote data payloads."); return false; } try { db.beginTransaction(); for (RemoteDataPayload payload : payloads) { ContentValues value = new ContentValues(); value.put(COLUMN_NAME_TYPE, payload.getType()); value.put(COLUMN_NAME_TIMESTAMP, payload.getTimestamp()); value.put(COLUMN_NAME_DATA, payload.getData().toString()); value.put(COLUMN_NAME_METADATA, payload.getMetadata().toString()); try { long id = db.insert(TABLE_NAME, null, value); if (id == -1) { db.endTransaction(); return false; } } catch (SQLException e) { Logger.error(e, "RemoteDataStore - Unable to save remote data payload."); } } db.setTransactionSuccessful(); db.endTransaction(); } catch (SQLException e) { Logger.error(e, "RemoteDataStore - Unable to save remote data payloads."); return false; } return true; } RemoteDataStore(@NonNull Context context, @NonNull String appKey, @NonNull String dbName); boolean savePayloads(@NonNull Set<RemoteDataPayload> payloads); @NonNull Set<RemoteDataPayload> getPayloads();  }
@Test public void testSavePayloads() { boolean success = dataStore.savePayloads(payloads); Assert.assertTrue(success); }