當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。