ProviderSearchLookupServiceImpl implements
		ProviderSearchLookupService { @Override public boolean isValidatedSearch(String usstate, String city, String zipcode, String gender, String specialty, String phone, String firstname, String lastname, String facilityName) { boolean validateCall = true; if (usstate == null && city == null && zipcode == null && phone == null && specialty == null && firstname == null && lastname == null && gender == null) validateCall = false; if (usstate != null && zipcode != null) validateCall = false; if (usstate != null) { if (usstate.matches("[a-zA-Z][a-zA-Z]") == true) { List<LookupDto> stateCodes = stateCodeService .findAllStateCodes(); boolean isValidStateCode = false; for (LookupDto stateCode : stateCodes) { if (usstate.compareToIgnoreCase(stateCode.getCode()) == 0) { isValidStateCode = true; break; } } if (isValidStateCode != true) { validateCall = false; } } else validateCall = false; } if (city != null && city.length() < 3) validateCall = false; if (zipcode != null && zipcode.length() < 5) validateCall = false; if (specialty != null && specialty.length() < 3) validateCall = false; if (phone != null && phone.length() != 10) validateCall = false; if (firstname != null && firstname.length() < 2) validateCall = false; if (lastname != null && lastname.length() < 2) validateCall = false; if (city != null && usstate == null) validateCall = false; return validateCall; } ProviderSearchLookupServiceImpl(String providerSearchURL,
			StateCodeService stateCodeService); @Override String getProviderSearchURL(); @Override void setProviderSearchURL(String providerSearchURL); @Override String providerSearch(String usstate, String city, String zipcode,
			String gender, String specialty, String phone, String firstname,
			String lastname, String facilityName, int pageNumber); @Override String providerSearch(String usstate, String city, String zipcode,
			String gender, String specialty, String phone, String firstname,
			String lastnameOrFacilityName, int pageNumber); @Override String providerSearchByNpi(String npi); @Override String callProviderSearch(String query); @Override String generateProviderSearchURL(String usstate, String city,
			String zipcode, String gender, String specialty, String phone,
			String firstname, String lastname, String facilityName,
			int pageNumber); @Override String generateProviderSearchURL(String usstate, String city,
			String zipcode, String gender, String specialty, String phone,
			String firstname, String lastnameOrFacilityName, int pageNumber); @Override boolean isValidatedSearch(String usstate, String city,
			String zipcode, String gender, String specialty, String phone,
			String firstname, String lastname, String facilityName);  }
@Test public void testIsValidatedSearch_All_Field_Is_Blank() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch(null, null, null, null, null, null, null, null, null); assertEquals(false, validateCall); }
@Test public void testIsValidatedSearch_When_Only_City_Given() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch(null, "columbia", null, null, null, null, null, null, null); assertEquals(false, validateCall); }
@Test public void testIsValidatedSearch_When_State_City_Given() { LookupDto stateCode = mock(LookupDto.class); List<LookupDto> stateCodes = new ArrayList<LookupDto>(); stateCodes.add(stateCode); when(stateCodeService.findAllStateCodes()).thenReturn(stateCodes); when(stateCode.getCode()).thenReturn("MD"); Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch("MD", "columbia", null, null, null, null, null, null, null); assertEquals(true, validateCall); }
@Test public void testIsValidatedSearch_When_City_Length_Less_Than_Three() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch("MD", "co", null, null, null, null, null, null, null); assertEquals(false, validateCall); }
@Test public void testIsValidatedSearch_When_Zipcode_Less_Than_Five() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch(null, null, "2104", null, null, null, null, null, null); assertEquals(false, validateCall); }
@Test public void testIsValidatedSearch_When_State_And_Zipcode_Given() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch("MD", null, "21046", null, null, null, null, null, null); assertEquals(false, validateCall); }
@Test public void testIsValidatedSearch_When_Specialty_Less_Than_Three() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch(null, null, null, null, "br", null, null, null, null); assertEquals(false, validateCall); }
@Test public void testIsValidatedSearch_When_Phone_Length_Not_Equal_Ten() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch(null, null, null, null, null, "410552", null, null, null); assertEquals(false, validateCall); }
@Test public void testIsValidatedSearch_When_Firstname_Less_Than_Two() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch(null, null, null, null, null, null, "a", null, null); assertEquals(false, validateCall); }
@Test public void testIsValidatedSearch_When_Lastname_Less_Than_Two() { Boolean validateCall = providerSearchLookupServiceImpl .isValidatedSearch(null, null, null, null, null, null, null, null, "a"); assertEquals(false, validateCall); }