Search in sources :

Example 21 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project JSqlParser by JSQLParser.

the class SpecialOracleTest method testAllSqlsParseDeparse.

@Test
public void testAllSqlsParseDeparse() throws IOException {
    int count = 0;
    int success = 0;
    File[] sqlTestFiles = SQLS_DIR.listFiles();
    boolean foundUnexpectedFailures = false;
    for (File file : sqlTestFiles) {
        if (file.isFile()) {
            count++;
            String sql = FileUtils.readFileToString(file, Charset.forName("UTF-8"));
            try {
                assertSqlCanBeParsedAndDeparsed(sql, true);
                success++;
                recordSuccessOnSourceFile(file);
            } catch (JSQLParserException ex) {
                String message = ex.getMessage();
                int pos = message.indexOf('\n');
                if (pos > 0) {
                    message = message.substring(0, pos);
                }
                if (sql.contains("@SUCCESSFULLY_PARSED_AND_DEPARSED") || EXPECTED_SUCCESSES.contains(file.getName())) {
                    LOG.log(Level.SEVERE, "UNEXPECTED PARSING FAILURE: {0}\n\t" + message, file.getName());
                    foundUnexpectedFailures = true;
                } else {
                    LOG.log(Level.FINE, "EXPECTED PARSING FAILURE: {0}", file.getName());
                }
                recordFailureOnSourceFile(file, message);
            } catch (Exception ex) {
                LOG.log(Level.SEVERE, "UNEXPECTED EXCEPTION: {0}\n\t" + ex.getMessage(), file.getName());
                foundUnexpectedFailures = true;
            } catch (AssertionFailedError ex) {
                if (sql.contains("@SUCCESSFULLY_PARSED_AND_DEPARSED") || EXPECTED_SUCCESSES.contains(file.getName())) {
                    LOG.log(Level.SEVERE, "UNEXPECTED DE-PARSING FAILURE: {0}\n" + ex.toString(), file.getName());
                    foundUnexpectedFailures = true;
                } else {
                    LOG.log(Level.FINE, "EXPECTED DE-PARSING FAILURE: {0}", file.getName());
                }
                recordFailureOnSourceFile(file, ex.getActual().getStringRepresentation());
            }
        }
    }
    LOG.log(Level.INFO, "tested {0} files. got {1} correct parse results, expected {2}", new Object[] { count, success, EXPECTED_SUCCESSES.size() });
    assertTrue(success >= EXPECTED_SUCCESSES.size());
    assertFalse(foundUnexpectedFailures, "Found Testcases failing unexpectedly.");
}
Also used : JSQLParserException(net.sf.jsqlparser.JSQLParserException) AssertionFailedError(org.opentest4j.AssertionFailedError) File(java.io.File) IOException(java.io.IOException) JSQLParserException(net.sf.jsqlparser.JSQLParserException) Test(org.junit.jupiter.api.Test)

Example 22 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by joel-costigliola.

the class ShouldBeEqual_Test method should_use_actual_and_expected_representation_in_AssertionFailedError_actual_and_expected_fields.

@Test
void should_use_actual_and_expected_representation_in_AssertionFailedError_actual_and_expected_fields() {
    // GIVEN
    byte[] actual = { 1, 2, 3 };
    byte[] expected = { 1, 2, 4 };
    ThrowingCallable code = () -> then(actual).as("numbers").isEqualTo(expected);
    // WHEN
    AssertionFailedError error = catchThrowableOfType(code, AssertionFailedError.class);
    // THEN
    then(error.getActual().getValue()).isEqualTo("[1, 2, 3]");
    then(error.getExpected().getValue()).isEqualTo("[1, 2, 4]");
    then(error).hasMessage(format("[numbers] %n" + "expected: [1, 2, 4]%n" + " but was: [1, 2, 3]"));
}
Also used : ThrowingCallable(org.assertj.core.api.ThrowableAssert.ThrowingCallable) AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Example 23 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by joel-costigliola.

the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_keep_specific_error_message_and_description_set_by_user.

@Test
void should_keep_specific_error_message_and_description_set_by_user() {
    // WHEN
    AssertionFailedError afe = expectAssertionFailedError(() -> assertion.as("test context").overridingErrorMessage("my %d errors %s", 5, "!").failWithActualExpectedAndMessage(actual, expected, "%d %s", 5, "time"));
    // THEN
    then(afe).hasMessage("[test context] my 5 errors !");
    then(afe.getActual().getEphemeralValue()).isSameAs(actual);
    then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Example 24 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by joel-costigliola.

the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_fail_with_message_having_args.

@Test
void should_fail_with_message_having_args() {
    // WHEN
    AssertionFailedError afe = expectAssertionFailedError(() -> assertion.failWithActualExpectedAndMessage(actual, expected, "fail %d %s %%s", 5, "times"));
    // THEN
    then(afe).hasMessage("fail 5 times %s");
    then(afe.getActual().getEphemeralValue()).isSameAs(actual);
    then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Example 25 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by joel-costigliola.

the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_fail_with_simple_message.

@Test
void should_fail_with_simple_message() {
    // WHEN
    AssertionFailedError afe = expectAssertionFailedError(() -> assertion.failWithActualExpectedAndMessage(actual, expected, "fail"));
    // THEN
    then(afe).hasMessage("fail");
    then(afe.getActual().getEphemeralValue()).isSameAs(actual);
    then(afe.getExpected().getEphemeralValue()).isSameAs(expected);
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Aggregations

AssertionFailedError (org.opentest4j.AssertionFailedError)144 Test (org.junit.jupiter.api.Test)72 AssertionTestUtils.expectAssertionFailedError (org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)12 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)8 IOException (java.io.IOException)8 URI (java.net.URI)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)8 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)4 Collectors (java.util.stream.Collectors)4 ThrowingCallable (org.assertj.core.api.ThrowableAssert.ThrowingCallable)4 GeneCentricEntry (org.uniprot.core.genecentric.GeneCentricEntry)4 GeneCentricDocument (org.uniprot.store.search.document.genecentric.GeneCentricDocument)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 Search (io.zulia.client.command.builder.Search)3 SearchResult (io.zulia.client.result.SearchResult)3 Assertions (org.junit.jupiter.api.Assertions)3 Order (org.junit.jupiter.api.Order)3 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2