Search in sources :

Example 1 with BoundedDiagCollector

use of com.google.api.tools.framework.model.BoundedDiagCollector in project toolkit by googleapis.

the class DiscoConfigBaselineTestCase method test.

/**
 * Run a test for the given file base name(s). Collects all .proto and .yaml files with the given
 * base name (i.e. baseName.proto or baseName.yaml), constructs model, and calls {@link #run()}.
 * Post that, prints diags and the result of the run to the baseline.
 */
protected void test() throws Exception {
    DiagCollector diagCollector = new BoundedDiagCollector();
    // Run test specific logic.
    Object result = run();
    if (!diagCollector.hasErrors() && result != null) {
        // Output the result depending on its type.
        if (result instanceof Map) {
            @SuppressWarnings("unchecked") Map<String, Object> map = (Map<String, Object>) result;
            for (Map.Entry<String, Object> entry : map.entrySet()) {
                testOutput().printf("============== file: %s ==============%n", entry.getKey());
                testOutput().println(displayValue(entry.getValue()));
            }
        } else {
            testOutput().println(displayValue(result));
        }
    }
}
Also used : BoundedDiagCollector(com.google.api.tools.framework.model.BoundedDiagCollector) DiagCollector(com.google.api.tools.framework.model.DiagCollector) BoundedDiagCollector(com.google.api.tools.framework.model.BoundedDiagCollector) Map(java.util.Map)

Aggregations

BoundedDiagCollector (com.google.api.tools.framework.model.BoundedDiagCollector)1 DiagCollector (com.google.api.tools.framework.model.DiagCollector)1 Map (java.util.Map)1