### Question:
PatternQueryHandler extends InstancesQueryHandler { protected String replaceVars(String queryStr, Set<String> varNames) { String command = queryStr; Pattern pattern = Pattern.compile("%%var[0-9]+%%"); Matcher m = pattern.matcher(queryStr); while(m.find()) { String eVar = m.group(); String var = eVar.replace("%", ""); command = command.replace(eVar, "?"+var); varNames.add(var); } return command; } PatternQueryHandler(List<Worker> workers, String endpoint);  PatternQueryHandler(LinkedList<Worker> workers, String endpoint, String limit);  PatternQueryHandler(LinkedList<Worker> workers, String endpoint, Long limit);   }### Answer:
@Test public void testReplacement(){ Set<String> varNames = new HashSet<String>(); String replacedQuery = getHandler().replaceVars(this.queryStr, varNames); assertEquals(expectedReplacedQuery, replacedQuery); assertEquals(Sets.newHashSet(vars), varNames); }