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();
}
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);
}
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");
}
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();
}
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");
}
Aggregations