### Question:
IMDBTransactionDao implements TransactionDao { @Override public DataSource.Factory<Integer, HttpTransaction> getAllTransactionsWith(String key, SearchType searchType) { Predicate<HttpTransaction> predicate; switch (searchType) { case DEFAULT: default: predicate = transactionPredicateProvider.getDefaultSearchPredicate(key); break; case INCLUDE_REQUEST: predicate = transactionPredicateProvider.getRequestSearchPredicate(key); break; case INCLUDE_RESPONSE: predicate = transactionPredicateProvider.getResponseSearchPredicate(key); break; case INCLUDE_REQUEST_RESPONSE: predicate = transactionPredicateProvider.getRequestResponseSearchPredicate(key); break; } return transactionArchComponentProvider.getDataSourceFactory(transactionDataStore, predicate); } IMDBTransactionDao(TransactionDataStore transactionDataStore, TransactionArchComponentProvider transactionArchComponentProvider, TransactionPredicateProvider transactionPredicateProvider); @Override long insertTransaction(HttpTransaction httpTransaction); @Override int updateTransaction(HttpTransaction httpTransaction); @Override int deleteTransactions(HttpTransaction... httpTransactions); @Override int deleteTransactionsBefore(Date beforeDate); @Override int clearAll(); @Override DataSource.Factory<Integer, HttpTransaction> getAllTransactions(); @Override LiveData<HttpTransaction> getTransactionsWithId(long id); @Override DataSource.Factory<Integer, HttpTransaction> getAllTransactionsWith(String key, SearchType searchType);  }### Answer:
@Test public void getAllTransactionsWithDefault_shouldCallArchComponentProviderWithRequestedSearchTermAndDefaultSearchPredicate() { when(transactionPredicateProvider.getDefaultSearchPredicate("test")).thenReturn(testPredicate); transactionDao.getAllTransactionsWith("test", TransactionDao.SearchType.DEFAULT); verify(transactionPredicateProvider).getDefaultSearchPredicate("test"); verify(transactionArchComponentProvider).getDataSourceFactory(eq(transactionDataStore), eq(testPredicate)); }
@Test public void getAllTransactionsWithRequest_shouldCallArchComponentProviderWithRequestedSearchTermAndRequestSearchPredicate() { when(transactionPredicateProvider.getRequestSearchPredicate("test")).thenReturn(testPredicate); transactionDao.getAllTransactionsWith("test", TransactionDao.SearchType.INCLUDE_REQUEST); verify(transactionPredicateProvider).getRequestSearchPredicate("test"); verify(transactionArchComponentProvider).getDataSourceFactory(eq(transactionDataStore), eq(testPredicate)); }
@Test public void getAllTransactionsWithResponse_shouldCallArchComponentProviderWithRequestedSearchTermAndResponseSearchPredicate() { when(transactionPredicateProvider.getResponseSearchPredicate("test")).thenReturn(testPredicate); transactionDao.getAllTransactionsWith("test", TransactionDao.SearchType.INCLUDE_RESPONSE); verify(transactionPredicateProvider).getResponseSearchPredicate("test"); verify(transactionArchComponentProvider).getDataSourceFactory(eq(transactionDataStore), eq(testPredicate)); }
@Test public void getAllTransactionsWithRequestResponse_shouldCallArchComponentProviderWithRequestedSearchTermAndRequestResponseSearchPredicate() { when(transactionPredicateProvider.getRequestResponseSearchPredicate("test")).thenReturn(testPredicate); transactionDao.getAllTransactionsWith("test", TransactionDao.SearchType.INCLUDE_REQUEST_RESPONSE); verify(transactionPredicateProvider).getRequestResponseSearchPredicate("test"); verify(transactionArchComponentProvider).getDataSourceFactory(eq(transactionDataStore), eq(testPredicate)); }