ExpansionHandler implements RuleChangesObserver { protected boolean isStorageExpand(String uri) { return ruleFeaturesProvider.isFeatureRequest(STORAGE_EXPAND, uri); } ExpansionHandler(Vertx vertx, final ResourceStorage storage, HttpClient httpClient, final Map<String, Object> properties, String serverRoot, final String rulesPath); @Override void rulesChanged(List<Rule> rules); int getMaxExpansionLevelSoft(); int getMaxExpansionLevelHard(); int getMaxSubRequestCount(); boolean isExpansionRequest(HttpServerRequest request); boolean isZipRequest(HttpServerRequest request); void handleExpansionRecursion(final HttpServerRequest request); void handleZipRecursion(final HttpServerRequest request); boolean isCollection(String target); static final String SERIOUS_EXCEPTION; static final String EXPAND_PARAM; static final String ZIP_PARAM; static final String MAX_EXPANSION_LEVEL_SOFT_PROPERTY; static final String MAX_EXPANSION_LEVEL_HARD_PROPERTY; static final String MAX_SUBREQUEST_PROPERTY; }
@Test public void testIsStorageExpand(TestContext context) { expansionHandler = new ExpansionHandler(vertx, storage, httpClient, new HashMap<>(), ROOT, RULES_ROOT); context.assertFalse(expansionHandler.isStorageExpand("/some/request/uri"), "uri should not be a storage expand since no routing rules have been defined yet"); List<Rule> rules = new ArrayList<>(); Rule rule1 = new Rule(); rule1.setUrlPattern("/test/rules/rule/storageExpand"); rule1.setStorageExpand(true); rules.add(rule1); Rule rule2 = new Rule(); rule2.setUrlPattern("/test/rules/rule/notStorageExpand"); rule2.setStorageExpand(false); rules.add(rule2); expansionHandler.rulesChanged(rules); context.assertTrue(expansionHandler.isStorageExpand("/test/rules/rule/storageExpand"), "uri should be a storage expand"); context.assertFalse(expansionHandler.isStorageExpand("/test/rules/rule/notStorageExpand"), "uri should not be a storage expand"); context.assertFalse(expansionHandler.isStorageExpand("/some/other/request/uri"), "uri should not be a storage expand"); }