Can anyone help why my mockery doesn't work?
Posted
by
user509550
on Stack Overflow
See other posts from Stack Overflow
or by user509550
Published on 2010-12-31T09:47:05Z
Indexed on
2010/12/31
9:54 UTC
Read the original article
Hit count: 220
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();
}
© Stack Overflow or respective owner