在我基于 Java+Spring 后端的项目中,我已将权限属性列表提取到.properties 文件中。如何验证测试中的属性文件中是否存在请求的参数?
有没有办法将此属性文件集成到我的集成测试中?
属性文件:
#Viewable Report Filter, Ordered list of states to be viewed in each step of the web-gui
TMSViewableReportFilter.allStates.verify=ONHOLD_HR,VERIFY,PREPARE,CONFIRM,CONFIRM_HR,CONFIRM_MGR,CONFIRM_RM,AGRESSO_IN_PROGRESS,CLOSED
TMSViewableReportFilter.allStates.manager=PREPARE,ONHOLD_FINANCE,ONHOLD_HR,AGRESSO_ERROR,CONFIRM,CONFIRM_HR,CONFIRM_MGR,CONFIRM_RM,AGRESSO_IN_PROGRESS,CLOSED
TMSViewableReportFilter.allStates.prepare=CONFIRM,CONFIRM_HR,CONFIRM_MGR,CONFIRM_RM,ONHOLD_FINANCE,CLOSED
TMSViewableReportFilter.allStates.confirm=CONFIRM_MGR,CONFIRM_HR,CONFIRM_RM,ONHOLD_HR,CLOSED
#Handleable Report Filter, Ordered list of states to be viewed in each step of the web-gui
TMSHandleableReportFilter.allStates.verify=APPROVE,ONHOLD_EMPLOYEE,ONHOLD_FINANCE,AGRESSO_ERROR
TMSHandleableReportFilter.allStates.manager=VERIFY
TMSHandleableReportFilter.allStates.prepare=PREPARE,ONHOLD_HR
TMSHandleableReportFilter.allStates.confirm.hr=CONFIRM_HR
TMSHandleableReportFilter.allStates.confirm.mgr=CONFIRM_MGR,CONFIRM_HR
TMSHandleableReportFilter.allStates.confirm.rm=CONFIRM_RM
这是我访问这些值的方式:
@Autowired
public TMSHandleableReportService(
@Value("${TMSHandleableReportFilter.allStates.verify}") String[] verifyStringStates,
@Value("${TMSHandleableReportFilter.allStates.manager}") String[] managerStringStates,
@Value("${TMSHandleableReportFilter.allStates.prepare}") String[] prepareStringStates,
@Value("${TMSHandleableReportFilter.allStates.confirm.hr}") String[] confirmHRStringStates,
@Value("${TMSHandleableReportFilter.allStates.confirm.mgr}") String[] confirmMGRStringStates,
@Value("${TMSHandleableReportFilter.allStates.confirm.rm}") String[] confirmRMStringStates) {
handleStates = new HashMap<String, List<TMSState>>();
handleStates.put(
"verify",
loadTMSStateFromStringArray(verifyStringStates,
"TMSViewableReportFilter.allStates.verify"));
handleStates.put(
"manager",
loadTMSStateFromStringArray(managerStringStates,
"TMSViewableReportFilter.allStates.manager"));
handleStates.put(
"prepare",
loadTMSStateFromStringArray(prepareStringStates,
"TMSViewableReportFilter.allStates.prepare"));
handleStates.put(
"confirm.hr",
loadTMSStateFromStringArray(confirmHRStringStates,
"TMSViewableReportFilter.allStates.confirm.hr"));
handleStates.put(
"confirm.mgr",
loadTMSStateFromStringArray(confirmMGRStringStates,
"TMSViewableReportFilter.allStates.confirm.mgr"));
handleStates.put(
"confirm.rm",
loadTMSStateFromStringArray(confirmRMStringStates,
"TMSViewableReportFilter.allStates.confirm.rm"));
验证属性文件中是否存在密钥就足够了。即验证TMSHandleableReportFilter.allStates.verify、TMSHandleableReportFilter.allStates.prepare...等的发生。