### Question:
PatientSearchCriteria { MatchMode getMatchMode() { String matchMode = Context.getAdministrationService().getGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_START); if (matchMode.equalsIgnoreCase(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_ANYWHERE)) { return MatchMode.ANYWHERE; } return MatchMode.START; } PatientSearchCriteria(SessionFactory sessionFactory, Criteria criteria); Criteria prepareCriteria(String name, String identifier, List<PatientIdentifierType> identifierTypes,
	        boolean matchIdentifierExactly, boolean orderByNames, boolean searchOnNamesOrIdentifiers);  }### Answer:
@Test public void getMatchMode_shouldReturnStartAsDefaultMatchMode() { globalPropertiesTestHelper.purgeGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE); Assert.assertEquals(MatchMode.START, patientSearchCriteria.getMatchMode()); }
@Test public void getMatchMode_shouldReturnStartAsConfiguredMatchMode() { String oldPropertyValue = globalPropertiesTestHelper.setGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_START); Assert.assertEquals(MatchMode.START, patientSearchCriteria.getMatchMode()); if (oldPropertyValue != null) { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, oldPropertyValue); } else { globalPropertiesTestHelper.purgeGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE); } }
@Test public void getMatchMode_shouldReturnAnywhereAsConfiguredMatchMode() { String oldPropertyValue = globalPropertiesTestHelper.setGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_ANYWHERE); Assert.assertEquals(MatchMode.ANYWHERE, patientSearchCriteria.getMatchMode()); if (oldPropertyValue != null) { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, oldPropertyValue); } else { globalPropertiesTestHelper.purgeGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE); } }
@Test public void getMatchMode_shouldReturnStartAsDefaultMatchMode() throws Exception { globalPropertiesTestHelper.purgeGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE); Assert.assertEquals(MatchMode.START, patientSearchCriteria.getMatchMode()); }
@Test public void getMatchMode_shouldReturnStartAsConfiguredMatchMode() throws Exception { String oldPropertyValue = globalPropertiesTestHelper.setGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_START); Assert.assertEquals(MatchMode.START, patientSearchCriteria.getMatchMode()); if (oldPropertyValue != null) { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, oldPropertyValue); } else { globalPropertiesTestHelper.purgeGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE); } }
@Test public void getMatchMode_shouldReturnAnywhereAsConfiguredMatchMode() throws Exception { String oldPropertyValue = globalPropertiesTestHelper.setGlobalProperty( OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_ANYWHERE); Assert.assertEquals(MatchMode.ANYWHERE, patientSearchCriteria.getMatchMode()); if (oldPropertyValue != null) { globalPropertiesTestHelper.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE, oldPropertyValue); } else { globalPropertiesTestHelper.purgeGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_SEARCH_MATCH_MODE); } }