0
public class A {

    public ResultSet executeCql(String cql, boolean cachePrepared, ConsistencyLevel consistencyLevel, Object... values)
        {
            //...
        }

     //...
}

I have mocked the class A. And I have tried to mock method its not working.

when(a.executeCql(anyString(), anyBoolean(), any(), any(Object[].class))).thenReturn(resultSet);

Help me on this.

I have tried this also.

when(cassandraHelper.executeCql(any(), anyBoolean(), any(ConsistencyLevel.class), Matchers.<Object>anyVararg())).thenReturn(resultSet);

Still this method returns null instead of mocked ResultSet.

Siva Kumar
  • 1,983
  • 3
  • 14
  • 26
  • What does "not working" mean in more detail? – hammerfest Oct 14 '16 at 11:08
  • Are you sure `a` is an instance of a Mock? For example, via `@InitMocks`. – vikingsteve Oct 14 '16 at 11:08
  • for mock i will use easy mock objects. **Maven** ` org.easymock easymock 3.2 ` **Test class** `private A a; @Before public void setUp() throws IOException { a = EasyMock.createNiceMock(A.class); expect(a.executeCql(anyString(), anyBoolean(), any(), any(Object[].class)))).andReturn(resultSet); replay(a); }` I think it will helps you !! – Parth Solanki Oct 14 '16 at 11:20

0 Answers0