protected RulesRepository getRepository() {
   if (Contexts.isApplicationContextActive()) {
     return (RulesRepository) Component.getInstance("repository");
   } else {
     try {
       return new RulesRepository(TestEnvironmentSessionHelper.getSession(false));
     } catch (Exception e) {
       throw new IllegalStateException("Unable to get repo to run tests", e);
     }
   }
 }
 private RulesRepository getRepo() throws Exception {
   return new RulesRepository(TestEnvironmentSessionHelper.getSession());
 }