如何为以下方法创建测试方法?

时间:2019-03-07 16:17:10

标签: java testing

public static SearchResult getDatesFromRule(Rule rule, SearchResult searchResult) {
    if (Objects.nonNull(rule.getWhen()) && !rule.getWhen().getBundles().isEmpty()) {
        for (CriteriaBundle criteriaBundle : rule.getWhen().getBundles()) {
            if (criteriaBundle.getDescription().equals(WAYBILL_DATE_FACT_PROP)) {
                criteriaBundle.getCriterias().forEach(criteria -> {
                    if (criteria.getOperator().equals(Operator.GE)) {
                        searchResult.setEffectiveDate(RulesUtil.formatDate(criteria.getValue(), RCConstants.DEFAULT_DATE_FORMAT,
                                RCConstants.UI_DATE_FORMAT));
                    } else if (criteria.getOperator().equals(Operator.LE)) {
                        searchResult.setExpirationDate(RulesUtil.formatDate(criteria.getValue(),
                                RCConstants.DEFAULT_DATE_FORMAT, RCConstants.UI_DATE_FORMAT));
                    }
                });
                break;
            }
        }
    }
    return searchResult;
}

0 个答案:

没有答案