@Test public void testLookupStatuses() { registerHandler("ctx", "handler1", "/items/{item}"); registerHandlerWithAction("ctx", new Method[]{GET}, "handler2", "clear", "/items/{item}/{sub}"); LookupResult lookupResult = resourceManager.lookupResource(GET, "/invalid"); assertEquals(NOT_FOUND, lookupResult.getStatus()); lookupResult = resourceManager.lookupResource(GET, "/ctx/items/1"); assertEquals(FOUND, lookupResult.getStatus()); lookupResult = resourceManager.lookupResource(DELETE, "/ctx/items/1"); assertEquals(INVALID_METHOD, lookupResult.getStatus()); lookupResult = resourceManager.lookupResource(GET, "/ctx/items/1/1", "clear"); assertEquals(FOUND, lookupResult.getStatus()); lookupResult = resourceManager.lookupResource(GET, "/ctx/items/1/1"); assertEquals(INVALID_ACTION, lookupResult.getStatus()); lookupResult = resourceManager.lookupResource(GET, "/ctx/items/1/1", "invalid"); assertEquals(INVALID_ACTION, lookupResult.getStatus()); lookupResult = resourceManager.lookupResource(GET, "/ctx/items/1", "invalid"); assertEquals(INVALID_ACTION, lookupResult.getStatus()); }
@Override public LookupResult lookupResource(Method method, String path, String action) { List<PathItem> pathItems = Arrays.stream(path.replaceAll(" .map(s -> s.isEmpty() ? "/" : s).map(QueryStringDecoder::decodeComponent).map(PathItem::fromString).collect(Collectors.toList()); return resourceTree.find(method, pathItems, action); }
ResourceManagerImpl implements ResourceManager { @Override public LookupResult lookupResource(Method method, String path, String action) { List<PathItem> pathItems = Arrays.stream(path.replaceAll(" .map(s -> s.isEmpty() ? "/" : s).map(QueryStringDecoder::decodeComponent).map(PathItem::fromString).collect(Collectors.toList()); return resourceTree.find(method, pathItems, action); } }
ResourceManagerImpl implements ResourceManager { @Override public LookupResult lookupResource(Method method, String path, String action) { List<PathItem> pathItems = Arrays.stream(path.replaceAll(" .map(s -> s.isEmpty() ? "/" : s).map(QueryStringDecoder::decodeComponent).map(PathItem::fromString).collect(Collectors.toList()); return resourceTree.find(method, pathItems, action); } ResourceManagerImpl(); }
ResourceManagerImpl implements ResourceManager { @Override public LookupResult lookupResource(Method method, String path, String action) { List<PathItem> pathItems = Arrays.stream(path.replaceAll(" .map(s -> s.isEmpty() ? "/" : s).map(QueryStringDecoder::decodeComponent).map(PathItem::fromString).collect(Collectors.toList()); return resourceTree.find(method, pathItems, action); } ResourceManagerImpl(); @Override void registerResource(String context, ResourceHandler handler); @Override LookupResult lookupResource(Method method, String path, String action); }
ResourceManagerImpl implements ResourceManager { @Override public LookupResult lookupResource(Method method, String path, String action) { List<PathItem> pathItems = Arrays.stream(path.replaceAll(" .map(s -> s.isEmpty() ? "/" : s).map(QueryStringDecoder::decodeComponent).map(PathItem::fromString).collect(Collectors.toList()); return resourceTree.find(method, pathItems, action); } ResourceManagerImpl(); @Override void registerResource(String context, ResourceHandler handler); @Override LookupResult lookupResource(Method method, String path, String action);  }