Can anyone help why my mockery doesn't work?
- by user509550
The test call real method(service) without mocking some expecations
@Test
public void testPropertyList() {
Credentials creds = new Credentials();
creds.setUsername("someEmail");
creds.setPassword("somePassword");
creds.setReferrer("someReferrer");
final Collection<PropertyInfo> propertyInfoCollection = new LinkedList<PropertyInfo>();
final List<ListingInfo> listings = new ArrayList<ListingInfo>();
listings.add(listingInfoMock);
listings.add(listingInfoMock);
propertyInfoCollection.add(new PropertyInfo("c521bf5796274bd587c00bec80583c00", listings));
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("page", "5");
params.add("size", "5");
instance.setPropertyListFacade(propertyListFacadeMock);
mockery.checking(new Expectations() {
{
one(propertyListFacadeMock).getUserProperties();
will(returnValue(propertyInfoCollection));
one(listingInfoMock).getPropertyName();
allowing(listingInfoMock).getThumbnailURL();
one(listingInfoMock).getListingSystemId();
one(listingInfoMock).getPropertyURL();
one(listingInfoMock).getListingSystemId();
one(listingInfoMock).getPropertyURL();
}
});
instance.setSessionManager(dashboardSessionManagerMock);
testSuccessfulAuthenticate();
ClientResponse response = resource.path(PROPERTIES_PATH).queryParams(params).accept(MediaType.APPLICATION_XML)
.get(ClientResponse.class);
assertEquals(200, response.getStatus());
mockery.assertIsSatisfied();
}