ZapRuleDefinition implements RulesDefinition { @Override public void define(Context context) { NewRepository repository = context .createRepository(ZapPlugin.REPOSITORY_KEY, ZapPlugin.LANGUAGE_KEY); repository.setName(ZapPlugin.REPOSITORY_KEY); String rulesFilePath = getRulesFilePath(); if (rulesFilePath == null) { loadDefaultZAProxyRules(repository); } else { File f = null; try { f = new File(rulesFilePath); xmlLoader.load(repository, new FileInputStream(f), "UTF-8"); } catch (FileNotFoundException e) { LOGGER.warn("The file " + f.getAbsolutePath() + " does not exist", e); loadDefaultZAProxyRules(repository); } } repository.done(); } ZapRuleDefinition(RulesDefinitionXmlLoader xmlLoader, Configuration configuration); @Override void define(Context context);  }
@Test public void defineContextTest() { RulesDefinitionXmlLoader xmlLoader = new RulesDefinitionXmlLoader(); Configuration configuration = mock(Configuration.class); ZapRuleDefinition ZapRuleDefinition = new ZapRuleDefinition(xmlLoader, configuration); Context context = new Context(); ZapRuleDefinition.define(context); for (Rule rule : context.repositories().get(0).rules()) { assertFalse(rule.tags().isEmpty()); } }