RuleFeaturesProvider { public List<RuleFeatures> getFeaturesList() { if(featuresList == null){ featuresList = new ArrayList<>(); } return featuresList; } RuleFeaturesProvider(List<Rule> rules); List<RuleFeatures> getFeaturesList(); boolean isFeatureRequest(RuleFeatures.Feature feature, String uri);  }
@Test public void testStorageExpandFeature(TestContext context){ List<Rule> rules = setUpRules(); RuleFeaturesProvider provider = new RuleFeaturesProvider(rules); List<RuleFeatures> ruleFeatures = provider.getFeaturesList(); assertCommonResults(context, ruleFeatures, rules); context.assertTrue(ruleFeatures.get(0).hasFeature(STORAGE_EXPAND)); context.assertFalse(ruleFeatures.get(1).hasFeature(STORAGE_EXPAND)); context.assertTrue(ruleFeatures.get(2).hasFeature(STORAGE_EXPAND)); context.assertFalse(ruleFeatures.get(3).hasFeature(STORAGE_EXPAND)); context.assertTrue(ruleFeatures.get(4).hasFeature(STORAGE_EXPAND)); context.assertFalse(ruleFeatures.get(5).hasFeature(STORAGE_EXPAND)); context.assertTrue(ruleFeatures.get(6).hasFeature(STORAGE_EXPAND)); context.assertFalse(ruleFeatures.get(7).hasFeature(STORAGE_EXPAND)); context.assertTrue(ruleFeatures.get(8).hasFeature(STORAGE_EXPAND)); context.assertFalse(ruleFeatures.get(9).hasFeature(STORAGE_EXPAND)); }
@Test public void testExpandOnBackendFeature(TestContext context){ List<Rule> rules = setUpRules(); RuleFeaturesProvider provider = new RuleFeaturesProvider(rules); List<RuleFeatures> ruleFeatures = provider.getFeaturesList(); assertCommonResults(context, ruleFeatures, rules); context.assertFalse(ruleFeatures.get(0).hasFeature(EXPAND_ON_BACKEND)); context.assertFalse(ruleFeatures.get(1).hasFeature(EXPAND_ON_BACKEND)); context.assertFalse(ruleFeatures.get(2).hasFeature(EXPAND_ON_BACKEND)); context.assertFalse(ruleFeatures.get(3).hasFeature(EXPAND_ON_BACKEND)); context.assertFalse(ruleFeatures.get(4).hasFeature(EXPAND_ON_BACKEND)); context.assertTrue(ruleFeatures.get(5).hasFeature(EXPAND_ON_BACKEND)); context.assertTrue(ruleFeatures.get(6).hasFeature(EXPAND_ON_BACKEND)); context.assertTrue(ruleFeatures.get(7).hasFeature(EXPAND_ON_BACKEND)); context.assertTrue(ruleFeatures.get(8).hasFeature(EXPAND_ON_BACKEND)); context.assertTrue(ruleFeatures.get(9).hasFeature(EXPAND_ON_BACKEND)); }
@Test public void testIgnoreRulesWithInvalidPatterns(TestContext context){ Rule ruleValid1 = createRule("/test/rules/rule_valid_1", true, false); Rule ruleValid2 = createRule("/test/rules/rule_valid_2", false, true); Rule ruleInvalid = createRule("/test/rules/(rule_invalid", true, false); RuleFeaturesProvider provider = new RuleFeaturesProvider(Arrays.asList(ruleInvalid, ruleValid1, ruleValid2)); List<RuleFeatures> ruleFeatures = provider.getFeaturesList(); context.assertEquals(2, ruleFeatures.size()); context.assertTrue(ruleFeatures.get(0).hasFeature(STORAGE_EXPAND)); context.assertFalse(ruleFeatures.get(0).hasFeature(EXPAND_ON_BACKEND)); context.assertFalse(ruleFeatures.get(1).hasFeature(STORAGE_EXPAND)); context.assertTrue(ruleFeatures.get(1).hasFeature(EXPAND_ON_BACKEND)); }