title: Alternative CDI implementation - WELD-001408: Unsatisfied dependencies for type Repository with qualifiers @Default
body: <p>I have an interface <code>Repository</code> with two implementations, <code>DBRepository</code> and <code>UTRepository</code>. <code>UTRepository</code> is annotated with <code>@Alternative</code> and I'm trying to use it in a JUnit test.</p>
  
  <p>The test class:</p>
  
  <pre><code>@RunWith(Arquillian.class)
  public class UserServiceTest {
      @Inject
      private UserService service;
  
      @Deployment
      public static JavaArchive createDeployment() {
          return ShrinkWrap.create(JavaArchive.class)
              .addClasses(Repository.class, UserService.class, UTRepository.class)
              .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
      }
  
      @Test
      public void addCharacterTest() {
          service.addCharacter(1L, Mockito.mock(GameCharacter.class));
      }
  }
  </code></pre>
  
  <p>The class under test:</p>
  
  <pre><code>public class UserService {
      @Inject
      Repository repository;
  
      @Transactional
      public void addCharacter(Long userId, GameCharacter character) {
          User user = repository.readById(userId, User.class);
          user.addCharacter(character);
          repository.update(user);
      }
  }
  </code></pre>
  
  <p>My <code>beans.xml</code> file (placed in src/test/webapp/WEB-INF/beans.xml):</p>
  
  <pre><code>&lt;beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="
        http://xmlns.jcp.org/xml/ns/javaee
        http://xmlns.jcp.org/xml/ns/javaee/beans_1_2.xsd"
      bean-discovery-mode="all"&gt;
      &lt;alternatives&gt;
          &lt;class&gt;org.package.name.UTRepository&lt;/class&gt;
      &lt;/alternatives&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>When I try to run the test, I get the exception:</p>
  
  <pre><code>org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Repository with qualifiers @Default
      at injection point [BackedAnnotatedField] @Inject org.package.name.services.UserService.repository
      at org.package.name.services.UserService.repository(UserService.java:0)
      at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:359)
      at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:281)
      at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:134)
      at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:155)
      at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:518)
      at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:68)
      at org.jboss.weld.bootstrap.ConcurrentValidator$1.doWork(ConcurrentValidator.java:66)
      at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
      at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
      at java.util.concurrent.FutureTask.run(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>What is the problem?</p>