当前位置: 首页>>代码示例>>Java>>正文


Java Quote类代码示例

本文整理汇总了Java中io.pivotal.quotes.domain.Quote的典型用法代码示例。如果您正苦于以下问题:Java Quote类的具体用法?Java Quote怎么用?Java Quote使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Quote类属于io.pivotal.quotes.domain包,在下文中一共展示了Quote类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getQuotes

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Retrieves the current quotes for the given symbols.
 * 
 * @param query
 *            request parameter with q=symbol,symbol
 * @return The Quote
 * @throws SymbolNotFoundException
 *             if the symbol is not valid.
 */
@RequestMapping(value = "/quotes", method = RequestMethod.GET)
public ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query) throws SymbolNotFoundException{
	logger.debug("received Quote query for: "+ query);
	if (query == null) {
		//return empty list.
		return new ResponseEntity<List<Quote>>(new ArrayList<Quote>(), getNoCacheHeaders(), HttpStatus.OK);
	}
	List<Quote> quotes;
	String[] splitQuery = query.split(",");
	if (splitQuery.length > 1) {
		quotes = service.getQuotes(query);
	} else {
		quotes = new ArrayList<>();
		quotes.add(service.getQuote(splitQuery[0]));
	}
	logger.info(String.format("Retrieved symbols: %s with quotes {}", query, quotes));
	return new ResponseEntity<List<Quote>>(quotes, getNoCacheHeaders(), HttpStatus.OK);
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:28,代码来源:QuoteV1Controller.java

示例2: getQuotes

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Retrieve multiple quotes at once.
 * 
 * @param symbols
 *            comma delimeted list of symbols.
 * @return a list of quotes.
 */
public List<Quote> getQuotes(String symbols) {
	logger.debug("retrieving multiple quotes for: "
			+ symbols);
	logger.debug("yahoo URL: "
			+ yahoo_url);
	logger.debug("env URL: "
			+ ENV);
	YahooQuoteResponse response = restTemplate.getForObject(yahoo_url,
			YahooQuoteResponse.class, ENV, symbols, FMT);
	logger.debug("Got response: " + response);
	List<Quote> quotes = response
			.getResults()
			.getQuoteList()
			.getQuote()
			.stream()
			.map(yQuote -> QuoteMapper.INSTANCE.mapFromYahooQuote(yQuote,
					response.getResults().getCreated()))
			.collect(Collectors.toList());
	return quotes;
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:28,代码来源:QuoteService.java

示例3: quote2

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
public static Quote quote2() {
	Quote quote = new Quote();
	quote.setName("International Business Machine");
	quote.setSymbol("IBM");
	quote.setLastPrice(QUOTE_LAST_PRICE);
	quote.setChange(QUOTE_CHANGE);
	quote.setChangePercent(QUOTE_CHANGE_PERCENT);
	try {
		quote.setTimestamp(dateFormat.parse(QUOTE_DATE_STRING));
	} catch (ParseException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	quote.setmSDate(QUOTE_MSDATE);
	quote.setMarketCap(50755764235.00f);
	quote.setVolume(15159291);
	quote.setChangeYTD(29.74f);
	quote.setChangePercentYTD(-12.1217215870881f);
	quote.setHigh(new BigDecimal(0.0));
	quote.setLow(new BigDecimal(0.0));
	quote.setOpen(new BigDecimal(26.52));
	return quote;
	
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:25,代码来源:TestConfiguration.java

示例4: getQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Retrives the current quote for the given symbol.
 * 
 * @param symbol The symbol to retrieve the quote for.
 * @return The Quote
 * @throws SymbolNotFoundException if the symbol is not valid.
 */
@RequestMapping(value = "/quote/{symbol}", method = RequestMethod.GET)
public ResponseEntity<Quote> getQuote(@PathVariable("symbol") final String symbol) throws SymbolNotFoundException {
	logger.debug("QuoteController.getQuote: retrieving quote for: " + symbol);
	Quote quote = service.getQuote(symbol);
	logger.info(String.format("Retrieved symbol: %s with quote %s", symbol, quote));
	return new ResponseEntity<Quote>(quote,
			getNoCacheHeaders(), HttpStatus.OK);
}
 
开发者ID:trujillano,项目名称:springBootTrader-aos,代码行数:16,代码来源:QuoteController.java

示例5: getQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Retrieves an up to date quote for the given symbol.
 * 
 * @param symbol The symbol to retrieve the quote for.
 * @return The quote object or null if not found.
 * @throws SymbolNotFoundException 
 */
public Quote getQuote(String symbol) throws SymbolNotFoundException {
	logger.debug("QuoteService.getQuote: retrieving quote for: " + symbol);
	Map<String, String> params = new HashMap<String, String>();
    params.put("symbol", symbol);

    Quote quote = restTemplate.getForObject(QUOTE_URL, Quote.class, params);
       logger.debug("QuoteService.getQuote: retrieved quote: " + quote);
       
       if (quote.getSymbol() ==  null) {
       	throw new SymbolNotFoundException("Symbol not found: " + symbol);
       }
	return quote;
}
 
开发者ID:trujillano,项目名称:springBootTrader-aos,代码行数:21,代码来源:QuoteService.java

示例6: getQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Tests retrieving a quote from the external service.
 * @throws Exception
 */
@Test
public void getQuote() throws Exception {
	Quote quote = service.getQuote(TestConfiguration.QUOTE_SYMBOL);
	assertEquals(TestConfiguration.QUOTE_SYMBOL, quote.getSymbol());
	assertEquals(TestConfiguration.QUOTE_NAME, quote.getName());
}
 
开发者ID:trujillano,项目名称:springBootTrader-aos,代码行数:11,代码来源:QuoteServiceTest.java

示例7: getQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Retrieves an up to date quote for the given symbol.
 * 
 * @param symbol
 *            The symbol to retrieve the quote for.
 * @return The quote object or null if not found.
 * @throws SymbolNotFoundException
 */
@HystrixCommand(fallbackMethod = "getQuoteFallback")
public Quote getQuote(String symbol) throws SymbolNotFoundException {
	logger.debug("QuoteService.getQuote: retrieving quote for: " + symbol);
	Map<String, String> params = new HashMap<String, String>();
	params.put("symbol", symbol);

	Quote quote = restTemplate.getForObject(quote_url, Quote.class, params);
	logger.debug("QuoteService.getQuote: retrieved quote: " + quote);

	if (quote.getSymbol() == null) {
		throw new SymbolNotFoundException("Symbol not found: " + symbol);
	}
	return quote;
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:23,代码来源:QuoteService.java

示例8: getQuoteFallback

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
@SuppressWarnings("unused")
private Quote getQuoteFallback(String symbol)
		throws SymbolNotFoundException {
	logger.debug("QuoteService.getQuoteFallback: circuit opened for symbol: "
			+ symbol);
	Quote quote = new Quote();
	quote.setSymbol(symbol);
	quote.setStatus("FAILED");
	return quote;
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:11,代码来源:QuoteService.java

示例9: getQuotesOneQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
@Test
public void getQuotesOneQuote() throws Exception {
	List<Quote> quotes = new ArrayList<>();
	quotes.add(TestConfiguration.quote());
	when(service.getQuote(TestConfiguration.QUOTE_SYMBOL)).thenReturn(
			TestConfiguration.quote());
	mockMvc.perform(
			get("/v1/quotes?q=" + TestConfiguration.QUOTE_SYMBOL).contentType(
					MediaType.APPLICATION_JSON)).andExpect(status().isOk())
					.andExpect(jsonPath("$",hasSize(1)))
					.andExpect(
					content().contentTypeCompatibleWith(
							MediaType.APPLICATION_JSON))
			.andExpect(
					jsonPath("$[0].Name").value(
							TestConfiguration.QUOTE_NAME))
			.andExpect(
					jsonPath("$[0].Symbol").value(
							TestConfiguration.QUOTE_SYMBOL))
			.andExpect(
					jsonPath("$[0].LastPrice").value(
							TestConfiguration.QUOTE_LAST_PRICE))
			.andExpect(
					jsonPath("$[0].Change",Matchers.closeTo(TestConfiguration.QUOTE_CHANGE, new BigDecimal(0.01))))
			.andExpect(
					jsonPath("$[0].ChangePercent", Matchers.closeTo(TestConfiguration.QUOTE_CHANGE_PERCENT, 0.01)))
			.andExpect(
					jsonPath("$[0].Timestamp",notNullValue()))
			.andExpect(
					jsonPath("$[0].MSDate",Matchers.closeTo(
							TestConfiguration.QUOTE_MSDATE,0.01)))
					.andDo(print());
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:34,代码来源:QuoteV1ControllerTest.java

示例10: getQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Tests retrieving a quote from the external service.
 * @throws Exception
 */
@Test
public void getQuote() throws Exception {
	Quote quote = service.getQuote(TestConfiguration.QUOTE_SYMBOL);
	assertEquals(TestConfiguration.QUOTE_SYMBOL, quote.getSymbol());
	//assertEquals(TestConfiguration.QUOTE_NAME, quote.getName());
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:11,代码来源:QuoteServiceTest.java

示例11: getNullQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
@Test
public void getNullQuote() throws Exception{
	//thrown.expect(com.netflix.hystrix.exception.HystrixRuntimeException.class);
	//thrown.expectCause(isA(SymbolNotFoundException.class));
	Quote quote = service.getQuote(TestConfiguration.NULL_QUOTE_SYMBOL);
	assertEquals(quote.getStatus(),"FAILED");
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:8,代码来源:QuoteServiceTest.java

示例12: getQuotes

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * test yahoo service with multiple quotes
 * @throws Exception
 */
@Test
public void getQuotes()  throws Exception {
	List<Quote> quotes = service.getQuotes(TestConfiguration.QUOTE_SYMBOLS);
	assertNotNull("should have 2 quotes",quotes);
	assertEquals("should have 2 quotes",quotes.size(), 2);
}
 
开发者ID:pivotal-bank,项目名称:quotes-service,代码行数:11,代码来源:QuoteServiceTest.java

示例13: getQuotes

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Retrieves the current quotes for the given symbols.
 *
 * @param query
 *            request parameter with q=symbol,symbol
 * @return The Quote
 * @throws SymbolNotFoundException
 *             if the symbol is not valid.
 */
@RequestMapping(value = "/quotes", method = RequestMethod.GET)
public ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query) throws SymbolNotFoundException {
	logger.debug("received Quote query for: %s", query);
	if (query == null) {
		//return empty list.
		return new ResponseEntity<>(new ArrayList<>(), getNoCacheHeaders(), HttpStatus.OK);
	}

	List<Quote> quotes = service.getQuotes( query );

	logger.info(String.format("Retrieved symbols: %s with quotes {}", query));
	return new ResponseEntity<>(quotes, getNoCacheHeaders(), HttpStatus.OK);
}
 
开发者ID:dpinto-pivotal,项目名称:cf-SpringBootTrader,代码行数:23,代码来源:QuoteController.java

示例14: getQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Tests retrieving a quote from the external service.
 * @throws Exception
 */
@Test
public void getQuote() throws Exception {
	Quote quote = service.getQuotes(TestConfiguration.QUOTE_SYMBOL).get(0);
	assertEquals(TestConfiguration.QUOTE_SYMBOL, quote.getSymbol());
	assertEquals(TestConfiguration.QUOTE_NAME, quote.getName());
}
 
开发者ID:dpinto-pivotal,项目名称:cf-SpringBootTrader,代码行数:11,代码来源:QuoteServiceTest.java

示例15: getNullQuote

import io.pivotal.quotes.domain.Quote; //导入依赖的package包/类
/**
 * Tests retrieving a quote with an unknown/null symbol from the external service.
 * @throws Exception
 */
@Test(expected=SymbolNotFoundException.class)
public void getNullQuote() throws Exception{
	Quote quote = service.getQuote(TestConfiguration.NULL_QUOTE_SYMBOL);
}
 
开发者ID:trujillano,项目名称:springBootTrader-aos,代码行数:9,代码来源:QuoteServiceTest.java


注:本文中的io.pivotal.quotes.domain.Quote类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。