Skip to content

Commit

Permalink
Merge pull request #91 from jasonkung22/feat/enum_test_controller
Browse files Browse the repository at this point in the history
perf(enum): Added enumerating multiple scenario test cases
  • Loading branch information
shalousun authored Dec 3, 2024
2 parents 232e257 + d21d247 commit d78add1
Show file tree
Hide file tree
Showing 3 changed files with 408 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package com.power.doc.controller.enums;

import com.power.common.model.CommonResult;
import java.util.List;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* 枚举无参数测试
* @author Jason Kung
* @date 2024/11/27 11:05
*/
@RestController
public class EnumNoArgumentController {

/**
* 测试header参数枚举
* @param noArgumentEnum 无参数枚举
* @return 结果
*/
@GetMapping("/enumNoArgument/testHeaderEnum")
public CommonResult<NoArgumentEnum> testHeaderEnum(@RequestHeader NoArgumentEnum noArgumentEnum) {
return null;
}

/**
* 测试path参数枚举
* @param noArgumentEnum 无参数枚举
* @return 结果
*/
@GetMapping("/enumNoArgument/testPathEnum/{noArgumentEnum}")
public CommonResult<NoArgumentEnum> testPathEnum(@PathVariable NoArgumentEnum noArgumentEnum) {
return null;
}

/**
* 测试query参数枚举
* @param noArgumentEnum 无参数枚举
* @param noArgumentEnumList 无参数枚举列表
* @return 结果
*/
@GetMapping("/enumNoArgument/testQueryEnum")
public CommonResult<NoArgumentEnum> testQueryEnum(@RequestParam NoArgumentEnum noArgumentEnum,
@RequestParam List<NoArgumentEnum> noArgumentEnumList) {
return null;
}

/**
* 测试post参数枚举
* @param noArgumentEnum 无参数枚举
* @param noArgumentEnumList 无参数枚举列表
* @return 结果
*/
@PostMapping("/enumNoArgument/testPostEnum")
public CommonResult<NoArgumentEnum> testPostEnum(@RequestParam NoArgumentEnum noArgumentEnum,
@RequestParam List<NoArgumentEnum> noArgumentEnumList) {
return null;
}

/**
* 测试body参数枚举
* @param innerClass 内部类
* @return 结果
*/
@PostMapping("/enumNoArgument/testBodyEnum")
public CommonResult<InnerClass> testBodyEnum(@RequestBody InnerClass innerClass) {
return null;
}

/**
* 测试query+body参数枚举
* @param noArgumentEnum 无参数枚举参数
* @param noArgumentEnumList 无参数枚举列表
* @param innerClass 内部类
* @return 结果
*/
@PostMapping("/enumNoArgument/testQueryAndBodyEnum")
public CommonResult<InnerClass> testQueryAndBodyEnum(@RequestParam NoArgumentEnum noArgumentEnum,
@RequestParam List<NoArgumentEnum> noArgumentEnumList,
@RequestBody InnerClass innerClass) {
return null;
}

/**
* 内部类
*/
@Data
public static class InnerClass {

/**
* 内部参数
*/
private String innerParam;
/**
* 无参数枚举参数
*/
private NoArgumentEnum noArgumentEnum;
/**
* 无参数枚举列表
*/
private List<NoArgumentEnum> noArgumentEnumList;
}

/**
* 无参数枚举
* @author jason 2024/11/27.
*/
public enum NoArgumentEnum {
/**
* 内部1
*/
INNER1,
/**
* 内部2
*/
INNER2;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package com.power.doc.controller.enums;

import com.fasterxml.jackson.annotation.JsonValue;
import com.power.common.model.CommonResult;
import java.util.List;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* 枚举无数据字典测试
* @author Jason Kung
* @date 2024/11/27 11:05
*/
@RestController
public class EnumNoDataDictionariesController {

/**
* 测试header参数枚举
* @param noDataDictionariesEnum 无数据字典枚举
* @return 结果
*/
@GetMapping("/enumNoDataDictionaries/testHeaderEnum")
public CommonResult<NoDataDictionariesEnum> testHeaderEnum(@RequestHeader NoDataDictionariesEnum noDataDictionariesEnum) {
return null;
}

/**
* 测试path参数枚举
* @param noDataDictionariesEnum 无数据字典枚举
* @return 结果
*/
@GetMapping("/enumNoDataDictionaries/testPathEnum/{noDataDictionariesEnum}")
public CommonResult<NoDataDictionariesEnum> testPathEnum(@PathVariable NoDataDictionariesEnum noDataDictionariesEnum) {
return null;
}

/**
* 测试query参数枚举
* @param noDataDictionariesEnum 无数据字典枚举
* @param noDataDictionariesEnumList 无数据字典枚举列表
* @return 结果
*/
@GetMapping("/enumNoDataDictionaries/testQueryEnum")
public CommonResult<NoDataDictionariesEnum> testQueryEnum(@RequestParam NoDataDictionariesEnum noDataDictionariesEnum,
@RequestParam List<NoDataDictionariesEnum> noDataDictionariesEnumList) {
return null;
}

/**
* 测试post参数枚举
* @param noDataDictionariesEnum 无数据字典枚举
* @param noDataDictionariesEnumList 无数据字典枚举列表
* @return 结果
*/
@PostMapping("/enumNoDataDictionaries/testPostEnum")
public CommonResult<NoDataDictionariesEnum> testPostEnum(@RequestParam NoDataDictionariesEnum noDataDictionariesEnum,
@RequestParam List<NoDataDictionariesEnum> noDataDictionariesEnumList) {
return null;
}

/**
* 测试body参数枚举
* @param innerClass 内部类
* @return 结果
*/
@PostMapping("/enumNoDataDictionaries/testBodyEnum")
public CommonResult<InnerClass> testBodyEnum(@RequestBody InnerClass innerClass) {
return null;
}

/**
* 测试query+body参数枚举
* @param noDataDictionariesEnum 无数据字典枚举参数
* @param noDataDictionariesEnumList 无数据字典枚举列表
* @param innerClass 内部类
* @return 结果
*/
@PostMapping("/enumNoDataDictionaries/testQueryAndBodyEnum")
public CommonResult<InnerClass> testQueryAndBodyEnum(@RequestParam NoDataDictionariesEnum noDataDictionariesEnum,
@RequestParam List<NoDataDictionariesEnum> noDataDictionariesEnumList,
@RequestBody InnerClass innerClass) {
return null;
}

/**
* 内部类
*/
@Data
public static class InnerClass {

/**
* 内部参数
*/
private String innerParam;
/**
* 无数据字典枚举参数
*/
private NoDataDictionariesEnum noDataDictionariesEnum;
/**
* 无数据字典枚举列表
*/
private List<NoDataDictionariesEnum> noDataDictionariesEnumList;
}

/**
* 无数据字典枚举
* @author jason 2024/11/27.
*/
public enum NoDataDictionariesEnum {
/**
* 内部1
*/
INNER1(1, "内部1"),
/**
* 内部2
*/
INNER2(2, "内部2");

private int id;

private String text;

NoDataDictionariesEnum(int id, String text) {
this.id = id;
this.text = text;
}

@JsonValue
public Integer getId() {
return this.id;
}

public String getText() {
return text;
}
}
}
Loading

0 comments on commit d78add1

Please sign in to comment.