单元测试搭建

master
shijie 4 years ago
parent aedfe7bb62
commit a61dd5d73a
  1. 10
      pom.xml
  2. 2
      src/main/java/com/yipin/liuwanr/ProjectMaagementApplication.java
  3. 198
      src/test/java/com/yipin/liuwanr/Project_ManagementTest.java

@ -85,6 +85,16 @@
<artifactId>spring-boot-test</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>

@ -3,7 +3,9 @@ package com.yipin.liuwanr;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@SpringBootApplication
@MapperScan(basePackages = {"com.yipin.liuwanr.mapper"})
public class ProjectMaagementApplication {

@ -0,0 +1,198 @@
package com.yipin.liuwanr;
import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.service.Project_ManagementService;
import io.swagger.annotations.ApiParam;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@SpringBootTest
public class Project_ManagementTest {
@Autowired
private Project_ManagementService managementService;
/**
* 查询用户角色信息
*/
@Test
public void testQueryRole() {
int userid = 455;
HashMap<String, Object> map = managementService.queryRole(userid);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 分页查询+条件查询
*/
@Test
public void testQueryAllManagements() {
Integer projectPermissions = null;
Integer founder = null;
Integer state = null;
String projectName = null;
Integer systemId = 1;
Integer userId = 4;
Project_Management vo = new Project_Management();
if (null != projectPermissions) {
vo.setProjectPermissions(projectPermissions);
}
if (null != founder) {
vo.setFounder(founder);
}
if (null != state) {
vo.setState(state);
}
if (null != systemId) {
vo.setSystemId(systemId);
}
if (null != projectName && projectName != "") {
vo.setProjectName(projectName);
}
if (null != userId) {
vo.setUserId(userId);
}
Integer pageNo = 1;
Integer pageSize = 10;
HashMap<String, Object> map = managementService.queryAllManagements(vo, pageNo, pageSize);
map.forEach((key, value) -> {
System.out.println("key = " + key + " ===> value = " + value);
});
}
/**
* 批量删除
*/
@Transactional
@Test
public void testDeleteProjectManagement() {
List<Integer> point = new ArrayList<>();
point.add(1);
HashMap<String, Object> map = managementService.deleteProjectManagement(point);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 根据项目管理id查询对应信息
*/
@Test
public void testGetProjectId() {
Integer projectId = null;
HashMap<String, Object> map = managementService.getProjectId(projectId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 添加判分点页面的判分点信息展示
*/
@Test
public void testQueryAllJudgmentPoints() {
Judgment_Points points = null;
HashMap<String, Object> map = managementService.queryAllJudgmentPoints(points);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 创建项目管理页面的判分点信息展示
*/
@Test
public void testGetByjudgmentPointsId() {
List<Integer> judgmentPointsId = null;
Integer projectId = null;
Integer userId = null;
HashMap<String, Object> map = managementService.getByjudgmentPointsId(judgmentPointsId, projectId, userId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 平均分配分值
*/
@Test
public void testAvgValues() {
Integer number = null;
HashMap<String, Object> map = managementService.avgValues(number);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 添加完角色信息 角色信息展示
*/
@Test
public void testGetByRoleId() {
List<Integer> roleId = null;
HashMap<String, Object> map = managementService.getByRoleId(roleId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 修改角色信息
*/
@Test
public void testUpdateRole() {
Role role = null;
HashMap<String, Object> map = managementService.updateRole(role);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 添加角色信息
*/
@Test
public void testInsertRole() {
Role role = null;
HashMap<String, Object> map = managementService.insertRole(role);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 添加项目管理信息
*/
@Transactional
@Test
public void testInsertProjectManagement() {
Project_Management pro = null;
List<Judgment_Points> points = null;
List<Integer> roles = null;
HashMap<String, Object> map = managementService.insertProjectManagement(pro, points, roles);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
@Test
public void testGetByName() {
String projectName = null;
HashMap<String, Object> map = managementService.getByName(projectName);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
/**
* 修改项目管理信息
*/
@Transactional
@Test
public void testUpdateProjectManagement() {
Project_Management pro = null;
List<Judgment_Points> points = null;
List<Integer> roles = null;
HashMap<String, Object> map = managementService.updateProjectManagement(pro, points, roles);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
}
Loading…
Cancel
Save