单元测试

master
shijie 4 years ago
parent 9adae8ada6
commit dc28241da8
  1. 15
      src/main/java/com/yipin/liuwanr/entity/Judgment_Points.java
  2. 24
      src/main/java/com/yipin/liuwanr/entity/Project_Management.java
  3. 10
      src/main/java/com/yipin/liuwanr/entity/Role.java
  4. 1
      src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java
  5. 131
      src/test/java/com/yipin/liuwanr/Project_ManagementTest.java

@ -106,5 +106,18 @@ public class Judgment_Points {
this.isdel = isdel;
}
@Override
public String toString() {
return "Judgment_Points{" +
"judgmentPointsId=" + judgmentPointsId +
", judgmentPointsName='" + judgmentPointsName + '\'' +
", experimentalRequirements='" + experimentalRequirements + '\'' +
", projectId='" + projectId + '\'' +
", judgmentPointsType=" + judgmentPointsType +
", isdel=" + isdel +
", systemId=" + systemId +
", userId=" + userId +
", score=" + score +
'}';
}
}

@ -222,4 +222,28 @@ public class Project_Management {
this.isAttendance = isAttendance;
}
@Override
public String toString() {
return "Project_Management{" +
"projectId=" + projectId +
", projectName='" + projectName + '\'' +
", projectPermissions=" + projectPermissions +
", founder=" + founder +
", creationTime='" + creationTime + '\'' +
", state=" + state +
", experimentalGoal='" + experimentalGoal + '\'' +
", caseDescription='" + caseDescription + '\'' +
", experimentTask='" + experimentTask + '\'' +
", experimentalDataId='" + experimentalDataId + '\'' +
", experimentSuggests='" + experimentSuggests + '\'' +
", systemId=" + systemId +
", isdel=" + isdel +
", isShow=" + isShow +
", isstartexperimental=" + isstartexperimental +
", isstartexperimentSuggests=" + isstartexperimentSuggests +
", isExperiment=" + isExperiment +
", isAttendance=" + isAttendance +
", userId=" + userId +
'}';
}
}

@ -65,4 +65,14 @@ public class Role implements Serializable {
this.roleAttribute = roleAttribute;
}
@Override
public String toString() {
return "Role{" +
"roleId=" + roleId +
", roleName='" + roleName + '\'' +
", roleNumber=" + roleNumber +
", roleType=" + roleType +
", roleAttribute=" + roleAttribute +
'}';
}
}

@ -459,6 +459,7 @@ public class Project_ManagementService {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Add Failed");
System.out.println(e.getMessage());
throw new RuntimeException();
}
return resp;

@ -1,14 +1,13 @@
package com.yipin.liuwanr;
import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.mapper.Project_ManagementMapper;
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;
@ -20,16 +19,21 @@ public class Project_ManagementTest {
@Autowired
private Project_ManagementService managementService;
@Autowired
private Project_ManagementMapper projectManagementMapper;
/**
* 查询用户角色信息
*/
@Test
public void testQueryRole() {
int userid = 455;
Integer userid = 455;
HashMap<String, Object> map = managementService.queryRole(userid);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
map.forEach((key, value) -> {
System.out.println("key = " + key + " ===> value = " + value.toString());
});
}
/**
@ -69,10 +73,28 @@ public class Project_ManagementTest {
Integer pageSize = 10;
HashMap<String, Object> map = managementService.queryAllManagements(vo, pageNo, pageSize);
map.forEach((key, value) -> {
System.out.println("key = " + key + " ===> value = " + value);
Integer retcode = (Integer) map.get("retcode");
System.out.println(retcode);
if (retcode == 200) {
PageResult pageResult = (PageResult) map.get("retvalue");
Long total = pageResult.getTotal();
System.out.println("total = " + total);
List<Project_Management> rows = (List<Project_Management>) pageResult.getRows();
rows.forEach(item -> {
System.out.println(item.toString());
});
} else {
String msg = (String) map.get("retvalue");
System.out.println(msg);
}
}
@ -85,7 +107,7 @@ public class Project_ManagementTest {
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));
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
/**
@ -93,9 +115,9 @@ public class Project_ManagementTest {
*/
@Test
public void testGetProjectId() {
Integer projectId = null;
Integer projectId = 299;
HashMap<String, Object> map = managementService.getProjectId(projectId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
/**
@ -103,9 +125,21 @@ public class Project_ManagementTest {
*/
@Test
public void testQueryAllJudgmentPoints() {
Judgment_Points points = null;
Judgment_Points points = new Judgment_Points();
points.setSystemId(1);
points.setJudgmentPointsName("");
HashMap<String, Object> map = managementService.queryAllJudgmentPoints(points);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
Integer retcode = (Integer) map.get("retcode");
System.out.println(retcode);
if (retcode == 200) {
List<Judgment_Points> list = (List<Judgment_Points>) map.get("retvalue");
list.forEach(item -> {
System.out.println(item.toString());
});
} else {
String msg = (String) map.get("retvalue");
System.out.println(msg);
}
}
@ -114,11 +148,22 @@ public class Project_ManagementTest {
*/
@Test
public void testGetByjudgmentPointsId() {
List<Integer> judgmentPointsId = null;
Integer projectId = null;
Integer userId = null;
List<Integer> judgmentPointsId = new ArrayList<>();
judgmentPointsId.add(187);
Integer projectId = 1;
Integer userId = 4;
HashMap<String, Object> map = managementService.getByjudgmentPointsId(judgmentPointsId, projectId, userId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
Integer retcode = (Integer) map.get("retcode");
System.out.println(retcode);
if (retcode == 200) {
List<Judgment_Points> list = (List<Judgment_Points>) map.get("retvalue");
list.forEach(item -> {
System.out.println(item.toString());
});
} else {
String msg = (String) map.get("retvalue");
System.out.println(msg);
}
}
/**
@ -126,7 +171,7 @@ public class Project_ManagementTest {
*/
@Test
public void testAvgValues() {
Integer number = null;
Integer number = 66;
HashMap<String, Object> map = managementService.avgValues(number);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
}
@ -136,9 +181,10 @@ public class Project_ManagementTest {
*/
@Test
public void testGetByRoleId() {
List<Integer> roleId = null;
List<Integer> roleId = new ArrayList<>();
roleId.add(235);
HashMap<String, Object> map = managementService.getByRoleId(roleId);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
/**
@ -146,9 +192,17 @@ public class Project_ManagementTest {
*/
@Test
public void testUpdateRole() {
Role role = null;
List<Integer> list = new ArrayList<>();
list.add(235);
List<Role> roleList = projectManagementMapper.getByRoleId(list);
Role role = roleList.get(0);
role.setRoleName("hh");
//System.out.println(role.toString());//Role{roleId=235, roleName='null', roleNumber=1, roleType=1, roleAttribute=1}
HashMap<String, Object> map = managementService.updateRole(role);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
/**
@ -156,9 +210,16 @@ public class Project_ManagementTest {
*/
@Test
public void testInsertRole() {
Role role = null;
List<Integer> list = new ArrayList<>();
list.add(235);
List<Role> roleList = projectManagementMapper.getByRoleId(list);
Role role = roleList.get(0);
role.setRoleId(null);
role.setRoleName("hh");
HashMap<String, Object> map = managementService.insertRole(role);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value));
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
}
/**
@ -167,14 +228,34 @@ public class Project_ManagementTest {
@Transactional
@Test
public void testInsertProjectManagement() {
Project_Management pro = null;
List<Judgment_Points> points = null;
List<Integer> roles = null;
Project_Management pro = new Project_Management();
pro.setProjectName("简单加法计算");
pro.setProjectPermissions(1);
pro.setExperimentalGoal("本项目将会帮助学生了解简单的加法计算");
pro.setCaseDescription("声明两个变量,让其相加,得到其和");
pro.setIsstartexperimental(0);
pro.setExperimentSuggests("使用加号,将声明的变量相加");
pro.setIsstartexperimentSuggests(0);
pro.setState(1);
pro.setSystemId(6);
pro.setUserId(4);
pro.setFounder(0);
List<Judgment_Points> points = new ArrayList<>();
Judgment_Points judgmentPoints = new Judgment_Points();
judgmentPoints.setJudgmentPointsId(153);
judgmentPoints.setExperimentalRequirements("声明两个变量,让其相加,得到其和.....");
judgmentPoints.setScore(100);
points.add(judgmentPoints);
List<Integer> roles = new ArrayList<>();
roles.add(120);
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;

Loading…
Cancel
Save