### Question:
AuthenticationContext implements Contextual<AuthenticationContext> { private static <T> RuleNode<T> replacing(RuleNode<T> node, MatchRule rule, T item, int idx) { return node == null ? new RuleNode<T>(null, rule, item) : node.replacing(rule, item, idx); } private  AuthenticationContext();   AuthenticationContext(final RuleNode<AuthenticationConfiguration> authRules, final RuleNode<SecurityFactory<SSLContext>> sslRules); static AuthenticationContext empty(); static AuthenticationContext captureCurrent(); AuthenticationContext with(MatchRule rule, AuthenticationConfiguration configuration); AuthenticationContext withSsl(MatchRule rule, SecurityFactory<SSLContext> sslContext); AuthenticationContext with(AuthenticationContext other); AuthenticationContext with(int idx, MatchRule rule, AuthenticationConfiguration configuration); AuthenticationContext withSsl(int idx, MatchRule rule, SecurityFactory<SSLContext> sslContext); AuthenticationContext replacing(int idx, MatchRule rule, AuthenticationConfiguration configuration); AuthenticationContext replacingSslContext(int idx, MatchRule rule, SecurityFactory<SSLContext> sslContext); AuthenticationContext without(int idx); AuthenticationContext withoutSsl(int idx); T run(PrivilegedAction<T> action); T run(PrivilegedExceptionAction<T> action); T run(P parameter, ParametricPrivilegedAction<T, P> action); T run(P parameter, ParametricPrivilegedExceptionAction<T, P> action); void runAsObjIntConsumer(ObjIntConsumer<T> action, T parameter1, int parameter2); T runAsSupplier(Supplier<T> action); void runAsObjIntConsumerEx(ExceptionObjIntConsumer<T, E> action, T parameter1, int parameter2); T runAsSupplierEx(ExceptionSupplier<T, E> action); ContextManager<AuthenticationContext> getInstanceContextManager(); static ContextManager<AuthenticationContext> getContextManager();  }### Answer:
@Test public void replaceRuleConfiguration() { RuleNode<AuthenticationConfiguration> initialRule = new RuleNode<>( new RuleNode<>( new RuleNode<>(null, MatchRule.ALL.matchPort(3456), config3), MatchRule.ALL.matchPort(2345), config2), MatchRule.ALL.matchPort(1234), config1); AuthenticationContext ctx = new AuthenticationContext(initialRule, null) .replacing(1, MatchRule.ALL.matchHost("someHost"), config4); assertExpectedRuleNode(ctx.authRules, config1, MatchRule.ALL.matchPort(1234)); RuleNode<AuthenticationConfiguration> second = ctx.authRules.getNext(); assertExpectedRuleNode(second, config4, MatchRule.ALL.matchHost("someHost")); RuleNode<AuthenticationConfiguration> third = second.getNext(); assertExpectedRuleNode(third, config3, MatchRule.ALL.matchPort(3456)); assertNull(third.getNext()); }