VootClient { @SuppressWarnings("unchecked") public List<String> groups(String userUrn) { long start = System.currentTimeMillis(); LOG.info("Starting to retrieve groups for {}", userUrn); List<Map<String, Object>> groups = (List<Map<String, Object>>) vootService.getForObject(vootServiceUrl + "/internal/groups/{userUrn}", List.class, userUrn); LOG.debug("Retrieved groups: {}", groups); LOG.info("finished retrieving groups for {} in {} ms", userUrn, System.currentTimeMillis() - start); return groups.stream().map(entry -> (String) entry.get("id")).collect(toList()); } VootClient(RestOperations vootService, String vootServiceUrl); @SuppressWarnings("unchecked") List<String> groups(String userUrn);  }
@Test public void testGroups() throws Exception { String response = IOUtils.toString(new ClassPathResource("voot/empty_groups.json").getInputStream(), "UTF-8"); stubFor(get(urlEqualTo("/internal/groups/id1")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(response))); List<String> groups = subject.groups("id1"); assertTrue(groups.isEmpty()); }
@Test public void testHasAccess() throws Exception { String response = IOUtils.toString(new ClassPathResource("voot/groups.json").getInputStream(), "UTF-8"); stubFor(get(urlEqualTo("/internal/groups/id1")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBody(response))); List<String> groups = subject.groups("id1"); assertEquals(14, groups.size()); assertTrue(groups.stream().allMatch(group -> StringUtils.hasText(group))); }