Search in sources :

Example 1 with SoyErrorKind

use of com.google.template.soy.error.SoyErrorKind in project closure-templates by google.

the class SoyConformanceTest method getViolations.

private ImmutableList<SoyError> getViolations(String textProto, SoyFileSetParserBuilder builder) {
    ValidatedConformanceConfig config = parseConfigProto(textProto);
    ErrorReporter errorReporter = ErrorReporter.createForTest();
    builder.setConformanceConfig(config).errorReporter(errorReporter).parse();
    ImmutableList<SoyError> errors = errorReporter.getErrors();
    Set<SoyErrorKind> expectedErrorKinds = new HashSet<>();
    for (RuleWithWhitelists rule : config.getRules()) {
        expectedErrorKinds.add(rule.getRule().error);
    }
    for (SoyError actualError : errors) {
        if (!expectedErrorKinds.contains(actualError.errorKind())) {
            throw new AssertionError("Found non-conformance error!: " + actualError + "\nexpected kind to be one of: " + expectedErrorKinds + " actual is: " + actualError.errorKind());
        }
    }
    return errors;
}
Also used : ErrorReporter(com.google.template.soy.error.ErrorReporter) SoyErrorKind(com.google.template.soy.error.SoyErrorKind) SoyError(com.google.template.soy.error.SoyError) HashSet(java.util.HashSet)

Aggregations

ErrorReporter (com.google.template.soy.error.ErrorReporter)1 SoyError (com.google.template.soy.error.SoyError)1 SoyErrorKind (com.google.template.soy.error.SoyErrorKind)1 HashSet (java.util.HashSet)1