Guest User

Untitled

a guest
Feb 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. package au.com.loftinspace;
  2.  
  3. import com.googlecode.instinct.marker.annotate.Subject;
  4. import com.googlecode.instinct.marker.annotate.Mock;
  5. import com.googlecode.instinct.marker.annotate.Specification;
  6. import com.googlecode.instinct.marker.annotate.BeforeSpecification;
  7. import static com.googlecode.instinct.expect.Expect.expect;
  8. import com.googlecode.instinct.integrate.junit4.InstinctRunner;
  9.  
  10. import java.util.List;
  11. import java.util.LinkedList;
  12. import java.util.ArrayList;
  13.  
  14. import org.jmock.Expectations;
  15. import org.junit.runner.RunWith;
  16.  
  17. @RunWith(InstinctRunner.class)
  18. public class AListUserAdaptor {
  19.  
  20. @Subject ListUserAdaptor listUserAdaptor;
  21. @Mock ListUser mockListUser;
  22.  
  23. @BeforeSpecification
  24. public void setUp() {
  25. listUserAdaptor = new ListUserAdaptor();
  26. listUserAdaptor.setListUser(mockListUser);
  27. }
  28.  
  29. @Specification
  30. public void shouldUseArrayListsOnListUser() {
  31. /*
  32. It might be expected that this would fail, but it does not. Type checking on the List happens at
  33. compile time. The runtime type of the list is not checked as aNonNull resolves to ANYTHING
  34. */
  35. expect.that(new Expectations() {{
  36. one(mockListUser).useAList(with(aNonNull(ArrayList.class)));
  37. }});
  38. listUserAdaptor.useAList();
  39. }
  40.  
  41. private class ListUserAdaptor {
  42. public ListUserAdaptor(){}
  43. private ListUser listUser;
  44.  
  45. public void setListUser(ListUser listUser) {
  46. this.listUser = listUser;
  47. }
  48.  
  49. public void useAList() {
  50. listUser.useAList(new LinkedList());
  51. }
  52. }
  53.  
  54. private class ListUser {
  55. public void useAList(List list) {}
  56. }
  57. }
Add Comment
Please, Sign In to add comment