CompanyTemplate extends AbstractTemplate implements CompanyOperations { public List<Company> getSuggestionsToFollow() { JsonNode node = restOperations.getForObject(COMPANY_SUGGESTIONS_TO_FOLLOW, JsonNode.class); try { return objectMapper.reader(new TypeReference<List<Company>>(){}).readValue(node.path("values")); } catch (Exception e) { throw new RuntimeException(e); } } CompanyTemplate(RestOperations RestOperations, ObjectMapper objectMapper); Company getCompany(int id); Company getCompanyByUniversalName(String name); List<Company> getCompaniesByEmailDomain(String domain); Companies search(String keywords); List<Company> getFollowing(); List<Company> getSuggestionsToFollow(); void startFollowingCompany(int id); void stopFollowingCompany(int id); Products getProducts(int companyId, int start, int count); static final String BASE_URL; static final String COMPANY_FIELDS; static final String COMPANY_URL; static final String COMPANY_SEARCH_URL; static final String COMPANY_FOLLOW_URL; static final String COMPANY_FOLLOW_START_STOP_URL; static final String COMPANY_SUGGESTIONS_TO_FOLLOW; static final String PRODUCT_FIELDS; static final String PRODUCTS_URL; }
@Test public void getSuggestionsToFollow() { mockServer.expect(requestTo(CompanyTemplate.COMPANY_SUGGESTIONS_TO_FOLLOW + "?oauth2_access_token=ACCESS_TOKEN")).andExpect(method(GET)) .andRespond(withSuccess(new ClassPathResource("suggestions_to_follow.json", getClass()), MediaType.APPLICATION_JSON)); List<Company> companies = linkedIn.companyOperations().getSuggestionsToFollow(); assertEquals(10, companies.size()); assertEquals("Ideo Technologies", companies.get(0).getName()); }