当前位置: 首页>>代码示例>>Java>>正文


Java Result.getRule方法代码示例

本文整理汇总了Java中com.buschmais.jqassistant.core.analysis.api.Result.getRule方法的典型用法代码示例。如果您正苦于以下问题:Java Result.getRule方法的具体用法?Java Result.getRule怎么用?Java Result.getRule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.buschmais.jqassistant.core.analysis.api.Result的用法示例。

在下文中一共展示了Result.getRule方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: verifyRuleResults

import com.buschmais.jqassistant.core.analysis.api.Result; //导入方法依赖的package包/类
/**
 * Verifies the given results and logs messages.
 *
 * @param results
 *            The collection of results to verify.
 * @param warnOnSeverity
 *            The severity threshold to warn.
 * @param failOnSeverity
 *            The severity threshold to fail.
 * @param type
 *            The type of the rules (as string).
 * @param header
 *            The header to use.
 * @param logResult
 *            if `true` log the result of the executable rule.
 * @return The number of detected violations.
 */
private int verifyRuleResults(Collection<? extends Result<? extends ExecutableRule>> results, Severity warnOnSeverity, Severity failOnSeverity, String type,
        String header, boolean logResult) {
    int violations = 0;
    for (Result<?> result : results) {
        if (Result.Status.FAILURE.equals(result.getStatus())) {
            ExecutableRule rule = result.getRule();
            String severityInfo = rule.getSeverity().getInfo(result.getSeverity());
            List<String> resultRows = getResultRows(result, logResult);
            // violation severity level check
            boolean warn = warnOnSeverity != null && result.getSeverity().getLevel() <= warnOnSeverity.getLevel();
            boolean fail = failOnSeverity != null && result.getSeverity().getLevel() <= failOnSeverity.getLevel();
            LoggingStrategy loggingStrategy;
            if (fail) {
                violations++;
                loggingStrategy = errorLogger;
            } else if (warn) {
                loggingStrategy = warnLogger;
            } else {
                loggingStrategy = debugLogger;
            }
            log(loggingStrategy, rule, resultRows, severityInfo, type, header);
        }
    }
    return violations;
}
 
开发者ID:buschmais,项目名称:jqa-core-framework,代码行数:43,代码来源:ReportHelper.java


示例2: endGroup

import com.buschmais.jqassistant.core.analysis.api.Result; //导入方法依赖的package包/类
@Override
public void endGroup() throws ReportException {
    // TestSuite
    Testsuite testsuite = new Testsuite();
    int tests = 0;
    int failures = 0;
    int errors = 0;
    for (Map.Entry<Result<? extends ExecutableRule>, Long> entry : results.entrySet()) {
        // TestCase
        Result<? extends Rule> result = entry.getKey();
        long time = entry.getValue().longValue();
        Testcase testcase = new Testcase();
        Rule rule = result.getRule();
        testcase.setName(rule.getId());
        testcase.setClassname(group.getId());
        testcase.setTime(Long.toString(time));
        List<Map<String, Object>> rows = result.getRows();
        if (rule instanceof Concept && rows.isEmpty()) {
            Failure failure = new Failure();
            failure.setMessage(rule.getDescription());
            failure.setContent("The concept returned an empty result.");
            testcase.getFailure().add(failure);
            failures++;
        } else if (rule instanceof Constraint && !rows.isEmpty()) {
            Error error = new Error();
            error.setMessage(rule.getDescription());
            StringBuilder sb = new StringBuilder();
            for (Map<String, Object> row : rows) {
                for (Map.Entry<String, Object> rowEntry : row.entrySet()) {
                    sb.append(rowEntry.getKey());
                    sb.append("=");
                    sb.append(rowEntry.getValue());
                }
            }
            error.setContent(sb.toString());
            testcase.getError().add(error);
            errors++;
        }
        tests++;
        testsuite.getTestcase().add(testcase);
    }
    testsuite.setTests(Integer.toString(tests));
    testsuite.setFailures(Integer.toString(failures));
    testsuite.setErrors(Integer.toString(errors));
    testsuite.setName(group.getId());
    long groupTime = System.currentTimeMillis() - groupBeginTimestamp;
    testsuite.setTime(Long.toString(groupTime));
    // TestSuite
    File file = new File(directory, "TEST-" + group.getId() + ".xml");
    try {
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        marshaller.marshal(testsuite, file);
    } catch (JAXBException e) {
        throw new ReportException("Cannot write JUnit report.", e);
    }
    this.group = null;
    this.results.clear();
}
 
开发者ID:buschmais,项目名称:jqa-maven-plugin,代码行数:61,代码来源:JUnitReportWriter.java



注:本文中的com.buschmais.jqassistant.core.analysis.api.Result.getRule方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。