Search in sources :

Example 1 with PersonRecord

use of com.zegoggles.smssync.mail.PersonRecord in project sms-backup-plus by jberkel.

the class ContactGroupsTest method shouldCheckForPerson.

@Test
public void shouldCheckForPerson() throws Exception {
    ContactGroupIds ids = new ContactGroupIds();
    PersonRecord record = new PersonRecord(22, "Test", "test@test.com", "123");
    assertThat(ids.contains(record)).isFalse();
    ids.add(22L, 44L);
    assertThat(ids.contains(record)).isTrue();
}
Also used : PersonRecord(com.zegoggles.smssync.mail.PersonRecord) Test(org.junit.Test)

Example 2 with PersonRecord

use of com.zegoggles.smssync.mail.PersonRecord in project sms-backup-plus by jberkel.

the class CalendarSyncer method syncCalendar.

public void syncCalendar(ConversionResult result) {
    enableSync();
    if (result.type != DataType.CALLLOG)
        return;
    for (Map<String, String> m : result.getMapList()) {
        try {
            final int duration = Integer.parseInt(m.get(CallLog.Calls.DURATION));
            final int callType = Integer.parseInt(m.get(CallLog.Calls.TYPE));
            final String number = m.get(CallLog.Calls.NUMBER);
            final Date then = new Date(Long.valueOf(m.get(CallLog.Calls.DATE)));
            final PersonRecord record = personLookup.lookupPerson(number);
            // insert into calendar
            calendarAccessor.addEntry(calendarId, then, duration, callFormatter.callTypeString(callType, record.getName()), callFormatter.formatForCalendar(callType, record.getNumber(), duration));
        } catch (NumberFormatException e) {
            Log.w(TAG, "error", e);
        }
    }
}
Also used : PersonRecord(com.zegoggles.smssync.mail.PersonRecord) Date(java.util.Date)

Example 3 with PersonRecord

use of com.zegoggles.smssync.mail.PersonRecord in project sms-backup-plus by jberkel.

the class CalendarSyncerTest method shouldSyncCalendar.

@Test
public void shouldSyncCalendar() throws Exception {
    ConversionResult result = new ConversionResult(DataType.CALLLOG);
    final String NUMBER = "12345";
    final String NAME = "Foo";
    final int DURATION = 10;
    final int TYPE = 1;
    Date callTime = new Date();
    result.add(new MimeMessage(), message(DURATION, TYPE, NUMBER, callTime));
    result.add(new MimeMessage(), message(DURATION, TYPE, NUMBER, callTime));
    when(callFormatter.callTypeString(TYPE, NAME)).thenReturn("title1");
    when(callFormatter.formatForCalendar(TYPE, NUMBER, DURATION)).thenReturn("title2");
    when(personLookup.lookupPerson(NUMBER)).thenReturn(new PersonRecord(1, NAME, "foo@bar", NUMBER));
    syncer.syncCalendar(result);
    verify(accessor, times(2)).addEntry(eq(CALENDAR_ID), eq(callTime), eq(DURATION), eq("title1"), eq("title2"));
}
Also used : ConversionResult(com.zegoggles.smssync.mail.ConversionResult) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) PersonRecord(com.zegoggles.smssync.mail.PersonRecord) Date(java.util.Date) Test(org.junit.Test)

Aggregations

PersonRecord (com.zegoggles.smssync.mail.PersonRecord)3 Date (java.util.Date)2 Test (org.junit.Test)2 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)1 ConversionResult (com.zegoggles.smssync.mail.ConversionResult)1