CallFormatter { public String formatForCalendar(int callType, String number, int duration) { StringBuilder description = new StringBuilder(); description.append(resources.getString(R.string.call_number_field, number)) .append(" (") .append(callTypeString(callType, null)) .append(")") .append("\n"); if (callType != CallLog.Calls.MISSED_TYPE) { description.append(resources.getString(R.string.call_duration_field, formattedCallDuration(duration))); } return description.toString(); } CallFormatter(Resources resources); String format(int callType, String number, int duration); String formatForCalendar(int callType, String number, int duration); String formattedCallDuration(int duration); String callTypeString(int callType, String name);  }
@Test public void shouldFormatForCalendarOutgoing() throws Exception { assertThat(formatter.formatForCalendar(CallLog.Calls.OUTGOING_TYPE, "Foo", 100)) .isEqualTo("Number: Foo (outgoing call)\n" + "Duration: 00:01:40"); }
@Test public void shouldFormatForCalendarIncoming() throws Exception { assertThat(formatter.formatForCalendar(CallLog.Calls.INCOMING_TYPE, "Foo", 100)) .isEqualTo("Number: Foo (incoming call)\n" + "Duration: 00:01:40"); }
@Test public void shouldFormatForCalendarMissed() throws Exception { assertThat(formatter.formatForCalendar(CallLog.Calls.MISSED_TYPE, "Foo", 100)) .isEqualTo("Number: Foo (missed call)\n"); }