Created
April 7, 2012 05:15
-
-
Save yamanyar/2325479 to your computer and use it in GitHub Desktop.
capture parameters example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//... lines of codes... templateService is mocked... | |
//here is regular expectation; we know the parameter that will be passed and we are verifying it | |
expect(nodeService.getProperties(fakeChildNodeRef2)).andReturn(new HashMap()); | |
//create a capturer; which will capture a map item | |
Capture<Map> capturer = new Capture<Map>(); | |
//write your expectaion again; this time we want to have a reference to whatever passed to | |
//our method processTemplate in mocked item templateService | |
expect(templateService.processTemplate(isA(String.class), and(isA(Map.class), capture(capturer)))).andReturn("fake"); | |
//replay; let the action begin | |
replay(nodeService, templateService); | |
String fake = testMe.serializeNode(fakeNodeRef); | |
//verify that our methods were called according to our expectations | |
verify(nodeService, templateService); | |
//now, let get the object from capturer to verify it.. | |
String outputGenerated = (String) (capturer.getValue()).get("json"); | |
//..lines of codes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment