QuoteService { @HystrixCommand(fallbackMethod = "getCompanyInfoFallback", commandProperties = {@HystrixProperty(name="execution.timeout.enabled", value="false")}) public List<CompanyInfo> getCompanyInfo(String name) { logger.debug("QuoteService.getCompanyInfo: retrieving info for: " + name); Map<String, String> params = new HashMap<>(); params.put("name", name); CompanyInfo[] companies = restTemplate.getForObject(company_url, CompanyInfo[].class, params); logger.debug("QuoteService.getCompanyInfo: retrieved info: " + Arrays.toString(companies)); return Arrays.asList(companies); } QuoteService(); @HystrixCommand(fallbackMethod = "getMarkitondemandQuotes", commandProperties = {@HystrixProperty(name="execution.timeout.enabled", value="false")}) List<Quote> getQuotes(String symbols); @HystrixCommand(fallbackMethod = "getQuotesFallback", commandProperties = {@HystrixProperty(name="execution.timeout.enabled", value="false")}) @SuppressWarnings("unused") List<Quote> getMarkitondemandQuotes(String symbols); @HystrixCommand(fallbackMethod = "getCompanyInfoFallback", commandProperties = {@HystrixProperty(name="execution.timeout.enabled", value="false")}) List<CompanyInfo> getCompanyInfo(String name); static final String FMT; }
@Test public void getCompanyInfo() throws Exception { List<CompanyInfo> comps = service.getCompanyInfo(TestConfiguration.QUOTE_SYMBOL); assertFalse(comps.isEmpty()); boolean pass = false; for (CompanyInfo info : comps) { if (info.getSymbol().equals(TestConfiguration.QUOTE_SYMBOL)) { pass = true; } } assertTrue(pass); }
@Test public void getNullCompanyInfo() throws Exception { List<CompanyInfo> comps = service.getCompanyInfo(TestConfiguration.NULL_QUOTE_SYMBOL); assertTrue(comps.isEmpty()); }