QuestionGroupFilterForLoan implements QuestionGroupFilter { @Override public <T> List<T> doFilter(List<T> t, Criteria<T> criteria) { if (t == null || loanOfferingBO == null) return t; List<T> filteredResult = new ArrayList<T>(); Set<QuestionGroupReference> questionGroupReferences = loanOfferingBO.getQuestionGroups(); if (questionGroupReferences != null) { for (QuestionGroupReference questionGroupReference : questionGroupReferences) { T result = criteria.filter(questionGroupReference.getQuestionGroupId(), t); if (result != null) filteredResult.add(result); } } return filteredResult; }  void setLoanOfferingBO(LoanOfferingBO loanOfferingBO); @Override List<T> doFilter(List<T> t, Criteria<T> criteria);  }
@Test public void shouldDoFilterForNoLoanOfferBO() { QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan(); List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4")); List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails,null); assertThat(filteredQuestionGroupDetails, is(questionGroupDetails)); }