From b435e6390ccb02ce3ab39a51de9540afa5805636 Mon Sep 17 00:00:00 2001 From: river <1376754470@qq.com> Date: Wed, 26 Aug 2020 17:21:46 +0800 Subject: [PATCH] all test accomplish --- .../java/com/yipin/liuwanr/entity/Staff.java | 23 ++ .../com/yipin/liuwanr/entity/Student.java | 33 +++ .../com/yipin/liuwanr/mapper/OrderMapper.java | 2 + .../liuwanr/service/SchoolServiceTest.java | 101 +++++++ .../liuwanr/service/StaffServiceTest.java | 194 +++++++++++++ ...tuProfessionalArchitectureServiceTest.java | 258 ++++++++++++++++++ 6 files changed, 611 insertions(+) create mode 100644 src/test/java/com/yipin/liuwanr/service/SchoolServiceTest.java create mode 100644 src/test/java/com/yipin/liuwanr/service/StaffServiceTest.java create mode 100644 src/test/java/com/yipin/liuwanr/service/StuProfessionalArchitectureServiceTest.java diff --git a/src/main/java/com/yipin/liuwanr/entity/Staff.java b/src/main/java/com/yipin/liuwanr/entity/Staff.java index 3265d61..875ae50 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Staff.java +++ b/src/main/java/com/yipin/liuwanr/entity/Staff.java @@ -139,4 +139,27 @@ public class Staff { public void setStaffProfessionalArchitectureId(Integer staffProfessionalArchitectureId) { this.staffProfessionalArchitectureId = staffProfessionalArchitectureId; } + + @Override + public String toString() { + return "Staff{" + + "staffId=" + staffId + + ", staffName='" + staffName + '\'' + + ", staffWorkNumber='" + staffWorkNumber + '\'' + + ", phone='" + phone + '\'' + + ", email='" + email + '\'' + + ", logNumber=" + logNumber + + ", lastTimeOfLanding='" + lastTimeOfLanding + '\'' + + ", staffGradeId=" + staffGradeId + + ", staffProfessionalArchitectureId=" + staffProfessionalArchitectureId + + ", staffProfessionalArchitectureName='" + staffProfessionalArchitectureName + '\'' + + ", nameAndNumber='" + nameAndNumber + '\'' + + ", roleId=" + roleId + + ", staffGradeName='" + staffGradeName + '\'' + + ", uniqueIdentificationAccount='" + uniqueIdentificationAccount + '\'' + + ", staffGradeIds='" + staffGradeIds + '\'' + + ", staffProfessionalArchitectureIds='" + staffProfessionalArchitectureIds + '\'' + + ", schoolId=" + schoolId + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/entity/Student.java b/src/main/java/com/yipin/liuwanr/entity/Student.java index 849fa02..8e83f71 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Student.java +++ b/src/main/java/com/yipin/liuwanr/entity/Student.java @@ -219,4 +219,37 @@ public class Student { public void setIsAssess(Integer isAssess) { this.isAssess = isAssess; } + + @Override + public String toString() { + return "Student{" + + "studentId=" + studentId + + ", studentName='" + studentName + '\'' + + ", studentNumber='" + studentNumber + '\'' + + ", phone='" + phone + '\'' + + ", email='" + email + '\'' + + ", roleId=" + roleId + + ", schoolId=" + schoolId + + ", professionalId=" + professionalId + + ", gradeId=" + gradeId + + ", classId=" + classId + + ", experimentalClassName='" + experimentalClassName + '\'' + + ", experimentalClassId='" + experimentalClassId + '\'' + + ", isAssess=" + isAssess + + ", uniqueIdentificationAccount='" + uniqueIdentificationAccount + '\'' + + ", searchContent='" + searchContent + '\'' + + ", professionalIds='" + professionalIds + '\'' + + ", gradeIds='" + gradeIds + '\'' + + ", classIds='" + classIds + '\'' + + ", professionalName='" + professionalName + '\'' + + ", gradeName='" + gradeName + '\'' + + ", studentNameNumber='" + studentNameNumber + '\'' + + ", intExperimentalClassId=" + intExperimentalClassId + + ", className='" + className + '\'' + + ", loginNumber=" + loginNumber + + ", lastLoginTime='" + lastLoginTime + '\'' + + ", attendance='" + attendance + '\'' + + ", stuProfessionalArchitectureName='" + stuProfessionalArchitectureName + '\'' + + '}'; + } } diff --git a/src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java b/src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java index 28eeb4d..6df3a52 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/OrderMapper.java @@ -11,6 +11,8 @@ import com.yipin.liuwanr.entity.Customer; import com.yipin.liuwanr.entity.Order; import com.yipin.liuwanr.vo.OrderVo; +import java.util.List; + public interface OrderMapper { //添加订单 diff --git a/src/test/java/com/yipin/liuwanr/service/SchoolServiceTest.java b/src/test/java/com/yipin/liuwanr/service/SchoolServiceTest.java new file mode 100644 index 0000000..33baf61 --- /dev/null +++ b/src/test/java/com/yipin/liuwanr/service/SchoolServiceTest.java @@ -0,0 +1,101 @@ +package com.yipin.liuwanr.service; + +import com.yipin.liuwanr.entity.School; +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.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; + +/** + * @auther River + * @date 2020/8/24 9:14 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class SchoolServiceTest { + + @Autowired + private SchoolService schoolService; + + /** + * 添加学校 + */ + @Test + @Transactional + public void addSchoolTest(){ + School school = new School(); + school.setSchoolName("北京大学"); + school.setProvinceId(1); + school.setCityId(1); + school.setLevel(1); + HashMap addSchool = schoolService.addSchool(school); + for (String s : addSchool.keySet()) { + System.out.println("key:" + s + "," + "value:" + addSchool.get(s)); + } + } + + /** + * 查询学校 + */ + @Test + @Transactional + public void querySchoolTest(){ + School school = new School(); + school.setProvinceId(1); + school.setCityId(1); + school.setLevel(1); + HashMap querySchool = schoolService.querySchool(school); + for (String s : querySchool.keySet()) { + System.out.println("key:" + s + "," + "value:" + querySchool.get(s)); + } + } + + /** + * 查询学校详情 + */ + @Test + @Transactional + public void querySchoolDetailsTest(){ + Integer schoolId = 1; + HashMap schoolDetails = schoolService.querySchoolDetails(schoolId); + for (String s : schoolDetails.keySet()) { + System.out.println("key:" + s + "," + "value:" + schoolDetails.get(s)); + } + } + + /** + * 删除学校 + */ + @Test + @Transactional + public void deleteSchoolTest(){ + School school = new School(); + school.setSchoolId(1); + HashMap deleteSchool = schoolService.deleteSchool(school); + for (String s : deleteSchool.keySet()) { + System.out.println("key:" + s + "," + "value:" + deleteSchool.get(s)); + } + } + + /** + * 更新学校 + */ + @Test + @Transactional + public void updateSchoolTest(){ + School school = new School(); + school.setSchoolId(1); + school.setProvinceId(1); + school.setCityId(1); + school.setLevel(1); + school.setSchoolName("北京大学"); + HashMap updateSchool = schoolService.updateSchool(school); + for (String s : updateSchool.keySet()) { + System.out.println("key:" + s + "," + "value:" + updateSchool.get(s)); + } + } +} diff --git a/src/test/java/com/yipin/liuwanr/service/StaffServiceTest.java b/src/test/java/com/yipin/liuwanr/service/StaffServiceTest.java new file mode 100644 index 0000000..34cf31c --- /dev/null +++ b/src/test/java/com/yipin/liuwanr/service/StaffServiceTest.java @@ -0,0 +1,194 @@ +package com.yipin.liuwanr.service; + +import com.yipin.liuwanr.entity.Staff; +import com.yipin.liuwanr.entity.UserM; +import com.yipin.liuwanr.vo.UserVO; +import org.apache.commons.io.IOUtils; +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.lang.Nullable; +import org.springframework.mock.web.MockMultipartFile; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.io.*; +import java.util.HashMap; + +/** + * @auther River + * @date 2020/8/24 9:45 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class StaffServiceTest { + + @Autowired + private StaffService staffService; + + /** + * 读取员工表 + */ + @Test + @Transactional + public void readStaffTest(){ + MultipartFile file = new MultipartFile() { + @Override + public String getName() { + return null; + } + @Nullable + @Override + public String getOriginalFilename() { + return null; + } + @Nullable + @Override + public String getContentType() { + return null; + } + @Override + public boolean isEmpty() { + return false; + } + @Override + public long getSize() { + return 0; + } + @Override + public byte[] getBytes() throws IOException { + return new byte[0]; + } + @Override + public InputStream getInputStream() throws IOException { + return null; + } + @Override + public void transferTo(File dest) throws IOException, IllegalStateException { + } + }; + Integer schoolId = 1; + File file1 = new File("C:\\Users\\Hello\\Desktop\\aaaa.xlsx"); + try { + //将file类型文件转换为MultipartFile类型文件 + FileInputStream input = new FileInputStream(file1); + file = new MockMultipartFile("file", file1.getName(), "text/plain", IOUtils.toByteArray(input)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + HashMap readStaff = staffService.readStaff(file, schoolId); + for (String s : readStaff.keySet()) { + System.out.println("key:" + s + "," + "value:" + readStaff.get(s)); + } + } + + /** + * 添加员工 + */ + @Test + @Transactional + public void addStaffTest(){ + Staff staff = new Staff(); + staff.setSchoolId(2043); + staff.setEmail("4867687@qq.com"); + staff.setPhone("18873465488"); + staff.setRoleId(3); + staff.setStaffGradeId(2050); + staff.setStaffName("zha"); + staff.setStaffProfessionalArchitectureId(2057); + staff.setStaffWorkNumber("1222"); + staff.setUniqueIdentificationAccount("204312221598238094000"); + HashMap addStaff = staffService.addStaff(staff); + for (String s : addStaff.keySet()) { + System.out.println("key:" + s + "," + "value:" + addStaff.get(s)); + } + } + + /** + * 查询员工 + */ + @Test + @Transactional + public void queryStaffTest(){ + Staff staff = new Staff(); + Integer pageNo = 1; + Integer pageSize = 10; + staff.setSchoolId(2043); + HashMap queryStaff = staffService.queryStaff(staff, pageNo, pageSize); + for (String s : queryStaff.keySet()) { + System.out.println("key:" + s + "," + "value:" + queryStaff.get(s)); + } + } + + /** + * 删除员工 + */ + @Test + @Transactional + public void deleteStaffTest(){ + Integer staffId = 118; + String phone = "13137366427"; + HashMap deleteStaff = staffService.deleteStaff(staffId, phone); + for (String s : deleteStaff.keySet()) { + System.out.println("key:" + s + "," + "value:" + deleteStaff.get(s)); + } + } + + /** + * 查询员工详情 + */ + @Test + @Transactional + public void queryStaffDetailsTest(){ + Integer staffId = 118; + HashMap staffDetails = staffService.queryStaffDetails(staffId); + for (String s : staffDetails.keySet()) { + System.out.println("key:" + s + "," + "value:" + staffDetails.get(s)); + } + } + + /** + * 更新员工 + */ + @Test + @Transactional + public void updateStaffTest(){ + UserVO userVO = new UserVO(); + Staff staff = new Staff(); + UserM user = new UserM(); + staff.setEmail("123@qq.com"); + staff.setPhone("13137366427"); + staff.setRoleId(4); + staff.setSchoolId(2043); + staff.setStaffGradeId(2050); + staff.setStaffId(118); + staff.setStaffName("世杰-教师"); + staff.setStaffProfessionalArchitectureId(2057); + staff.setStaffWorkNumber("123"); + staff.setUniqueIdentificationAccount("20431231596424406000"); + userVO.setStaff(staff); + user.setAccountRole(3); + user.setCityId(1); + user.setDisciplineId(1); + user.setEmail("123@qq.com"); + user.setName("世杰-教师"); + user.setPhone("13137366427"); + user.setProfessionalClassId(1); + user.setProvinceId(4); + user.setProfessionalId(4); + user.setSchoolId(2043); + user.setUniqueIdentificationAccount("20431231596424406000"); + user.setUserAccount("123"); + user.setUserId(461); + user.setWorkNumber("123"); + userVO.setUser(user); + HashMap updateStaff = staffService.updateStaff(userVO); + for (String s : updateStaff.keySet()) { + System.out.println("key:" + s + "," + "value:" + updateStaff.get(s)); + } + } +} diff --git a/src/test/java/com/yipin/liuwanr/service/StuProfessionalArchitectureServiceTest.java b/src/test/java/com/yipin/liuwanr/service/StuProfessionalArchitectureServiceTest.java new file mode 100644 index 0000000..05823eb --- /dev/null +++ b/src/test/java/com/yipin/liuwanr/service/StuProfessionalArchitectureServiceTest.java @@ -0,0 +1,258 @@ +package com.yipin.liuwanr.service; + +import com.yipin.liuwanr.entity.StuProfessionalArchitecture; +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.SpringRunner; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; + +/** + * @auther River + * @date 2020/8/25 9:46 + */ +@SpringBootTest +@RunWith(SpringRunner.class) +public class StuProfessionalArchitectureServiceTest { + + @Autowired + private StuProfessionalArchitectureService stuProfessionalArchitectureService; + + /** + * 添加学生专业组织 + */ + @Test + @Transactional + public void addStuProfessionalArchitectureTest(){ + StuProfessionalArchitecture stuPA = new StuProfessionalArchitecture(); + stuPA.setSchoolId(2043); + stuPA.setStuProfessionalArchitectureName("计算机学院"); + HashMap stuProfessionalArchitecture = stuProfessionalArchitectureService.addStuProfessionalArchitecture(stuPA); + for (String s : stuProfessionalArchitecture.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuProfessionalArchitecture.get(s)); + } + } + + /** + * 查询学生专业架构 + */ + @Test + @Transactional + public void queryStuProfessionalArchitectureTest(){ + Integer schoolId = 1; + HashMap professionalArchitecture = stuProfessionalArchitectureService.queryStuProfessionalArchitecture(schoolId); + for (String s : professionalArchitecture.keySet()) { + System.out.println("key:" + s + "," + "value:" + professionalArchitecture.get(s)); + } + } + + /** + * 查询学生专业架构详情 + */ + @Test + @Transactional + public void queryStuPADTest(){ + Integer stuProfessionalArchitectureId = 34; + HashMap stuPAD = stuProfessionalArchitectureService.queryStuPAD(stuProfessionalArchitectureId); + for (String s : stuPAD.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuPAD.get(s)); + } + } + + /** + * 删除学生专业 + */ + @Test + @Transactional + public void deleteStuProfessionalArchitectureTest(){ + Integer stuProfessionalArchitectureId = 34; + HashMap professionalArchitecture = stuProfessionalArchitectureService.deleteStuProfessionalArchitecture(stuProfessionalArchitectureId); + for (String s : professionalArchitecture.keySet()) { + System.out.println("key:" + s + "," + "value:" + professionalArchitecture.get(s)); + } + } + + /** + * 删除学生转年级 + */ + @Test + @Transactional + public void deleteStuGradeTest(){ + Integer gradeId = 1; + HashMap stuGrade = stuProfessionalArchitectureService.deleteStuGrade(gradeId); + for (String s : stuGrade.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuGrade.get(s)); + } + } + + /** + * 删除学生转班级 + */ + @Test + @Transactional + public void deleteStuClassTest(){ + Integer classId = 1; + HashMap stuClass = stuProfessionalArchitectureService.deleteStuClass(classId); + for (String s : stuClass.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuClass.get(s)); + } + } + + /** + * 更新学生专业架构 + */ + @Test + @Transactional + public void updateStuProfessionalArchitectureTest(){ + StuProfessionalArchitecture stuPA = new StuProfessionalArchitecture(); + stuPA.setSchoolId(2043); + stuPA.setStuProfessionalArchitectureId(34); + stuPA.setStuProfessionalArchitectureName("英语"); + HashMap professionalArchitecture = stuProfessionalArchitectureService.updateStuProfessionalArchitecture(stuPA); + for (String s : professionalArchitecture.keySet()) { + System.out.println("key:" + s + "," + "value:" + professionalArchitecture.get(s)); + } + } + + /** + * 查询全部学生专业架构 + */ + @Test + @Transactional + public void queryStudentProfessionalArchitectureTest(){ + Integer schoolId = 1; + HashMap professionalArchitecture = stuProfessionalArchitectureService.queryStuProfessionalArchitecture(schoolId); + for (String s : professionalArchitecture.keySet()) { + System.out.println("key:" + s + "," + "value:" + professionalArchitecture.get(s)); + } + } + + /** + * 查询学生年级 + */ + @Test + @Transactional + public void queryStuGradeTest(){ + Integer stuProfessionalArchitectureId = 34; + HashMap queryStuGrade = stuProfessionalArchitectureService.queryStuGrade(stuProfessionalArchitectureId); + for (String s : queryStuGrade.keySet()) { + System.out.println("key:" + s + "," + "value:" + queryStuGrade.get(s)); + } + } + + /** + * 查询学生年级详情 + */ + @Test + @Transactional + public void queryStuGradeDTest(){ + Integer gradeId = 1; + HashMap stuGradeD = stuProfessionalArchitectureService.queryStuGradeD(gradeId); + for (String s : stuGradeD.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuGradeD.get(s)); + } + } + + /** + * 查询学生班级 + */ + @Test + @Transactional + public void queryStuClassTest(){ + Integer gradeId = 1; + HashMap stuClass = stuProfessionalArchitectureService.queryStuClass(gradeId); + for (String s : stuClass.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuClass.get(s)); + } + } + + /** + * 查询学生班级详情 + */ + @Test + @Transactional + public void queryStuClassDTest(){ + Integer classId = 1; + HashMap stuClassD = stuProfessionalArchitectureService.queryStuClassD(classId); + for (String s : stuClassD.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuClassD.get(s)); + } + } + + /** + * 添加班级 + */ + @Test + @Transactional + public void addStuClassTest(){ + StuProfessionalArchitecture stuPA = new StuProfessionalArchitecture(); + stuPA.setClassName("12"); + stuPA.setGradeId(20); + HashMap addStuClass = stuProfessionalArchitectureService.addStuClass(stuPA); + for (String s : addStuClass.keySet()) { + System.out.println("key:" + s + "," + "value:" + addStuClass.get(s)); + } + } + + /** + * 修改班级 + */ + @Test + @Transactional + public void updateStuClassTest(){ + StuProfessionalArchitecture stuPA = new StuProfessionalArchitecture(); + stuPA.setClassName("13"); + stuPA.setClassId(76); + HashMap stuClass = stuProfessionalArchitectureService.updateStuClass(stuPA); + for (String s : stuClass.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuClass.get(s)); + } + } + + /** + * 添加年级 + */ + @Test + @Transactional + public void addStuGradeTest(){ + StuProfessionalArchitecture stuPA = new StuProfessionalArchitecture(); + stuPA.setGradeName("2020"); + stuPA.setStuProfessionalArchitectureId(37); + HashMap stuGrade = stuProfessionalArchitectureService.addStuGrade(stuPA); + for (String s : stuGrade.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuGrade.get(s)); + } + } + + /** + * 修改年级 + */ + @Test + @Transactional + public void updateStuGradeTest(){ + StuProfessionalArchitecture stuPA = new StuProfessionalArchitecture(); + stuPA.setGradeId(50); + stuPA.setGradeName("2018"); + stuPA.setStuProfessionalArchitectureId(37); + HashMap stuGrade = stuProfessionalArchitectureService.updateStuGrade(stuPA); + for (String s : stuGrade.keySet()) { + System.out.println("key:" + s + "," + "value:" + stuGrade.get(s)); + } + } + + /** + * 查询学生 + */ + @Test + @Transactional + public void queryStudentTest(){ + Integer classId = 1; + HashMap student = stuProfessionalArchitectureService.queryStudent(classId); + for (String s : student.keySet()) { + System.out.println("key:" + s + "," + "value:" + student.get(s)); + } + } +}