Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自动化测试用例 #130

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions .idea/junitgenerator-prj-settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions case-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,24 @@
<artifactId>spring-test</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public Response<?> getDirCardTree(@RequestParam @NotNull(message = "业务线id
@RequestParam @NotNull(message = "渠道为空") Integer channel) {
return Response.success(dirService.getDirTree(productLineId, channel));
}

@GetMapping("/getId")
public String getId(String parentId, Long productLineId, Integer channel, String text) {
return dirService.getId(parentId, productLineId, channel, text);

/**
* 移动文件夹,会文件夹下及其子文件夹全部移动
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,9 @@ public Response<?> login(@RequestBody UserLoginReq req, HttpServletRequest reque
public Response<?> logout(HttpServletRequest request,HttpServletResponse response) {
return Response.success(userService.logout(request, response));
}

@PostMapping("/logoff")
public Response<?> logoff(String Username) {
return Response.success(userService.logoff(Username));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.xiaoju.framework.entity.request.ParamValidate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

/**
Expand All @@ -12,6 +13,7 @@
* @date 2020/9/11
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DirCreateReq implements ParamValidate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.xiaoju.framework.entity.request.ParamValidate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

/**
Expand All @@ -13,6 +14,7 @@
* @date 2020/9/11
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DirDeleteReq implements ParamValidate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.xiaoju.framework.entity.request.ParamValidate;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import static com.xiaoju.framework.constants.BizConstant.UNSORTED_BIZ_ID;
Expand All @@ -14,6 +15,7 @@
* @date 2020/9/11
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DirRenameReq implements ParamValidate {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public interface UserMapper {
int updateByPrimaryKeySelective(User record);

int updateByPrimaryKey(User record);

int deleteByUserName(String username);
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public interface DirService {
*/
DirNodeDto addDir(DirCreateReq request);


// 通过其他三个信息找到delid值
String getId(String parentId, Long productLineId, Integer channel, String text);
/**
* 重命名文件夹
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface UserService {
Integer register(UserRegisterReq req, HttpServletRequest request, HttpServletResponse response);
Integer login(UserLoginReq req, HttpServletRequest request, HttpServletResponse response);
Integer logout(HttpServletRequest request, HttpServletResponse response);
Integer logoff(String Username);

/**
* 获取用户对应权限的路径匹配列表
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,23 @@ public DirNodeDto addDir(DirCreateReq request) {
return root;
}


@Override
public String getId(String parentId, Long productLineId, Integer channel, String text){
DirNodeDto root = getDirTree(productLineId, channel);
DirNodeDto dir = getDir(parentId, root);
if(dir == null)
return null;
Iterator<DirNodeDto> iterator = dir.getChildren().iterator();
while (iterator.hasNext()) {
DirNodeDto next = iterator.next();
if (text.equals(next.getText())) {
return next.getId();
}
}
return null;
}

@Override
@Transactional(rollbackFor = Exception.class)
public DirNodeDto renameDir(DirRenameReq request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,10 @@ public CaseCreateReq buildCaseByXml(FileImportReq request, String fileName, Http

JSONArray jsonArray = new JSONArray();
String fileXml = "content.xml";
// String picXml = "attachments"; // 存放图片的文件夹
// String picName = (fileName + picXml).replace("/", File.separator);
String picXml1 = "attachments";
String picXml2 = "resources";
String picName1 = (fileName + picXml1).replace("/", File.separator);
String picName2 = (fileName + picXml2).replace("/", File.separator);
String contentFullName = (fileName + fileXml).replace("/", File.separator);
File file = new File(contentFullName);
if(!file.exists()) // 判断文件是否存在
Expand All @@ -494,7 +496,7 @@ public CaseCreateReq buildCaseByXml(FileImportReq request, String fileName, Http
String eleName = childElement.getName();
if(eleName.equalsIgnoreCase("sheet"))
{
jsonArray = TreeUtil.importDataByXml(request, childElement, fileName, requests, uploadPath);
jsonArray = TreeUtil.importDataByXml(request, childElement, picName1, picName2, requests, uploadPath);
}
return buildCaseCreateReq(request, jsonArray);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public Integer logout(HttpServletRequest request, HttpServletResponse response)
}

@Override
public Integer logoff(String username){
// 4.注销该用户
return userMapper.deleteByUserName(username);
}

public List<String> getUserAuthorityContent(String username) {
User user = userMapper.selectByUserName(username);
if (Objects.isNull(user)) {
Expand Down
70 changes: 39 additions & 31 deletions case-server/src/main/java/com/xiaoju/framework/util/TreeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ public static void importDataByJson(JSONArray children, JSONObject rootTopic, St


//导入xml内容
public static JSONArray importDataByXml(FileImportReq request, Element e, String fileName, HttpServletRequest requests, String uploadPath) throws IOException {
public static JSONArray importDataByXml(FileImportReq request, Element e, String fileName1, String fileName2, HttpServletRequest requests, String uploadPath) throws IOException {
JSONArray jsonArray = new JSONArray();
List<Element> elementList = e.elements();
if(elementList.size() == 0)
Expand Down Expand Up @@ -527,6 +527,14 @@ public static JSONArray importDataByXml(FileImportReq request, Element e, String
String path = element.attributeValue("src");

// 将文件传入到temp文件下,因此需要将文件进行转换,将file文件类型转化为MultipartFile类型,然后进行上传
File file = null;
File file1 = new File(fileName1 + "/" + path.split("/")[1]);
File file2 = new File(fileName2 + "/" + path.split("/")[1]);
if(file1.exists())
file = file1;
else
file = file2;
LOGGER.info("file为:" + file);
File file = new File(fileName + path.split(":")[1]);
try {
if (StringUtils.isEmpty(element.attributeValue("width")) || StringUtils.isEmpty(element.attributeValue("height"))) {
Expand Down Expand Up @@ -569,7 +577,7 @@ else if (element.getName().equalsIgnoreCase("title")) {
{
if(childEle.getName().equalsIgnoreCase("topics"))
{
JSONArray jsonArray1 = importDataByXml(request, childEle, fileName, requests, uploadPath);
JSONArray jsonArray1 = importDataByXml(request, childEle, fileName1, fileName2, requests, uploadPath);
if(jsonArray1.size()>0){
childrenNext.addAll(jsonArray1);
}
Expand Down Expand Up @@ -597,22 +605,22 @@ else if (element.getName().equalsIgnoreCase("title")) {

}

//根据xml文件获取优先级
private static Integer getPriorityByElement(Element element)
{
Integer priorityId = 0;
Map<String, Integer> priorityIds = getAllPriority();
List<Element> markers = element.elements();
if (markers != null && markers.size() > 0) {
for (Element mark : markers) {
String markId = mark.attributeValue("marker-id");
if (priorityIds.containsKey(markId)) {
priorityId = priorityIds.get(markId);
}
}
}
return priorityId;
}
//根据xml文件获取优先级
private static Integer getPriorityByElement(Element element)
{
Integer priorityId = 0;
Map<String, Integer> priorityIds = getAllPriority();
List<Element> markers = element.elements();
if (markers != null && markers.size() > 0) {
for (Element mark : markers) {
String markId = mark.attributeValue("marker-id");
if (priorityIds.containsKey(markId)) {
priorityId = priorityIds.get(markId);
}
}
}
return priorityId;
}

//根据content.json文件获取优先级
private static Integer getPriorityByJsonArray(JSONArray markers)
Expand Down Expand Up @@ -656,17 +664,17 @@ private static String getPriorityByJson(JSONObject jsonObject)
}

//获取所有优先级
private static Map<String, Integer> getAllPriority(){
Map<String, Integer> priorityIds = new HashMap<>();
priorityIds.put("priority-1", 1);
priorityIds.put("priority-2", 2);
priorityIds.put("priority-3", 3);
priorityIds.put("priority-4", 3);
priorityIds.put("priority-5", 3);
priorityIds.put("priority-6", 3);
priorityIds.put("priority-7", 3);
priorityIds.put("priority-8", 3);
priorityIds.put("priority-9", 3);
return priorityIds;
}
private static Map<String, Integer> getAllPriority(){
Map<String, Integer> priorityIds = new HashMap<>();
priorityIds.put("priority-1", 1);
priorityIds.put("priority-2", 2);
priorityIds.put("priority-3", 3);
priorityIds.put("priority-4", 3);
priorityIds.put("priority-5", 3);
priorityIds.put("priority-6", 3);
priorityIds.put("priority-7", 3);
priorityIds.put("priority-8", 3);
priorityIds.put("priority-9", 3);
return priorityIds;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
delete from user
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByUserName" parameterType="java.lang.String">
delete from user
where username = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.xiaoju.framework.entity.dto.User">
insert into user (id, username, password,
salt, authority_name, is_delete, channel,
Expand Down
Loading