本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}