String contentTypes = "*/*";
//If acceptContentTypes does not specify a specific Mime type, the
//method is declared with a most specific ProduceMime type is selected.
MetadataMap<String, String> values = new MetadataMap<String, String>();
OperationResourceInfo ori = findTargetResourceClass(resources, null, "/1/2/",
"GET", values, contentTypes, getTypes("*/*"));
assertNotNull(ori);
assertEquals("getBooks", ori.getMethodToInvoke().getName());
assertEquals("Only id and final match groups should be there", 2, values.size());
assertEquals("2 {id} values should've been picked up", 2, values.get("id").size());
assertEquals("FINAL_MATCH_GROUP should've been picked up", 1,
values.get(URITemplate.FINAL_MATCH_GROUP).size());
assertEquals("First {id} is 1", "1", values.getFirst("id"));
assertEquals("Second id is 2", "2", values.get("id").get(1));
values = new MetadataMap<String, String>();
ori = findTargetResourceClass(resources, null, "/2",
"POST", values, contentTypes, getTypes("*/*"));
assertNotNull(ori);
assertEquals("updateBookStoreInfo", ori.getMethodToInvoke().getName());
assertEquals("Only id and final match groups should be there", 2, values.size());
assertEquals("Only single {id} should've been picked up", 1, values.get("id").size());
assertEquals("FINAL_MATCH_GROUP should've been picked up", 1,
values.get(URITemplate.FINAL_MATCH_GROUP).size());
assertEquals("Only the first {id} should've been picked up", "2", values.getFirst("id"));
values = new MetadataMap<String, String>();
ori = findTargetResourceClass(resources, null, "/3/4",
"PUT", values, contentTypes, getTypes("*/*"));
assertNotNull(ori);
assertEquals("updateBook", ori.getMethodToInvoke().getName());
assertEquals("Only the first {id} should've been picked up", 3, values.size());
assertEquals("Only the first {id} should've been picked up", 1, values.get("id").size());
assertEquals("Only the first {id} should've been picked up", 1, values.get("bookId").size());
assertEquals("Only the first {id} should've been picked up", 1,
values.get(URITemplate.FINAL_MATCH_GROUP).size());