@Test public void testMergeSummaryData() { CoursesByTerm summary1 = new CoursesByTerm(); summary1.setGpa((double) 3.3); summary1.setCredits((double) 40); ICoursesDao courseDao1 = mock(ICoursesDao.class); when(courseDao1.getCoursesByTerm(request, "1234")).thenReturn(summary1); courseDaos.add(courseDao1); CoursesByTerm summary2 = new CoursesByTerm(); summary2.setGpa((double) 3.5); summary2.setCredits((double) 30); ICoursesDao courseDao2 = mock(ICoursesDao.class); when(courseDao2.getCoursesByTerm(request, "1234")).thenReturn(summary2); courseDaos.add(courseDao2); dao.getCoursesByTerm(request, "1234"); assertEquals(3.5, summary1.getGpa(), 0.1); assertEquals(30, summary2.getCredits(), 0.1); }
@Override public CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode) { CoursesByTerm summary = null; for (ICoursesDao dao : courseDaos) { try { CoursesByTerm daoSummary = dao.getCoursesByTerm(request, termCode); if (summary == null) { summary = daoSummary; } else { mergeCourseSummaries(summary, daoSummary); } } catch (Exception e) { log.error("Exception reading course dao", e); } } return summary; }
MergingCoursesDaoImpl implements ICoursesDao { @Override public CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode) { CoursesByTerm summary = null; for (ICoursesDao dao : courseDaos) { try { CoursesByTerm daoSummary = dao.getCoursesByTerm(request, termCode); if (summary == null) { summary = daoSummary; } else { mergeCourseSummaries(summary, daoSummary); } } catch (Exception e) { log.error("Exception reading course dao", e); } } return summary; } }
MergingCoursesDaoImpl implements ICoursesDao { @Override public CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode) { CoursesByTerm summary = null; for (ICoursesDao dao : courseDaos) { try { CoursesByTerm daoSummary = dao.getCoursesByTerm(request, termCode); if (summary == null) { summary = daoSummary; } else { mergeCourseSummaries(summary, daoSummary); } } catch (Exception e) { log.error("Exception reading course dao", e); } } return summary; }  }
MergingCoursesDaoImpl implements ICoursesDao { @Override public CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode) { CoursesByTerm summary = null; for (ICoursesDao dao : courseDaos) { try { CoursesByTerm daoSummary = dao.getCoursesByTerm(request, termCode); if (summary == null) { summary = daoSummary; } else { mergeCourseSummaries(summary, daoSummary); } } catch (Exception e) { log.error("Exception reading course dao", e); } } return summary; }  @Resource(name="courseDaos") void setCourseDaos(List<ICoursesDao> courseDaos); @Override TermList getTermList(PortletRequest request); @Override CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode); }
MergingCoursesDaoImpl implements ICoursesDao { @Override public CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode) { CoursesByTerm summary = null; for (ICoursesDao dao : courseDaos) { try { CoursesByTerm daoSummary = dao.getCoursesByTerm(request, termCode); if (summary == null) { summary = daoSummary; } else { mergeCourseSummaries(summary, daoSummary); } } catch (Exception e) { log.error("Exception reading course dao", e); } } return summary; }  @Resource(name="courseDaos") void setCourseDaos(List<ICoursesDao> courseDaos); @Override TermList getTermList(PortletRequest request); @Override CoursesByTerm getCoursesByTerm(PortletRequest request, String termCode);  }