init project
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.mt.wms.upms;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* @author jiff
|
||||
* @date 2018-12-11
|
||||
* @since 1.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class LisPlatformUpmsApplicationTest {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.mt.wms.upms.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mt.wms.core.dto.LoginUser;
|
||||
import com.mt.wms.core.dto.Permission;
|
||||
import com.mt.wms.upms.LisPlatformUpmsApplicationTest;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jiff
|
||||
* @date 2018-12-11
|
||||
* @since 1.0
|
||||
*/
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class UpmsControllerTest extends LisPlatformUpmsApplicationTest {
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
private HttpHeaders httpHeaders = new HttpHeaders();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
httpHeaders.add(LoginUser.HTTP_HEADER_NAME, JSON.toJSONString(LoginUser.builder().userId(1L).userName("jiff")
|
||||
.orgId(1L).userType(LoginUser.USER_TYPE_PLATFORM).build()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPermissions() {
|
||||
ParameterizedTypeReference<List<Permission>> type = new ParameterizedTypeReference<List<Permission>>() {
|
||||
};
|
||||
ResponseEntity<List<Permission>> responseEntity = restTemplate.exchange("/upms/getPermissions", HttpMethod.POST, new HttpEntity<>(httpHeaders), type);
|
||||
Assert.assertThat(responseEntity.getBody().get(0).getUrl(), Matchers.notNullValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.mt.wms.upms.mapper;
|
||||
|
||||
import com.mt.wms.core.dto.Permission;
|
||||
import com.mt.wms.core.enums.AppTypeEnum;
|
||||
import com.mt.wms.upms.LisPlatformUpmsApplicationTest;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jiff
|
||||
* @date 2018-12-11
|
||||
* @since 1.0
|
||||
*/
|
||||
public class ResourceMapperTest extends LisPlatformUpmsApplicationTest {
|
||||
@Autowired
|
||||
private ResourceMapper resourceMapper;
|
||||
|
||||
@Test
|
||||
public void listByUser() {
|
||||
List<Permission> permissions = resourceMapper.listByUser(1l, AppTypeEnum.PC.getValue());
|
||||
Assert.notEmpty(permissions, "权限为空");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.mt.wms.upms.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.mt.wms.upms.LisPlatformUpmsApplicationTest;
|
||||
import com.mt.wms.upms.params.SysUserQueryParam;
|
||||
import com.mt.wms.upms.vo.SysUserVo;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jiff
|
||||
* @date 2018-12-11
|
||||
* @since 1.0
|
||||
*/
|
||||
public class UserMapperTest extends LisPlatformUpmsApplicationTest {
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Test
|
||||
public void listByOrg() {
|
||||
SysUserQueryParam queryParam = SysUserQueryParam.builder().genealogyId("/1").name("ff").sex(1).build();
|
||||
queryParam.setCurrent(1);
|
||||
queryParam.setSize(10);
|
||||
IPage page = new Page(queryParam.getCurrent(), queryParam.getSize());
|
||||
List<SysUserVo> sysUserVos = userMapper.listByOrg(page, queryParam);
|
||||
page.setRecords(sysUserVos);
|
||||
Assert.assertEquals(page.getRecords(), sysUserVos);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.mt.wms.upms.service;
|
||||
|
||||
import com.mt.wms.upms.LisPlatformUpmsApplicationTest;
|
||||
import com.mt.wms.upms.params.MenuResourceQueryParam;
|
||||
import com.mt.wms.core.vo.PageVo;
|
||||
import com.mt.wms.core.vo.R;
|
||||
import com.mt.wms.upms.vo.ResourceVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author jiff
|
||||
* @date 2018-12-13
|
||||
* @since 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
public class MenuResourceServiceTest extends LisPlatformUpmsApplicationTest {
|
||||
@Autowired
|
||||
private MenuResourceService menuResourceService;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
log.info("setUp");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
log.info("tearDown");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pageWithMenu() {
|
||||
MenuResourceQueryParam param = new MenuResourceQueryParam().setMenuId(1L);
|
||||
param.setCurrent(1);
|
||||
param.setSize(10);
|
||||
R<PageVo<ResourceVo>> r = menuResourceService.pageWithMenu(param);
|
||||
Assert.assertThat(r.getData().getRecords(), Matchers.hasSize(1));
|
||||
r = menuResourceService.pageWithMenu(param.setMenuId(2L));
|
||||
Assert.assertThat(r.getData().getRecords(), Matchers.hasSize(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pageWithMenuByParam() {
|
||||
MenuResourceQueryParam param = new MenuResourceQueryParam().setMenuId(1L).setName("获取");
|
||||
param.setCurrent(1);
|
||||
param.setSize(10);
|
||||
R<PageVo<ResourceVo>> r = menuResourceService.pageWithMenu(param);
|
||||
Assert.assertThat(r.getData().getRecords(), Matchers.hasSize(1));
|
||||
|
||||
r = menuResourceService.pageWithMenu(param.setMenuId(2L).setName(null).setUrl("add"));
|
||||
Assert.assertThat(r.getData().getRecords(), Matchers.hasSize(1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2018.
|
||||
* http://www.ulabcare.com
|
||||
*/
|
||||
|
||||
package com.mt.wms.upms.service;
|
||||
|
||||
import com.mt.wms.upms.LisPlatformUpmsApplicationTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author jiff
|
||||
* @date 2018-12-11
|
||||
* @since 1.0
|
||||
*/
|
||||
public class UpmsServiceTest extends LisPlatformUpmsApplicationTest {
|
||||
@Autowired
|
||||
private UpmsService upmsService;
|
||||
|
||||
public void getPermissions() {
|
||||
upmsService.getPermissions();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user