Commit 7ab1dc79 authored by libin's avatar libin

购房车

parent 015d00f7
package com.github.wxiaoqi.service;
import com.github.wxiaoqi.security.admin.AdminBootstrap;
import com.github.wxiaoqi.security.admin.mapper.AppUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/8/6 16:43
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = {AdminBootstrap.class})
@Slf4j
public class MapperTest {
@Autowired
private AppUserMapper appUserMapper;
@Test
public void testOptional(){
}
}
package com.github.wxiaoqi.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.admin.AdminBootstrap;
import com.github.wxiaoqi.security.admin.biz.*;
import com.github.wxiaoqi.security.admin.dto.UserPostionDTO;
import com.github.wxiaoqi.security.admin.dto.WalletFindDTO;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.context.WebApplicationContext;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
* @author libin
* @version 1.0
* @description
* @data 2019/7/17 15:37
*/
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = AdminBootstrap.class)
public class ServiceTest {
@Autowired
private WebApplicationContext wac;
@Autowired
private MyWalletBiz myWalletBiz;
@Autowired
private MyWalletDetailBiz myWalletDetailBiz;
@Autowired
private AppUserLoginBiz appUserLoginBiz;
@Autowired
private AppUserDetailBiz appUserDetailBiz;
private MockMvc mockMvc;
private String token;
@Autowired
private GroupBiz groupBiz;
// @Before
public void init() throws Exception {
mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
long loginCode = 0;
/* LinkedMultiValueMap smsparam = new LinkedMultiValueMap();
smsparam.put("username",Arrays.asList("19972242603"));
smsparam.put("type",Arrays.asList(1));
MvcResult smsResult = mockMvc.perform(MockMvcRequestBuilders.post("/api/app/user/sendsms").params(smsparam)
.header("Content-Type", "application/json"))
.andExpect(status().isOk())
.andReturn();
loginCode = Long.valueOf(smsResult.getResponse().getContentAsString());
log.debug("登录验证码:【{}】",loginCode);*/
LinkedMultiValueMap loginParams = new LinkedMultiValueMap();
loginParams.put("username",Arrays.asList("19972242603"));
loginParams.put("mobilecode",Arrays.asList("5003"));
loginParams.put("password",Arrays.asList("12345678"));
loginParams.put("type",Arrays.asList("1"));
MvcResult tokenResult = mockMvc.perform(MockMvcRequestBuilders.post("/api/app/user/login")
.params(loginParams)
.header("Content-Type", "application/json"))
.andExpect(status().isOk())
.andReturn();
String contentAsString = tokenResult.getResponse().getContentAsString();
JSONObject jsonObject = JSONObject.parseObject(contentAsString);
log.debug("**************************");
log.debug("登录的token:【{}】", token);
log.debug("**************************");
}
@Test
public void testWalletPage() throws Exception {
WalletFindDTO walletFindDTO = new WalletFindDTO();
walletFindDTO.setPhone("19972242603");
walletFindDTO.setPage(1);
walletFindDTO.setLimit(20);
LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.put("page", Arrays.asList("1"));
params.put("limit", Arrays.asList("20"));
params.put("phone", Arrays.asList("19972242603"));
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/wallet/admin/page").params(params)
.header("Content-Type", "application/json"))
.andExpect(status().is(200))
.andReturn();
log.debug("返回的结果:【{}】", mvcResult.getResponse().getContentAsString());
}
@Test
public void testBatchUpdatePostion() throws Exception {
List<UserPostionDTO> userPostionDTOS = new ArrayList<>();
UserPostionDTO userPostionDTO = new UserPostionDTO();
userPostionDTO.setId(1);
userPostionDTO.setExtract(50);
UserPostionDTO userPostion2 = new UserPostionDTO();
userPostion2.setExtract(25);
userPostion2.setId(2);
userPostionDTOS.add(userPostionDTO);
userPostionDTOS.add(userPostion2);
log.debug("更新数据:【{}】", JSON.toJSONString(userPostionDTOS));
mockMvc.perform(MockMvcRequestBuilders.put("/postion/admin")
.header("Content-Type", "application/json")
.content(JSON.toJSONString(userPostionDTOS)))
.andExpect(status().is(200))
.andReturn();
}
@Test
public void testPostions() throws Exception {
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/postion/admin/postions")
.header("Content-Type", "application/json"))
.andExpect(status().is(200))
.andReturn();
log.debug("返回结果:【{}】", mvcResult.getResponse().getContentAsString());
}
@Test
public void testWalletDetailAdminPage() throws Exception {
LinkedMultiValueMap<String, String> linkedMultiValueMap = new LinkedMultiValueMap();
linkedMultiValueMap.put("page", Arrays.asList("1"));
linkedMultiValueMap.put("limit", Arrays.asList("20"));
linkedMultiValueMap.put("source", Arrays.asList("1"));
linkedMultiValueMap.put("username", Arrays.asList("XX"));
// linkedMultiValueMap.put("phone", Arrays.asList("19972242603"));
log.debug("请求参数:【{}】", JSON.toJSONString(linkedMultiValueMap));
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/walletdetail/admin/page").params(linkedMultiValueMap)
.header("Content-Type", "application/json"))
.andExpect(status().is(200))
.andReturn();
String contentAsString = mvcResult.getResponse().getContentAsString();
log.debug("请求返回的结果:【{}】", contentAsString);
}
/**
* walletcath/admin
*/
@Test
public void testWalletCathPage() throws Exception {
LinkedMultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.put("page", Arrays.asList("1"));
params.put("limit", Arrays.asList("20"));
params.put("username", Arrays.asList("XX_981132"));
params.put("phone", Arrays.asList("19972242603"));
params.put("state", Arrays.asList("1"));
log.debug("请求参数:【{}】", JSON.toJSONString(params));
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("/walletcath/admin/page").params(params)
.header("Content-Type", "application/json"))
.andExpect(status().is(200))
.andReturn();
log.debug("返回的结果:【{}】", mvcResult.getResponse().getContentAsString());
}
@Test
public void testPromote() throws Exception {
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.get("")
.header("Authorization", token)
.header("Content-Type","application/json"))
.andExpect(status().isOk())
.andReturn();
log.debug("返回的结果:【{}】", mvcResult.getResponse().getContentAsString());
}
@Test
public void testUnBinding(){
appUserLoginBiz.unBindThirdPartyByType("wx","18178966185",265);
}
@Test
public void testGetByUserName(){
appUserLoginBiz.getUserByUsername("18178966185");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment