public void testParseTalksJson() throws Exception { ArrayList<ContentProviderOperation> batch = mTalksHandler.parse(getDummyJson(), getContext().getContentResolver()); assertEquals(4, batch.size()); getProvider().applyBatch(batch); Cursor cursor = getProvider().query(Talks.uri(24001), null, null, null, null); cursor.moveToFirst(); assertEquals("Android", cursor.getString(cursor.getColumnIndex(Talks.TITLE))); long datetimestamp = cursor.getLong(cursor.getColumnIndex(Talks.START_DATE)); CharSequence date = DateFormat.format("yyyy-MM-dd h:mm", new Date(datetimestamp)); assertEquals("2012-06-23 9:30", date); int duration = (int) ((cursor.getLong(cursor.getColumnIndex(Talks.END_DATE)) - datetimestamp) / (60 * 60 * 1000)); assertEquals(1, duration); assertEquals("sala3", cursor.getString(cursor.getColumnIndex(Talks.ROOM))); assertEquals( "*****@*****.**", cursor.getString(cursor.getColumnIndex(Talks.SPEAKER_EMAIL))); assertEquals("fbgblog", cursor.getString(cursor.getColumnIndex(Talks.SPEAKER_TWITTER))); assertEquals("Bill Gates", cursor.getString(cursor.getColumnIndex(Talks.SPEAKER))); assertEquals("¿Cuanto nos paga?", cursor.getString(cursor.getColumnIndex(Talks.DESCRIPTION))); }
public void testGetMillis() throws Exception { String expected = "2012-02-29 10:30"; long millis = mTalksHandler.getMillis(expected); Date date = new Date(millis); CharSequence actual = DateFormat.format("yyyy-MM-dd h:mm", date); assertEquals(expected, actual); }