title: Cannot inject MapStruct mapper into spring-boot JUnit test
body: <p>I'm trying to write a unit test for a MapStruct mapper with <code>componentModel="spring"</code>.</p>
  
  <p>The application works perfectly, including the mapper injection.
  The problem is that the mapper is not injected to the test class and I'm getting the following error:</p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.onap.sdc.workflow.api.mapping.WorkflowMapperTest': Unsatisfied dependency expressed through field 'workflowMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.onap.sdc.workflow.services.mappers.WorkflowMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  </code></pre>
  
  <p>I'm using intellij IDEA and target\generated-sources is marked.</p>
  
  <p>Here is the mapper class:</p>
  
  <pre><code>@Mapper(componentModel = "spring")
  public interface WorkflowMapper {
  
  @Mapping(source = "properties", target = "category", qualifiedByName = "propertiesToCategoryMapper")
  Workflow itemToWorkflow(Item item);
  
  @Mapping(source = "category", target = "properties", qualifiedByName = "categoryToPropertiesMapper")
  @InheritInverseConfiguration
  Item workflowToItem(Workflow workflow);
  
  @Named("propertiesToCategoryMapper")
  default String customPropertiesToCategoryMapper(Map&lt;String, Object&gt; properties) {
      return String.class.cast(properties.get(WorkflowProperty.CATEGORY));
  }
  
  @Named("categoryToPropertiesMapper")
  default Map&lt;String, Object&gt; customCategoryToPropertiesMapper(String category) {
      return Collections.singletonMap(WorkflowProperty.CATEGORY, category);
  }
  </code></pre>
  
  <p>I'm using this mapper in the following code snippet:</p>
  
  <pre><code>@Service("workflowManager")
  public class WorkflowManagerImpl implements WorkflowManager {
  
  private WorkflowMapper workflowMapper;
  
  @Autowired
  public WorkflowManagerImpl(WorkflowMapper workflowMapper) {
      this.workflowMapper = workflowMapper;
  }
  
  ...some code
  </code></pre>
  
  <p>The unit test class:</p>
  
  <pre><code>@ContextConfiguration(classes = 
  WorkflowMapperTest.WorkflowMapperSpringTestConfig.class)
  @RunWith(SpringJUnit4ClassRunner.class)
  public class WorkflowMapperTest {
  
  @Configuration
  @ComponentScan(basePackageClasses = WorkflowMapperTest.class)
  public static class WorkflowMapperSpringTestConfig { }
  
  @Autowired
  WorkflowMapper workflowMapper;
  
  @Test
  public void shouldMapItemPropertyToWorkflowCategory() {
      ...some code...
  }
  </code></pre>
  
  <p>Any help will be appreciated.</p>