hashMap.put("var2", new String[] {"a", "b"});
assertEquals("instantiate template", "artifacts", template.expand(hashMap));
}
public void testPrefixOperator() {
UriTemplateProcessor template = new BitWorkingUriTemplateProcessor("{-prefix|/|var}/cat");
UriTemplateProcessor template3 =
new BitWorkingUriTemplateProcessor("telegram:{-prefix|stop|var}");
String[][] animalsVar = {{"var", "animals"}};
String[][] noVar = {{"var", null}};
String[][] emptyVar = {{"var", ""}};
String[][] domesticAnimalsVar = {{"var", "animals", "domestic"}};
String[][] message = {{"var", "hello", "baby", "go", "home"}};
assertMatchTemplate(template, "/animals/cat", animalsVar);
assertMatchTemplate(template, "/cat", noVar);
assertMatchTemplate(template, "//cat", emptyVar);
assertMatchTemplate(template, "/animals;cat", null);
assertMatchTemplate(template, "animals/cat", null);
try {
new BitWorkingUriTemplateProcessor("/{-prefix|/|var1,var2}cat");
fail("-prefix accepts only one variable");
} catch (IllegalArgumentException e) {
} // ok
assertMatchTemplate(template, "/animals/domestic/cat", domesticAnimalsVar);
assertMatchTemplate(template3, "telegram:stophellostopbabystopgostophome", message);
HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("var", "animals");
assertEquals("instantiate template", "/animals/cat", template.expand(hashMap));
hashMap = new HashMap<String, Object>();
hashMap.put("var", "");
assertEquals("instantiate template", "//cat", template.expand(hashMap));
hashMap = new HashMap<String, Object>();
assertEquals("instantiate template", "/cat", template.expand(hashMap));
hashMap = new HashMap<String, Object>();
hashMap.put("", "");
assertEquals("instantiate template", "/cat", template.expand(hashMap));
hashMap = new HashMap<String, Object>();
hashMap.put("", "pets");
assertEquals("instantiate template", "/cat", template.expand(hashMap));
hashMap = new HashMap<String, Object>();
hashMap.put("var", new String[] {"animals", "domestic"});
assertEquals("instantiate template", "/animals/domestic/cat", template.expand(hashMap));
hashMap = new HashMap<String, Object>();
hashMap.put("var", new String[] {"hello", "baby", "go", "home"});
assertEquals("instantiate template3", "telegram:stophellostopbabystopgostophome", template3
.expand(hashMap));
}