public class ReadInterfaceFromExcel extends ReadInterfaceFromAbstract implements ActionEnvironment, AssertResponse, ExtractResponse, BeforeOperation
文件名:ReadInterfaceFromExcel.java
用途:用于读取excel文件中的接口信息,文件支持“.xls”和“.xlsx”格式,但在读取完后,需要调用close()方法关闭文件的读取
编码时间:2022年9月8日 上午10:48:30
修改时间:2022年9月8日 上午10:48:30
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ReadInterfaceFromExcel.ExcelField
文件名:ReadInterfaceFromExcel.java
|
DEFAULT_HOST, DEFAULT_ORD, DEFAULT_SEARCH, interfaceCacheMapARRAY_END_SYMBOL, ARRAY_START_SYMBOL, JSON_ASSERT_ASSERT_REGEX, JSON_ASSERT_LB, JSON_ASSERT_ORD, JSON_ASSERT_PARAM_NAME, JSON_ASSERT_RB, JSON_ASSERT_SEARCH, JSON_ASSERT_XPATH, SEPARATE_SPLIT_REGEX, SEPARATE_SYMBOL, SEPARATE_TRANSFERRED_MEANING_REGEXARRAY_END_SYMBOL, ARRAY_START_SYMBOL, JSON_EXTRACT_LB, JSON_EXTRACT_ORD, JSON_EXTRACT_PARAM_NAME, JSON_EXTRACT_RB, JSON_EXTRACT_SAVE_NAME, JSON_EXTRACT_SEARCH, JSON_EXTRACT_XPATH, SEPARATE_SPLIT_REGEX, SEPARATE_SYMBOL, SEPARATE_TRANSFERRED_MEANING_REGEX| Constructor and Description |
|---|
ReadInterfaceFromExcel(File excelFile)
构造对象,读取模板文件,并初始化各个参数
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addInterNameRowIndex(HashMap<String,Entry<Integer,Integer>> map,
int fieldIndex,
org.apache.poi.ss.usermodel.Sheet dataSheet)
该方法用于将sheet所有行中指定下标单元格中不为空的内容进行存储,并记录其内容及行号至指定的map集合中
|
void |
close()
该方法用于关闭对接口模板的读取
|
HashMap<String,String> |
getActionEnvironment()
该方法用于返回所有的执行环境集合
|
Set<String> |
getAssertContent(String interName)
该方法用于返回指定接口的断言内容json串
|
List<BeforeInterfaceOperation> |
getBeforeOperation(String interName)
该方法用于返回接口的所有前置操作方法
|
Set<String> |
getExtractContent(String interName)
该方法用于指定接口的报文提词内容json串集合
|
InterfaceInfo |
getInterface(String interName)
该方法用于根据接口名称,返回接口的信息类对象
|
InterfaceInfo |
getInterface(String interName,
String environmentName)
该方法用于根据接口名称及所在环境,返回接口的信息类对象
|
List<String> |
getParentInterfaceName(String interName)
该方法用于返回接口的所有父层接口名称(不包括当前接口名称)
|
protected List<Optional<org.apache.poi.ss.usermodel.Cell>> |
getRowAllCell(org.apache.poi.ss.usermodel.Row row,
int columnIndex)
该方法用于获取当前行中所有单元格对象的集合
|
protected List<org.apache.poi.ss.usermodel.Row> |
getSheetAllRow(org.apache.poi.ss.usermodel.Sheet sheet)
该方法用于获取当前sheet中所有行对象的集合
|
protected void |
readBodySheetContent(String interName,
InterfaceInfo inter) |
protected void |
readInterSheetContent(String interName,
InterfaceInfo inter)
该方法用于读取“接口”sheet页中接口相关的基本信息
|
protected void |
readMultirowSheetContent(String interName,
String sheetName,
InterfaceInfo inter,
HashMap<String,Entry<Integer,Integer>> map)
该方法用于读取一个接口占多行的sheet页内容
|
void |
setActionEnvironment(String environmentName)
该方法用于设置当前执行接口的环境
|
clearInterfaceInfoCacheprotected final String SPECIAL_CONTENT_SYMBOL
protected org.apache.poi.ss.usermodel.Workbook excel
protected org.apache.poi.ss.usermodel.DataFormatter format
public ReadInterfaceFromExcel(File excelFile)
excelFile - 接口模板文件public void setActionEnvironment(String environmentName)
ActionEnvironmentsetActionEnvironment in interface ActionEnvironmentenvironmentName - 环境名称public HashMap<String,String> getActionEnvironment()
ActionEnvironmentgetActionEnvironment in interface ActionEnvironmentpublic List<BeforeInterfaceOperation> getBeforeOperation(String interName)
BeforeOperationgetBeforeOperation in interface BeforeOperationpublic List<String> getParentInterfaceName(String interName)
BeforeOperationgetParentInterfaceName in interface BeforeOperationinterName - 接口名称public Set<String> getExtractContent(String interName)
ExtractResponsejson串的键值可通过静态属性获取,当没有断言内容时,则json中的键都为空值
getExtractContent in interface ExtractResponseinterName - 接口名称public Set<String> getAssertContent(String interName)
AssertResponsejson串的键值可通过静态属性获取,当没有断言内容时,则json中的键都为空值
getAssertContent in interface AssertResponseinterName - 接口名称public InterfaceInfo getInterface(String interName)
ReadInterfaceFromAbstractgetInterface in class ReadInterfaceFromAbstractinterName - 接口名称public InterfaceInfo getInterface(String interName, String environmentName)
ActionEnvironmentgetInterface in interface ActionEnvironmentinterName - 接口名称environmentName - 环境名称protected void readBodySheetContent(String interName, InterfaceInfo inter)
protected void readMultirowSheetContent(String interName, String sheetName, InterfaceInfo inter, HashMap<String,Entry<Integer,Integer>> map)
interName - 接口名称sheetName - sheet页名称inter - 接口信息类对象protected void readInterSheetContent(String interName, InterfaceInfo inter)
interName - 接口名称inter - 接口信息类对象public void close()
protected List<org.apache.poi.ss.usermodel.Row> getSheetAllRow(org.apache.poi.ss.usermodel.Sheet sheet)
sheet - sheet对象protected List<Optional<org.apache.poi.ss.usermodel.Cell>> getRowAllCell(org.apache.poi.ss.usermodel.Row row, int columnIndex)
row - 行对象columnIndex - 当前行下的列数protected void addInterNameRowIndex(HashMap<String,Entry<Integer,Integer>> map, int fieldIndex, org.apache.poi.ss.usermodel.Sheet dataSheet)
map - 存储内容及下标的集合fieldIndex - 指定字段所在的列的下标dataSheet - 数据sheet页Copyright © 2024. All rights reserved.