/** * Returns a {@code RuleChain} with a single {@link TestRule}. This method * is the usual starting point of a {@code RuleChain}. * * @param outerRule the outer rule of the {@code RuleChain}. * @return a {@code RuleChain} with a single {@link TestRule}. */ public static RuleChain outerRule(TestRule outerRule) { return emptyRuleChain().around(outerRule); }
@Override public Statement apply( Statement base, Description description ) { if ( chain == null ) { if ( fs == null ) { fs = new EphemeralFileSystemRule(); } this.pageCacheRule = new PageCacheRule( pageCacheConfig ); this.directory = TestDirectory.testDirectory( clazz, fs ); this.chain = RuleChain.outerRule( fs ).around( directory ).around( pageCacheRule ); } return chain.apply( base, description ); }
/** * Creates a {@link RuleChain} where the rules are evaluated in the order you pass in. * * @param testRules * test rules to evaluate * @return a new rule chain. */ public static RuleChain create(final TestRule... testRules) { if (testRules == null || testRules.length == 0) { return RuleChain.emptyRuleChain(); } RuleChain ruleChain = RuleChain.outerRule(testRules[0]); for (int i = 1; i < testRules.length; i++) { ruleChain = ruleChain.around(testRules[i]); } return ruleChain; } }
public RuleChainBuilder around(TestRule rule) { this.ruleChain = ruleChain.around(rule); return this; }
@Override public Statement apply(final Statement base, final Description description) { return innerChain.apply(base, description); }
/** * Create a new {@code RuleChain}, which encloses the {@code nextRule} with * the rules of the current {@code RuleChain}. * * @param enclosedRule the rule to enclose. * @return a new {@code RuleChain}. */ public RuleChain around(TestRule enclosedRule) { List<TestRule> rulesOfNewChain = new ArrayList<TestRule>(); rulesOfNewChain.add(enclosedRule); rulesOfNewChain.addAll(rulesStartingWithInnerMost); return new RuleChain(rulesOfNewChain); }
private AggregateGuiceModuleTestRule(List<GuiceModuleTestRule> subrule) { this.subrule = subrule; this.chain = subrule .stream() .reduce(RuleChain.emptyRuleChain(), RuleChain::around, RuleChain::around); }
@Inject public ForClass(DriverCleanupRule driverCleanupRule) { this.chain = RuleChain.outerRule(driverCleanupRule); }
public RuleChainBuilder around(Class<? extends TestRule> ruleClass) { this.ruleChain = ruleChain.around(injectionContext.getInstance(ruleClass)); return this; }
@Override public Statement apply(Statement base, Description description) { return chain.apply(base, description); } }
/** * Create a new {@code RuleChain}, which encloses the given {@link TestRule} with * the rules of the current {@code RuleChain}. * * @param enclosedRule the rule to enclose; must not be {@code null}. * @return a new {@code RuleChain}. * @throws NullPointerException if the argument {@code enclosedRule} is {@code null} */ public RuleChain around(TestRule enclosedRule) { if (enclosedRule == null) { throw new NullPointerException("The enclosed rule must not be null"); } List<TestRule> rulesOfNewChain = new ArrayList<TestRule>(); rulesOfNewChain.add(enclosedRule); rulesOfNewChain.addAll(rulesStartingWithInnerMost); return new RuleChain(rulesOfNewChain); }
public StatelessTestRunner(Class<?> testedProductClass) throws InitializationError { super(testedProductClass); this.productRef = new LazyReference<TestedProduct<?>>() { @Override protected TestedProduct<?> create() throws Exception { return createProduct(); } }; try { setupInjector(); prepareFixtures(); injectClassRules(); baseMethodRules = RuleChain.emptyRuleChain(); baseClassRules = RuleChain.emptyRuleChain(); } catch(Exception e) { throw new InitializationError(e); } }
/** * Returns a {@code RuleChain} with a single {@link TestRule}. This method * is the usual starting point of a {@code RuleChain}. * * @param outerRule the outer rule of the {@code RuleChain}. * @return a {@code RuleChain} with a single {@link TestRule}. */ public static RuleChain outerRule(TestRule outerRule) { return emptyRuleChain().around(outerRule); }
private static void register(Orchestrator orchestrator) { ORCHESTRATORS.add(orchestrator); RESOURCES = RESOURCES.around(orchestrator); }
@Override public Statement apply(final Statement base, final Description description) { return ruleChain.apply(base, description); } }
/** * Create a new {@code RuleChain}, which encloses the {@code nextRule} with * the rules of the current {@code RuleChain}. * * @param enclosedRule the rule to enclose. * @return a new {@code RuleChain}. */ public RuleChain around(TestRule enclosedRule) { List<TestRule> rulesOfNewChain = new ArrayList<TestRule>(); rulesOfNewChain.add(enclosedRule); rulesOfNewChain.addAll(rulesStartingWithInnerMost); return new RuleChain(rulesOfNewChain); }