assertNotNull(rootCri.getURITemplate());
URITemplate template = rootCri.getURITemplate();
MultivaluedMap<String, String> values = new MetadataMap<String, String>();
assertTrue(template.match("/bookstore/books/123", values));
assertTrue(rootCri.hasSubResources());
MethodDispatcher md = rootCri.getMethodDispatcher();
assertEquals(6, md.getOperationResourceInfos().size());
for (OperationResourceInfo ori : md.getOperationResourceInfos()) {
if ("getDescription".equals(ori.getMethod().getName())) {
assertEquals("GET", ori.getHttpMethod());
assertEquals("/path", ori.getURITemplate().getValue());
assertEquals("text/bar", ori.getProduceTypes().get(0).toString());
assertEquals("text/foo", ori.getConsumeTypes().get(0).toString());
assertFalse(ori.isSubResourceLocator());
} else if ("getAuthor".equals(ori.getMethod().getName())) {
assertEquals("GET", ori.getHttpMethod());
assertEquals("/path2", ori.getURITemplate().getValue());
assertEquals("text/bar2", ori.getProduceTypes().get(0).toString());
assertEquals("text/foo2", ori.getConsumeTypes().get(0).toString());
assertFalse(ori.isSubResourceLocator());
} else if ("getBook".equals(ori.getMethod().getName())) {
assertNull(ori.getHttpMethod());
assertNotNull(ori.getURITemplate());
assertTrue(ori.isSubResourceLocator());
} else if ("addBook".equals(ori.getMethod().getName())) {
assertEquals("POST", ori.getHttpMethod());
assertNotNull(ori.getURITemplate());
assertFalse(ori.isSubResourceLocator());
} else if ("updateBook".equals(ori.getMethod().getName())) {
assertEquals("PUT", ori.getHttpMethod());
assertNotNull(ori.getURITemplate());
assertFalse(ori.isSubResourceLocator());
} else if ("deleteBook".equals(ori.getMethod().getName())) {
assertEquals("DELETE", ori.getHttpMethod());
assertNotNull(ori.getURITemplate());
assertFalse(ori.isSubResourceLocator());
} else {
fail("unexpected OperationResourceInfo" + ori.getMethod().getName());
}
}
// Verify sub-resource ClassResourceInfo: Book
assertEquals(1, rootCri.getSubClassResourceInfo().size());
ClassResourceInfo subCri = rootCri.getSubClassResourceInfo().get(0);
assertNull(subCri.getURITemplate());
assertEquals(org.apache.cxf.jaxrs.resources.Book.class, subCri.getResourceClass());
MethodDispatcher subMd = subCri.getMethodDispatcher();
assertEquals(2, subMd.getOperationResourceInfos().size());
//getChapter method
OperationResourceInfo subOri = subMd.getOperationResourceInfos().iterator().next();
assertEquals("GET", subOri.getHttpMethod());
assertNotNull(subOri.getURITemplate());
//getState method
OperationResourceInfo subOri2 = subMd.getOperationResourceInfos().iterator().next();
assertEquals("GET", subOri2.getHttpMethod());
assertNotNull(subOri2.getURITemplate());
}