void (Runnable testRunnable, NestingRule... rules) { final ProjectViewFileNestingService nestingService = ProjectViewFileNestingService.getInstance(); final List<NestingRule> originalRules = new ArrayList<>(nestingService.getRules().size()); for (NestingRule rule : nestingService.getRules()) { originalRules.add(new NestingRule(rule.getParentFileSuffix(), rule.getChildFileSuffix())); } try { nestingService.setRules(Arrays.asList(rules)); testRunnable.run(); } finally { nestingService.setRules(originalRules); } }