title: How to mock array of String
body: <p>below is the example code, if this work i can use the same logic in my business code.</p>
  
  <pre><code>class A{    
  public String[] getString(String[] a){
      System.out.println("called");
      return a;
  }}
  
  class B{
  A a;    
  public String[] getString(){
      String[] ab = {"inside main class"};
      a= new A();
      return a.getString(ab);
  }
  }
  </code></pre>
  
  <p>Junit:</p>
  
  <pre><code>public class test{
  private MockMvc mockMvc;
  @Mock
  private A a;
  
  @InjectMocks
  private B b;
  
  @Before
  public void setUp() {
      MockitoAnnotations.initMocks(this);
      mockMvc = MockMvcBuilders.standaloneSetup(b).build();
  }
  
  @Test
  public void test2Object(){
      String[] bc = {"mock main class"};      
      Mockito.when(a.getString(Mockito.any(String[].class))).thenReturn(bc);
      System.out.println((b.getString())[0]);
  }   
  }
  </code></pre>
  
  <p>Expected o/p "mock main class" but I am getting "inside main class"</p>
  
  <p>Could anyone please help me to solve this issue.</p>