Skip to content

Instantly share code, notes, and snippets.

@eyalgo
Created February 16, 2014 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eyalgo/9040745 to your computer and use it in GitHub Desktop.
Save eyalgo/9040745 to your computer and use it in GitHub Desktop.
Item item = mock(Item.class);
Map<String, Set<String>> attributes = mock(Map.class);
Set<String> values = mock(Set.class);
Iterator<String> iterator = mock(Iterator.class);
when(iterator.next()).thenReturn("the single value");
when(values.iterator()).thenReturn(iterator);
when(attributes.containsKey("the-key")).thenReturn(true);
when(attributes.get("the-key")).thenReturn(values);
when(item.getAttributes()).thenReturn(attributes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment