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


Java ServiceTestConfiguration类代码示例

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


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

示例1: getPortfolio

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void getPortfolio() throws Exception {
	when(service.getPortfolio(ServiceTestConfiguration.ACCOUNT_ID))
			.thenReturn(ServiceTestConfiguration.portfolio());

	mockMvc.perform(
			get("/portfolio/" + ServiceTestConfiguration.ACCOUNT_ID)
					.contentType(MediaType.APPLICATION_JSON))
			.andExpect(status().isOk())
			.andDo(print())
			.andExpect(
					content().contentTypeCompatibleWith(
							MediaType.APPLICATION_JSON))
			.andExpect(
					jsonPath("$.accountId").value(
							ServiceTestConfiguration.ACCOUNT_ID))
			.andExpect(jsonPath("$.holdings.*").value(hasSize(1)))
			.andDo(print());
}
 
开发者ID:trujillano,项目名称:springBootTrader-aos,代码行数:20,代码来源:PortfolioControllerTest.java

示例2: getPortfolio

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void getPortfolio() throws Exception {
	when(service.getPortfolio(ServiceTestConfiguration.USER_ID))
			.thenReturn(ServiceTestConfiguration.portfolio());

	mockMvc.perform(
			get("/portfolio/" + ServiceTestConfiguration.USER_ID)
					.contentType(MediaType.APPLICATION_JSON))
			.andExpect(status().isOk())
			.andDo(print())
			.andExpect(
					content().contentTypeCompatibleWith(
							MediaType.APPLICATION_JSON))
			.andExpect(
					jsonPath("$.userName").value(
							ServiceTestConfiguration.USER_ID))
			.andExpect(jsonPath("$.holdings.*").value(hasSize(1)))
			.andDo(print());
}
 
开发者ID:pivotal-bank,项目名称:portfolio-service,代码行数:20,代码来源:PortfolioControllerTest.java

示例3: addOrder

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
	public void addOrder() throws Exception {
		when(service.addOrder(ServiceTestConfiguration.order()))
		.thenReturn(ServiceTestConfiguration.order2());

mockMvc.perform(
		post("/portfolio/" + ServiceTestConfiguration.ACCOUNT_ID)
		.contentType(MediaType.APPLICATION_JSON)
				.content(
						convertObjectToJson(ServiceTestConfiguration.order())))
						.andExpect(status().isCreated()).andDo(print());

	}
 
开发者ID:trujillano,项目名称:springBootTrader-aos,代码行数:14,代码来源:PortfolioControllerTest.java

示例4: doGetPortfolio

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void doGetPortfolio() {

	when(repo.findByAccountId(ServiceTestConfiguration.ACCOUNT_ID)).thenReturn(ServiceTestConfiguration.orders());
	//when(quoteService.getUri()).thenReturn(uri);
	when(restTemplate.getForObject("http://quotes/quote/{symbol}", Quote.class, ServiceTestConfiguration.quote().getSymbol())).thenReturn(ServiceTestConfiguration.quote());
	Portfolio folio = service.getPortfolio(ServiceTestConfiguration.ACCOUNT_ID);
}
 
开发者ID:trujillano,项目名称:springBootTrader-aos,代码行数:9,代码来源:PortfolioServiceTest.java

示例5: doSaveOrderSellOrder

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void doSaveOrderSellOrder() {
	Order returnOrder = ServiceTestConfiguration.sellOrder();
	returnOrder.setOrderId(1);
	double amount = ServiceTestConfiguration.sellOrder().getQuantity()*ServiceTestConfiguration.sellOrder().getPrice().doubleValue()-ServiceTestConfiguration.sellOrder().getOrderFee().doubleValue();
	ResponseEntity<Double> response = new ResponseEntity<Double>(100d, HttpStatus.OK);
	
	
	//when(accountService.getUri()).thenReturn(uri);
	when(restTemplate.getForEntity("http://accounts/accounts/{userid}/increaseBalance/{amount}", Double.class, ServiceTestConfiguration.sellOrder().getAccountId(), amount )).thenReturn(response);
	when(repo.save(ServiceTestConfiguration.sellOrder())).thenReturn(returnOrder);
	Order order = service.addOrder(ServiceTestConfiguration.sellOrder());
	assertEquals(order, returnOrder);
}
 
开发者ID:trujillano,项目名称:springBootTrader-aos,代码行数:15,代码来源:PortfolioServiceTest.java

示例6: addOrder

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
	public void addOrder() throws Exception {
		when(service.addOrder(ServiceTestConfiguration.order()))
		.thenReturn(ServiceTestConfiguration.order2());

mockMvc.perform(
		post("/portfolio")
		.contentType(MediaType.APPLICATION_JSON)
				.content(
						convertObjectToJson(ServiceTestConfiguration.order())))
						.andExpect(status().isCreated()).andDo(print());

	}
 
开发者ID:pivotal-bank,项目名称:portfolio-service,代码行数:14,代码来源:PortfolioControllerTest.java

示例7: doGetPortfolio

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void doGetPortfolio() {

	when(repo.findByUserId(ServiceTestConfiguration.USER_ID)).thenReturn(ServiceTestConfiguration.orders());
	//when(quoteService.getUri()).thenReturn(uri);
	when(quoteService.getQuote(ServiceTestConfiguration.quote().getSymbol())).thenReturn(ServiceTestConfiguration.quote());
	//when(restTemplate.getForObject("http://" + service.quotesService +"/quote/{symbol}", Quote.class, ServiceTestConfiguration.quote().getSymbol())).thenReturn(ServiceTestConfiguration.quote());
	Portfolio folio = service.getPortfolio(ServiceTestConfiguration.USER_ID);
}
 
开发者ID:pivotal-bank,项目名称:portfolio-service,代码行数:10,代码来源:PortfolioServiceTest.java

示例8: doSaveOrderSellOrder

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void doSaveOrderSellOrder() {
	Order returnOrder = ServiceTestConfiguration.sellOrder();
	returnOrder.setOrderId(1);
	double amount = ServiceTestConfiguration.sellOrder().getQuantity()*ServiceTestConfiguration.sellOrder().getPrice().doubleValue()-ServiceTestConfiguration.sellOrder().getOrderFee().doubleValue();
	ResponseEntity<String> response = new ResponseEntity<String>("SUCCESS", HttpStatus.OK);
	
	
	//when(accountService.getUri()).thenReturn(uri);
	when(restTemplate.postForEntity(eq("http://" + service.accountsService +"/accounts/transaction"), any(), eq(String.class ))).thenReturn(response);
	when(repo.save(ServiceTestConfiguration.sellOrder())).thenReturn(returnOrder);
	Order order = service.addOrder(ServiceTestConfiguration.sellOrder());
	assertEquals(order, returnOrder);
}
 
开发者ID:pivotal-bank,项目名称:portfolio-service,代码行数:15,代码来源:PortfolioServiceTest.java

示例9: doGetQuoteFailure

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void doGetQuoteFailure() {
	when(restTemplate.getForObject("http://" + quotesURI + "/quote/{symbol}", Quote.class, ServiceTestConfiguration.SYMBOL)).thenThrow(new RuntimeException("Deliberately throwing an exception 1"));
	
	Quote quote = service.getQuote(ServiceTestConfiguration.SYMBOL);
	assertNotEquals(ServiceTestConfiguration.quote(),quote);
	Quote emptyQuote = new Quote();
	emptyQuote.setSymbol(ServiceTestConfiguration.SYMBOL);
	emptyQuote.setStatus("FAILED");
	assertEquals(emptyQuote,quote);
}
 
开发者ID:pivotal-bank,项目名称:portfolio-service,代码行数:12,代码来源:QuoteRemoteCallServiceTest.java

示例10: doGetPortfolio

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void doGetPortfolio() {

	when(repo.findByAccountId(ServiceTestConfiguration.ACCOUNT_ID)).thenReturn(ServiceTestConfiguration.orders());
	//when(quoteService.getUri()).thenReturn(uri);
	when(quoteService.getQuotes(ServiceTestConfiguration.quote().getSymbol())).thenReturn(Collections.singletonList(ServiceTestConfiguration.quote()));
	//when(restTemplate.getForObject("http://" + service.quotesService +"/quote/{symbol}", Quote.class, ServiceTestConfiguration.quote().getSymbol())).thenReturn(ServiceTestConfiguration.quote());
	Portfolio folio = service.getPortfolio(ServiceTestConfiguration.ACCOUNT_ID);
}
 
开发者ID:dpinto-pivotal,项目名称:cf-SpringBootTrader,代码行数:10,代码来源:PortfolioServiceTest.java

示例11: doSaveOrderSellOrder

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void doSaveOrderSellOrder() {
	Order returnOrder = ServiceTestConfiguration.sellOrder();
	returnOrder.setOrderId(1);
	double amount = ServiceTestConfiguration.sellOrder().getQuantity()*ServiceTestConfiguration.sellOrder().getPrice().doubleValue()-ServiceTestConfiguration.sellOrder().getOrderFee().doubleValue();
	ResponseEntity<Double> response = new ResponseEntity<Double>(100d, HttpStatus.OK);
	
	
	//when(accountService.getUri()).thenReturn(uri);
	when(restTemplate.getForEntity("http://" + service.accountsService +"/accounts/{userid}/increaseBalance/{amount}", Double.class, ServiceTestConfiguration.sellOrder().getAccountId(), amount )).thenReturn(response);
	when(repo.save(ServiceTestConfiguration.sellOrder())).thenReturn(returnOrder);
	Order order = service.addOrder(ServiceTestConfiguration.sellOrder());
	assertEquals(order, returnOrder);
}
 
开发者ID:dpinto-pivotal,项目名称:cf-SpringBootTrader,代码行数:15,代码来源:PortfolioServiceTest.java

示例12: doGetQuoteFailure

import io.pivotal.portfolio.config.ServiceTestConfiguration; //导入依赖的package包/类
@Test
public void doGetQuoteFailure() {
	when(restTemplate.getForObject("http://" + quotesURI + "/quotes?q={symbol}", Quote[].class, ServiceTestConfiguration.SYMBOL)).
			thenThrow(new RuntimeException("Deliberately throwing an exception 1"));

	List<Quote> quote = service.getQuotes(ServiceTestConfiguration.SYMBOL);
	assertNotEquals(ServiceTestConfiguration.quote(),quote.get(0));
	Quote emptyQuote = new Quote();
	emptyQuote.setSymbol(ServiceTestConfiguration.SYMBOL);
	emptyQuote.setStatus("FAILED");
	assertEquals(Collections.singletonList(emptyQuote),quote);
}
 
开发者ID:dpinto-pivotal,项目名称:cf-SpringBootTrader,代码行数:13,代码来源:QuoteRemoteCallServiceTest.java


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