CallFormatter { public String format(int callType, String number, int duration) { final StringBuilder text = new StringBuilder(); if (callType != CallLog.Calls.MISSED_TYPE && callType != CallLog.Calls.REJECTED_TYPE) { text.append(duration) .append("s") .append(" (").append(formattedCallDuration(duration)).append(")") .append("\n"); } text.append(number) .append(" (").append(callTypeString(callType, null)).append(")"); return text.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 shouldFormatIncoming() throws Exception { assertThat(formatter.format(CallLog.Calls.INCOMING_TYPE, "Foo", 100)) .isEqualTo("100s (00:01:40)\n" + "Foo (incoming call)"); }
@Test public void shouldFormatOutgoing() throws Exception { assertThat(formatter.format(CallLog.Calls.OUTGOING_TYPE, "Foo", 100)) .isEqualTo("100s (00:01:40)\n" + "Foo (outgoing call)"); }
@Test public void shouldFormatMissing() throws Exception { assertThat(formatter.format(CallLog.Calls.MISSED_TYPE, "Foo", 100)) .isEqualTo("Foo (missed call)"); }
@Test public void shouldFormatRejected() throws Exception { assertThat(formatter.format(CallLog.Calls.REJECTED_TYPE, "Foo", 0)) .isEqualTo("Foo (incoming call, rejected)"); }
@Test public void shouldFormatVoicemail() throws Exception { assertThat(formatter.format(CallLog.Calls.VOICEMAIL_TYPE, "Foo", 100)) .isEqualTo("100s (00:01:40)\n" + "Foo (incoming call, voicemail)"); }