### Question:
MembershipService { public List<String> getAllMemberships() { Membership memberships = restService.makeCall(membershipServerUrl, membershipServerUri, Membership.class); memberships.getMemberships().replaceAll(String::toUpperCase); return memberships.getMemberships(); }  List<String> getAllMemberships();  }### Answer:
@Test public void getAllMemberships() throws Exception { ArrayList<String> opsMemberships; opsMemberships = new ArrayList<>(); opsMemberships.add("Application1"); opsMemberships.add("Application2"); opsMemberships.add("Application3"); HashMap<String, List<String>> node; node = new HashMap<>(); node.put("test", opsMemberships); Membership response = new Membership(node); when(restService.makeCall(any(), any(), any())).thenReturn(response); Assert.assertTrue(membershipService.getAllMemberships().contains("APPLICATION1")); Assert.assertTrue(membershipService.getAllMemberships().contains("APPLICATION2")); Assert.assertTrue(membershipService.getAllMemberships().contains("APPLICATION3")); }
@Test public void getEmptyMemberships() throws Exception { when(restService.makeCall(any(), any(), any())).thenReturn(new Membership()); Assert.assertTrue(membershipService.getAllMemberships().size() == 0); }