Search in sources :

Example 1 with RichMappingTestResult

use of org.finos.legend.engine.test.runner.mapping.RichMappingTestResult in project legend-sdlc by finos.

the class MappingTestCase method doRunTest.

@Override
protected void doRunTest() {
    RichMappingTestResult richMappingTestResult = this.mappingTestRunner.doRunTest();
    MappingTest mappingTest = this.mappingTestRunner.mappingTest;
    if (richMappingTestResult.getResult() == TestResult.FAILURE) {
        String message = "Test failure for mapping test '" + mappingTest.name + "' for Mapping '" + this.entity.getPath() + "'";
        Optional<String> expected = richMappingTestResult.getExpected();
        Optional<String> actual = richMappingTestResult.getActual();
        if (expected.isPresent() || actual.isPresent()) {
            assertEquals(message, expected.orElse(null), actual.orElse(null));
        }
        fail(message);
    } else if (richMappingTestResult.getResult() == TestResult.ERROR) {
        StringWriter stringWriter = new StringWriter();
        PrintWriter printWriter = new PrintWriter(stringWriter);
        richMappingTestResult.getException().printStackTrace(printWriter);
        String stackTraceString = stringWriter.toString();
        fail("Error running mapping test '" + mappingTest.name + "' for Mapping '" + this.entity.getPath() + "' with error stack trace: \n" + stackTraceString + "\n");
    }
}
Also used : StringWriter(java.io.StringWriter) RichMappingTestResult(org.finos.legend.engine.test.runner.mapping.RichMappingTestResult) MappingTest(org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.mappingTest.MappingTest) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 MappingTest (org.finos.legend.engine.protocol.pure.v1.model.packageableElement.mapping.mappingTest.MappingTest)1 RichMappingTestResult (org.finos.legend.engine.test.runner.mapping.RichMappingTestResult)1