@Before public void setUp() throws Exception { when(myBatis.openSession(false)).thenReturn(session); esSetup = new EsSetup( ImmutableSettings.builder() .loadFromUrl(ESNode.class.getResource("config/elasticsearch.json")) .build()); esSetup.execute(EsSetup.deleteAll()); ESNode node = mock(ESNode.class); when(node.client()).thenReturn(esSetup.client()); Settings settings = new Settings(); settings.setProperty("sonar.log.profilingLevel", "FULL"); Profiling profiling = new Profiling(settings); searchIndex = new ESIndex(node, profiling); searchIndex.start(); RuleRegistry esRule = new RuleRegistry(searchIndex, null, null, null); esRule.start(); esActiveRule = new ESActiveRule(searchIndex, activeRuleDao, myBatis, profiling); esActiveRule.start(); esSetup.execute( EsSetup.index("rules", "rule", "1").withSource(testFileAsString("shared/rule1.json")), EsSetup.index("rules", "rule", "2").withSource(testFileAsString("shared/rule2.json")), EsSetup.index("rules", "rule", "3").withSource(testFileAsString("shared/rule3.json"))); }
@Before public void setUp() throws Exception { when(myBatis.openSession(false)).thenReturn(session); esSetup = new EsSetup( ImmutableSettings.builder() .loadFromUrl(ESNode.class.getResource("config/elasticsearch.json")) .build()); esSetup.execute(EsSetup.deleteAll()); ESNode node = mock(ESNode.class); when(node.client()).thenReturn(esSetup.client()); Settings settings = new Settings(); settings.setProperty("sonar.log.profilingLevel", "FULL"); Profiling profiling = new Profiling(settings); searchIndex = new ESIndex(node, profiling); searchIndex.start(); registry = new RuleRegistry(searchIndex, myBatis, ruleDao, characteristicDao); registry.start(); esSetup.execute( EsSetup.index("rules", "rule", "1").withSource(testFileAsString("shared/rule1.json")), EsSetup.index("rules", "rule", "2").withSource(testFileAsString("shared/rule2.json")), EsSetup.index("rules", "rule", "3").withSource(testFileAsString("shared/rule3.json")), EsSetup.index("rules", "rule", "50") .withSource(testFileAsString("shared/removed_rule.json"))); esSetup .client() .admin() .cluster() .prepareHealth(RuleRegistry.INDEX_RULES) .setWaitForGreenStatus() .execute() .actionGet(); }