I am trying to define when
mockito method with multiple any
arguments:
TestBedDaoClient testBedDaoClient = mock(TestBedDaoClient.class);
when(testBedDaoClient.addTestBed(anyString(), anyString(), any(VCloudConfiguration.class))).thenReturn(testBedPojoMockData);
In target test class:
TestBedPojo addedTestBedPojo = testBedDaoClient.addTestBed(testBedName, testBedDescription, vCloudConfiguration);
In DAO client:
public TestBedPojo addTestBed(String testBedName, String testBedDescription, VCloudConfiguration vCloudConfiguration){
return testBedPojo;
}
I wanted to define when
in such a way that it returns testBedPojoMockData
with any values of arguments. But I am getting error: Argument(s) are different!
I even tried:
when(testBedDaoClient.addTestBed("test", "test", any(VCloudConfiguration.class))).thenReturn(testBedPojoMockData);
when(testBedDaoClient.addTestBed(any(), any(), any())).thenReturn(testBedPojoMockData);
But no luck. How I can define this when
so that it returns the mock data on any call?