### Question:
UrlBuilder { public String buildUrl(Map<String, ?> allColumnValues) { Set<String> missing = getMissingColumns(allColumnValues.keySet()); if (!missing.isEmpty()) { logger.log(Level.WARNING, "Missing value(s) for URL column(s): {0}", missing); return null; } List<Object> values = new ArrayList<Object>(); for (String col : columns) { if (allColumnValues.get(col) == null) { logger.log(Level.WARNING, "Missing value for URL column: {0}", col); return null; } if (columnsToEscape.contains(col)) { values.add(escaper.escape(allColumnValues.get(col).toString())); } else { values.add(allColumnValues.get(col)); } } return MessageFormat.format(format, values.toArray()); } private  UrlBuilder(Builder builder); String buildUrl(Map<String, ?> allColumnValues); Set<String> getMissingColumns(Set<String> allColumns); static UrlBuilder fromConfiguration(); static final String CONFIG_FORMAT; static final String CONFIG_COLUMNS; static final String CONFIG_COLUMNS_TO_ESCAPE; }### Answer:
@Test public void testBuilder() { UrlBuilder urlBuilder = new Builder() .setFormat("http: .setColumns(ImmutableSet.of("id", "name")) .setColumnsToEscape(ImmutableSet.of("name")) .build(); Map<String, Object> allColumnValues = new HashMap<String, Object>(); allColumnValues.put("id", "1#2#3"); allColumnValues.put("name", "product 1"); String golden = "http: assertEquals(golden, urlBuilder.buildUrl(allColumnValues)); }
@Test public void testBuilder_emptyColumnsToEscape() { UrlBuilder urlBuilder = new Builder() .setFormat("http: .setColumns(ImmutableSet.of("id", "name")) .setColumnsToEscape(ImmutableSet.of()) .build(); Map<String, Object> allColumnValues = new HashMap<String, Object>(); allColumnValues.put("id", "1#2#3"); allColumnValues.put("name", "product 1"); String golden = "http: assertEquals(golden, urlBuilder.buildUrl(allColumnValues)); }