JMeadowsQueryBuilder { public JMeadowsQuery build() { JMeadowsQuery queryBean = new JMeadowsQuery(); queryBean.setActive(active); queryBean.setItemId(itemId); queryBean.setStatus(status); queryBean.setSortBy(sortBy); queryBean.setRecordSiteCode(recordSiteCode); queryBean.setMax(max); queryBean.setRequestingApp(requestingAppName); queryBean.setUser(user); queryBean.setPatient(patient); XMLGregorianCalendar startXmlDate = null; XMLGregorianCalendar endXmlDate = null; if (startDate != null) { startXmlDate = toXMLGregorianCalendar(pushCalendarToStartOfDay(startDate)); } if (endDate != null) { endXmlDate = toXMLGregorianCalendar(pushCalendarToEndOfDay(endDate)); } queryBean.setStartDate(startXmlDate); queryBean.setEndDate(endXmlDate); return queryBean; } JMeadowsQueryBuilder(); JMeadowsQueryBuilder active(Integer active); JMeadowsQueryBuilder endDate(Calendar endDate); JMeadowsQueryBuilder itemId(String itemId); JMeadowsQueryBuilder max(Integer max); JMeadowsQueryBuilder patient(Patient patient); JMeadowsQueryBuilder recordSiteCode(String recordSiteCode); JMeadowsQueryBuilder sortBy(String sortBy); JMeadowsQueryBuilder startDate(Calendar startDate); JMeadowsQueryBuilder status(String status); JMeadowsQueryBuilder user(User user); JMeadowsQuery build();  }
@Test public void testBuild() { JMeadowsQuery query = new JMeadowsQueryBuilder() .active(active) .endDate(endDate) .itemId(itemId) .max(max) .patient(patient) .recordSiteCode(recordSiteCode) .sortBy(sortBy) .startDate(startDate) .status(status) .user(user) .build(); assertThat(query.getActive(), is(active)); endDate.set(Calendar.HOUR_OF_DAY, 23); endDate.set(Calendar.MINUTE, 59); endDate.set(Calendar.SECOND, 59); assertThat(query.getEndDate().toGregorianCalendar().getTime(), is(endDate.getTime())); assertThat(query.getItemId(), is(itemId)); assertThat(query.getMax(), is(max)); assertThat(query.getPatient().getName(), is(patient.getName())); assertThat(query.getRecordSiteCode(), is(recordSiteCode)); assertThat(query.getSortBy(), is(sortBy)); startDate.set(Calendar.HOUR_OF_DAY, 0); startDate.set(Calendar.MINUTE, 0); startDate.set(Calendar.SECOND, 0); assertThat(query.getStartDate().toGregorianCalendar().getTime(), is(startDate.getTime())); assertThat(query.getStatus(), is(status)); assertThat(query.getUser().getName(), is(user.getName())); }