### Question:
DevicePrintService { public UserProfile getBestMatchingUserProfile(DevicePrint devicePrint) { SortedMap<ComparisonResult, UserProfile> comparisonResultMap = new TreeMap<ComparisonResult, UserProfile>(); for (UserProfile userProfile : getNotExpiredProfiles()) { DevicePrint storedDevicePrint = userProfile.getDevicePrint(); comparisonResultMap.put(devicePrintComparator.compare(devicePrint, storedDevicePrint, devicePrintAuthenticationConfig), userProfile); } if (comparisonResultMap.isEmpty()) { return null; } ComparisonResult selectedComparisonResult = comparisonResultMap.firstKey(); UserProfile selectedProfile = null; if (selectedComparisonResult.getPenaltyPoints() <= devicePrintAuthenticationConfig.getLong( DevicePrintAuthenticationConfig.MAX_TOLERATED_PENALTY_POINTS)) { selectedProfile = comparisonResultMap.get(selectedComparisonResult); } return selectedProfile; } DevicePrintService(DevicePrintAuthenticationConfig devicePrintAuthenticationConfig,
            UserProfilesDao userProfilesDao, DevicePrintExtractorFactory extractorFactory,
            DevicePrintComparator devicePrintComparator); boolean hasRequiredAttributes(DevicePrint devicePrint); DevicePrint getDevicePrint(HttpServletRequest request); UserProfile getBestMatchingUserProfile(DevicePrint devicePrint); void createNewProfile(DevicePrint devicePrint); void updateProfile(UserProfile profile, DevicePrint devicePrint);  }### Answer:
@Test public void shouldGetBestMatchingUserProfileWithNoStoredProfiles() { DevicePrint devicePrint = mock(DevicePrint.class); List<UserProfile> userProfiles = new ArrayList<UserProfile>(); given(userProfilesDao.getProfiles()).willReturn(userProfiles); UserProfile selectedUserProfile = devicePrintService.getBestMatchingUserProfile(devicePrint); assertNull(selectedUserProfile); }