### Question:
RadiologyOrderSearchHandler implements SearchHandler { @Override public PageableResult search(RequestContext context) throws ResponseException { final String patientUuid = context.getRequest() .getParameter(REQUEST_PARAM_PATIENT); Patient patient = null; if (StringUtils.isNotBlank(patientUuid)) { patient = ((PatientResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Patient.class)).getByUniqueId(patientUuid); if (patient == null) { return new EmptySearchResult(); } } final String fromEffectiveStartDateString = context.getRequest() .getParameter(REQUEST_PARAM_EFFECTIVE_START_DATE_FROM); Date fromEffectiveStartDate = null; if (StringUtils.isNotBlank(fromEffectiveStartDateString)) { fromEffectiveStartDate = (Date) ConversionUtil.convert(fromEffectiveStartDateString, java.util.Date.class); } final String toEffectiveStartDateString = context.getRequest() .getParameter(REQUEST_PARAM_EFFECTIVE_START_DATE_TO); Date toEffectiveStartDate = null; if (StringUtils.isNotBlank(toEffectiveStartDateString)) { toEffectiveStartDate = (Date) ConversionUtil.convert(toEffectiveStartDateString, java.util.Date.class); } final String urgencyString = context.getRequest() .getParameter(REQUEST_PARAM_URGENCY); Urgency urgency = null; if (StringUtils.isNotBlank(urgencyString)) { urgency = Urgency.valueOf(urgencyString); } final String accessionNumber = context.getRequest() .getParameter(REQUEST_PARAM_ACCESSION_NUMBER); final RadiologyOrderSearchCriteria radiologyOrderSearchCriteria = new RadiologyOrderSearchCriteria.Builder().withAccessionNumber(accessionNumber) .withPatient(patient) .fromEffectiveStartDate(fromEffectiveStartDate) .toEffectiveStartDate(toEffectiveStartDate) .withUrgency(urgency) .build(); final List<RadiologyOrder> result = radiologyOrderService.getRadiologyOrders(radiologyOrderSearchCriteria); if (result.isEmpty()) { return new EmptySearchResult(); } return new NeedsPaging<RadiologyOrder>(result, context); }  @Override SearchConfig getSearchConfig(); @Override PageableResult search(RequestContext context); static final String REQUEST_PARAM_ACCESSION_NUMBER; static final String REQUEST_PARAM_PATIENT; static final String REQUEST_PARAM_EFFECTIVE_START_DATE_FROM; static final String REQUEST_PARAM_EFFECTIVE_START_DATE_TO; static final String REQUEST_PARAM_URGENCY; static final String REQUEST_PARAM_TOTAL_COUNT; }### Answer:
@Test public void shouldReturnEmptySearchResultIfPatientCannotBeFound() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter(RadiologyOrderSearchHandler.REQUEST_PARAM_PATIENT, PATIENT_UUID_UNKNOWN); RequestContext requestContext = new RequestContext(); requestContext.setRequest(request); PageableResult pageableResult = radiologyOrderSearchHandler.search(requestContext); assertThat(pageableResult, is(instanceOf(EmptySearchResult.class))); }
@Test public void shouldReturnEmptySearchResultIfPatientHasNoRadiologyOrders() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.setParameter(RadiologyOrderSearchHandler.REQUEST_PARAM_PATIENT, PATIENT_UUID_WITHOUT_ORDERS); RequestContext requestContext = new RequestContext(); requestContext.setRequest(request); PageableResult pageableResult = radiologyOrderSearchHandler.search(requestContext); assertThat(pageableResult, is(instanceOf(EmptySearchResult.class))); }