UserAgentImpl implements UserAgent, ProviderScanner { static void appendPairs(final Set<String> keys, final Map pairs, final StringBuilder destination, final String header, final String footer) { destination.append(header).append(NEW_LINE).append(NEW_LINE); final String[] keyArray = new String[keys.size()]; keys.toArray(keyArray); Arrays.sort(keyArray); for (final String key : keyArray) { final String encodedKey = sortOfUrlEncode(key); final String value = (String) pairs.get(key); final String encodedValue = value == null ? "" : sortOfUrlEncode(value); destination.append(encodedKey).append('=').append(encodedValue).append(NEW_LINE); } destination.append(NEW_LINE).append(footer).append(NEW_LINE); } UserAgentImpl();   UserAgentImpl(final TestableProcessFactory processFactory, final Provider provider, final List<Provider> candidateProviders); @Override Provider findCompatibleProvider(); @Override Provider findCompatibleProvider(final String userAgentProvider); @Override Map<Provider, List<String>> getUnmetProviderRequirements(); @Override boolean hasCompatibleProvider(); @Override boolean hasCompatibleProvider(final String userAgentProvider); @Override AuthorizationResponse requestAuthorizationCode(final URI authorizationEndpoint, final URI redirectUri); static StringBuilder buildUnsupportedMessage(Map<Provider, List<String>> unmetRequirements); static void describeUnmetRequirements(final Map<Provider, List<String>> unmetRequirements, final StringBuilder destination);  }
@Test public void appendPairs_nullValue() throws Exception { final StringBuilder sb = new StringBuilder(); final LinkedHashMap<String, String> variables = new LinkedHashMap<String, String>(); variables.put("HOME", null); UserAgentImpl.appendPairs(variables.keySet(), variables, sb, "BEGIN", "END"); assertLinesEqual(sb.toString(), "BEGIN", "", "HOME=", "", "END" ); }