title: @Mockbean with @Qualifer throws during the Junit test run
body: <p>i am writing the junits for the below class,</p>
  
  <pre><code>@Repository
  public class IncidentRepository {
  
      @Autowired
      @Qualifier("mysqlJdbcTemplate")
      private JdbcTemplate mysqlJdbcTemplate;
  
  
      @Autowired
      @Qualifier("oracleJdbcTemplate")
      private JdbcTemplate oracleJdbcTemplate;
  
      private String tableName = "BSC_INCIDENT_STG_3";
  
  
      public String getTableName() {
          return tableName;
      }
  
      public List&lt;Incident&gt; listAll() {
          String cprSql = "SELECT 1 FROM DUAL";
          return oracleJdbcTemplate.query(cprSql, new IncidentMapper());
  
      }
  }
  </code></pre>
  
  <p>and the Junit class i am working on is this,</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @ContextConfiguration(classes = CommonConfig.class)
  public class IncidentRepositoryTest {
  
      private final Logger log = LoggerFactory.getLogger(Application.class);
  
      @InjectMocks
      IncidentRepository incidentRepository;
  
      @Qualifier("mysqlJdbcTemplate")
      private JdbcTemplate mysqlJdbcTemplate;
  
      @Qualifier("oracleJdbcTemplate")
      private JdbcTemplate oracleJdbcTemplate;
  
      @MockBean
      private Incident incident;
  
  @MockBean
      private IncidentMapper incidentMapper;
  
      private String deleteSqlQuery = "DELETE FROM ";
  
      String cprSql = "SELECT 1 FROM DUAL";
  
      List&lt;Incident&gt; incidentList = new ArrayList&lt;Incident&gt;();
  
      @Before
      public void setUp() throws Exception {
          //All Initializations goes here.
          MockitoAnnotations.initMocks(this);     
          mysqlJdbcTemplate = Mockito.mock(JdbcTemplate.class);
          oracleJdbcTemplate = Mockito.mock(JdbcTemplate.class);
  
          incident.setIncidentNumber("incidentNumber");
          incident.setApplicationId("J12342");
          incident.setCategory("O12987");
          incident.setOpenTime("ApplicationName");
          incident.setSeverityCode("OwningLob");
          incident.setAssignment("reportingCIOLOB");
          incident.setStatus("reportingCTOGroup");
          incident.setCloseTime("rto");
          incident.setStatus("status");
          incident.setElapsedTime("assetName");
          incident.setResolutionCode("environment");
          incident.setType("invNo");
          incident.setOpenGroup("osiStatus");
          incident.setResolvedGroup("measuredID");
          incident.setResolvedTime("policyID");
          incident.setUserPriority("policyName");
          incident.setJpAcctLob("lastBreakDate");
          incident.setJpAcctAppRto("lastClearedDate");
          incident.setJpImpact("osiStatus");
          incident.setJpImpactDurationMin("measuredID");
          incident.setJpExternalId("policyID");
          incident.setJpExternalSystem("policyName");
          incident.setJpConfigItem("lastBreakDate");
          incident.setJpMasterHost("lastClearedDate");
          incident.setJpSite("osiStatus");
          incident.setJpAppserviceName("measuredID");
          incident.setJpAppserviceId("policyID");
          incident.setJpVerumidentifier("policyName");
  
          incidentList.add(incident);
  
      }
  
      @Test
      public void testListAll() throws Exception {
  
  when(oracleJdbcTemplate.query(cprSql,incidentMapper)).thenReturn(incidentList);
          incidentRepository.listAll();       
      }
  }
  </code></pre>
  
  <p>The problem now is that mysqlJdbcTemplate object is always null in the IncidentRepository class even when i mocked it.</p>
  
  <p>I dont want to you @Autowired annotation .i just want to mock the objects.</p>
  
  <p>Can someone please help ?</p>