Search in sources :

Example 1 with ContactsProvider

use of com.alexstyl.specialdates.contact.ContactsProvider in project Memento-Calendar by alexstyl.

the class ContactsSearchTest method returnEmptyForNoContacts.

@Test
public void returnEmptyForNoContacts() {
    ContactsProvider contactsProvider = mock(ContactsProvider.class);
    when(contactsProvider.getAllContacts()).thenReturn(Collections.<Contact>emptyList());
    ContactsSearch search = new ContactsSearch(contactsProvider, NameMatcher.INSTANCE);
    List<Contact> results = search.searchForContacts("there is no contact with a name like this", 1);
    assertThat(results).isEmpty();
}
Also used : ContactsProvider(com.alexstyl.specialdates.contact.ContactsProvider) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Example 2 with ContactsProvider

use of com.alexstyl.specialdates.contact.ContactsProvider in project Memento-Calendar by alexstyl.

the class ContactsSearchTest method ensureThatCounterIsRespected.

@Test
public void ensureThatCounterIsRespected() {
    ContactsProvider contactsProvider = mock(ContactsProvider.class);
    when(contactsProvider.getAllContacts()).thenReturn(contacts("Alex Styl", "Alex Evil Twin"));
    ContactsSearch search = new ContactsSearch(contactsProvider, NameMatcher.INSTANCE);
    List<Contact> oneContact = search.searchForContacts("Alex", 1);
    assertThat(oneContact.size()).isEqualTo(1);
    List<Contact> twoContacts = search.searchForContacts("Alex", 2);
    assertThat(twoContacts.size()).isEqualTo(2);
}
Also used : ContactsProvider(com.alexstyl.specialdates.contact.ContactsProvider) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Example 3 with ContactsProvider

use of com.alexstyl.specialdates.contact.ContactsProvider in project Memento-Calendar by alexstyl.

the class ContactsSearchTest method canFindSurname.

@Test
public void canFindSurname() {
    ContactsProvider contactsProvider = mock(ContactsProvider.class);
    when(contactsProvider.getAllContacts()).thenReturn(contacts("Alex Styl", "Alex Evil Twin", "Anna Papadopoulou"));
    ContactsSearch search = new ContactsSearch(contactsProvider, NameMatcher.INSTANCE);
    List<Contact> oneContact = search.searchForContacts("Papadopoulou", 1);
    assertThat(oneContact.size()).isEqualTo(1);
    assertThat(oneContact.get(0).getDisplayName().toString()).isEqualTo("Anna Papadopoulou");
}
Also used : ContactsProvider(com.alexstyl.specialdates.contact.ContactsProvider) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Example 4 with ContactsProvider

use of com.alexstyl.specialdates.contact.ContactsProvider in project Memento-Calendar by alexstyl.

the class ContactsSearchTest method returnEmptyForNoMatches.

@Test
public void returnEmptyForNoMatches() {
    ContactsProvider contactsProvider = mock(ContactsProvider.class);
    when(contactsProvider.getAllContacts()).thenReturn(contacts("Alex Styl", "Alex Evil Twin", "Anna Papadopoulou"));
    ContactsSearch search = new ContactsSearch(contactsProvider, NameMatcher.INSTANCE);
    List<Contact> results = search.searchForContacts("there is no contact with a name like this", 1);
    assertThat(results).isEmpty();
}
Also used : ContactsProvider(com.alexstyl.specialdates.contact.ContactsProvider) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Example 5 with ContactsProvider

use of com.alexstyl.specialdates.contact.ContactsProvider in project Memento-Calendar by alexstyl.

the class ContactsSearchTest method canFindFirstname.

@Test
public void canFindFirstname() {
    ContactsProvider contactsProvider = mock(ContactsProvider.class);
    when(contactsProvider.getAllContacts()).thenReturn(contacts("Alex Styl", "Alex Evil Twin", "Anna Papadopoulou"));
    ContactsSearch search = new ContactsSearch(contactsProvider, NameMatcher.INSTANCE);
    List<Contact> oneContact = search.searchForContacts("Anna", 1);
    assertThat(oneContact.size()).isEqualTo(1);
    assertThat(oneContact.get(0).getDisplayName().toString()).isEqualTo("Anna Papadopoulou");
}
Also used : ContactsProvider(com.alexstyl.specialdates.contact.ContactsProvider) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Aggregations

Contact (com.alexstyl.specialdates.contact.Contact)5 ContactsProvider (com.alexstyl.specialdates.contact.ContactsProvider)5 Test (org.junit.Test)5