CompanyTemplate extends AbstractTemplate implements CompanyOperations { public Products getProducts(int companyId, int start, int count) { return restOperations.getForObject(PRODUCTS_URL, Products.class, companyId, start, count); } 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 getProducts() { mockServer.expect(requestTo((CompanyTemplate.PRODUCTS_URL + "&oauth2_access_token=ACCESS_TOKEN") .replaceFirst("\\{id\\}", "1337") .replaceFirst("\\{start\\}", "0") .replaceFirst("\\{count\\}", "5"))).andExpect(method(GET)) .andRespond(withSuccess(new ClassPathResource("products.json", getClass()), MediaType.APPLICATION_JSON)); Products productResult = linkedIn.companyOperations().getProducts(1337, 0, 5); assertEquals(5, productResult.getCount()); assertEquals(0, productResult.getStart()); assertEquals(29, productResult.getTotal()); assertEquals(5, productResult.getProducts().size()); Product p = productResult.getProducts().get(0); assertEquals(new Date(1288188851297l), p.getCreationTimestamp()); assertEquals("LinkedIn Content Ads offer marketers the opportunity to distribute multiple streams of dynamic, robust content in a single ad unit. From video and blogs to Twitter and RSS feeds, these unique ad units can be targeted to a unique segment of LinkedIn professionals through our enhanced targeting capabilities. Easy to execute and available in standard 300x250 and 160x600 media sizes, content ads require minimal maintenance. Marketers can build loyal followers by exposing LinkedIn members to the full spectrum of your most valuable content.Key Features include:", p.getDescription()); assertEquals(4, p.getFeatures().size()); assertEquals("Engaging user experience", p.getFeatures().get(0)); assertEquals(1353, p.getId()); assertEquals("https: assertEquals("LinkedIn Content Ads", p.getName()); assertEquals(3, p.getNumRecommendations()); assertEquals("INT", p.getProductCategory().getCode()); assertEquals("Internet", p.getProductCategory().getName()); assertEquals(3, p.getRecommendations().size()); assertEquals(160209, p.getRecommendations().get(0).getId()); assertEquals(1353, p.getRecommendations().get(0).getProductId()); assertEquals("CSUN", p.getRecommendations().get(0).getRecommender().getFirstName()); assertEquals("4vmInU1H4C", p.getRecommendations().get(0).getRecommender().getId()); assertEquals("C.", p.getRecommendations().get(0).getRecommender().getLastName()); assertEquals("Please \"like\" our College Facebook ( https: assertEquals(new Date(1319639274411l), p.getRecommendations().get(0).getTimestamp()); }