private org.ei.telemedicine.view.contract.TimelineEvent eventFor(
     TimelineEvent pregnancyEvent, String expectedRelativeTime) {
   return new org.ei.telemedicine.view.contract.TimelineEvent(
       pregnancyEvent.type(),
       pregnancyEvent.title(),
       new String[] {pregnancyEvent.detail1(), pregnancyEvent.detail2()},
       expectedRelativeTime);
 }
  @Test
  public void shouldGetANCDetailsAsJSON() {
    TimelineEvent pregnancyEvent =
        TimelineEvent.forStartOfPregnancyForEC(caseId, "TC 1", "2011-10-21", "2011-10-21");
    TimelineEvent fpEvent =
        TimelineEvent.forChangeOfFPMethod(caseId, "condom", "iud", "2011-12-22");
    TimelineEvent eventVeryCloseToCurrentDate =
        TimelineEvent.forChangeOfFPMethod(caseId, "iud", "condom", "2012-07-29");

    HashMap<String, String> details = new HashMap<String, String>();
    details.put("ashaName", "Shiwani");
    details.put("isHighPriority", "1");

    when(allEligibleCouples.findByCaseID(caseId))
        .thenReturn(
            new EligibleCouple(
                "EC CASE 1",
                "Woman 1",
                "Husband 1",
                "EC Number 1",
                "Village 1",
                "Subcenter 1",
                details));
    when(allTimelineEvents.forCase(caseId))
        .thenReturn(asList(pregnancyEvent, fpEvent, eventVeryCloseToCurrentDate));

    ECDetail expectedDetail =
        new ECDetail(
                caseId,
                "Village 1",
                "Subcenter 1",
                "EC Number 1",
                true,
                null,
                null,
                new ArrayList<Child>(),
                new CoupleDetails("Woman 1", "Husband 1", "EC Number 1", false),
                details)
            .addTimelineEvents(
                asList(
                    eventFor(eventVeryCloseToCurrentDate, "29-07-2012"),
                    eventFor(fpEvent, "22-12-2011"),
                    eventFor(pregnancyEvent, "21-10-2011")));

    String actualJson = controller.get();
    ECDetail actualDetail = new Gson().fromJson(actualJson, ECDetail.class);

    assertEquals(expectedDetail, actualDetail);
  }
 private ContentValues createValuesFor(TimelineEvent timelineEvent) {
   ContentValues values = new ContentValues();
   values.put(CASEID_COLUMN, timelineEvent.caseId());
   values.put(TYPE_COLUMN, timelineEvent.type());
   values.put(REF_DATE_COLUMN, timelineEvent.referenceDate().toString());
   values.put(TITLE_COLUMN, timelineEvent.title());
   values.put(DETAIL1_COLUMN, timelineEvent.detail1());
   values.put(DETAIL2_COLUMN, timelineEvent.detail2());
   return values;
 }
 public void add(TimelineEvent timelineEvent) {
   Log.e("Timeline", " Created " + timelineEvent.caseId() + "--" + timelineEvent.title());
   SQLiteDatabase database = masterRepository.getWritableDatabase();
   database.insert(TIMELINEEVENT_TABLE_NAME, null, createValuesFor(timelineEvent));
 }