title: Injecting mock @Service for Spring unit tests
body: <p>I am testing a class that uses use @Autowired to inject a service:</p>
  
  <pre><code>public class RuleIdValidator implements ConstraintValidator&lt;ValidRuleId, String&gt; {
  
      @Autowired
      private RuleStore ruleStore;
  
      // Some other methods
  }
  </code></pre>
  
  <p>But how can I mock ruleStore during testing? I can't figure out how to inject my mock RuleStore into Spring and into the Auto-wiring system.</p>
  
  <p>Thanks</p>