Search in sources :

Example 76 with AssertionFailedError

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

the class OptionalDoubleAssert_hasValue_Test method should_fail_if_optionalDouble_does_not_have_expected_value.

@Test
void should_fail_if_optionalDouble_does_not_have_expected_value() {
    // GIVEN
    OptionalDouble actual = OptionalDouble.of(5.0);
    double expectedValue = 10.0;
    // WHEN
    AssertionFailedError error = catchThrowableOfType(() -> assertThat(actual).hasValue(expectedValue), AssertionFailedError.class);
    // THEN
    assertThat(error).hasMessage(shouldContain(actual, expectedValue).create());
    assertThat(error.getActual().getStringRepresentation()).isEqualTo(String.valueOf(actual.getAsDouble()));
    assertThat(error.getExpected().getStringRepresentation()).isEqualTo(String.valueOf(expectedValue));
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError) OptionalDouble(java.util.OptionalDouble) Test(org.junit.jupiter.api.Test)

Example 77 with AssertionFailedError

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

the class ShouldBeEqual_newAssertionError_without_JUnit_Test method check.

private void check(AssertionError error) throws Exception {
    verify(constructorInvoker).newInstance(AssertionFailedError.class.getName(), new Class<?>[] { String.class, Object.class, Object.class }, format("[Jedi] %n" + "expected: \"Yoda\"%n" + " but was: \"Luke\""), STANDARD_REPRESENTATION.toStringOf("Yoda"), STANDARD_REPRESENTATION.toStringOf("Luke"));
    assertThat(error).isNotInstanceOf(ComparisonFailure.class).isInstanceOf(AssertionFailedError.class);
    AssertionFailedError assertionFailedError = (AssertionFailedError) error;
    assertThat(assertionFailedError.getActual().getValue()).isEqualTo(STANDARD_REPRESENTATION.toStringOf("Luke"));
    assertThat(assertionFailedError.getExpected().getValue()).isEqualTo(STANDARD_REPRESENTATION.toStringOf("Yoda"));
    assertThat(error).hasMessage(format("[Jedi] %n" + "expected: \"Yoda\"%n" + " but was: \"Luke\""));
}
Also used : ComparisonFailure(org.junit.ComparisonFailure) AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 78 with AssertionFailedError

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

the class AbstractAssert_failWithActualExpectedAndMessage_Test method expectAssertionFailedError.

static AssertionFailedError expectAssertionFailedError(ThrowingCallable shouldRaiseAssertionError) {
    AssertionFailedError error = catchThrowableOfType(shouldRaiseAssertionError, AssertionFailedError.class);
    assertThat(error).as("The code under test should have raised an AssertionFailedError").isNotNull();
    return error;
}
Also used : AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 79 with AssertionFailedError

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

the class AbstractAssert_failureWithActualExpected_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 = assertion.as("test context").overridingErrorMessage("my %d errors %s", 5, "!").failureWithActualExpected(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 80 with AssertionFailedError

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

the class DefaultAssertionErrorCollector_Test method decorated_AssertionFailedError_should_not_have_null_actual_and_expected_values_when_not_populated.

@Test
void decorated_AssertionFailedError_should_not_have_null_actual_and_expected_values_when_not_populated() {
    // GIVEN
    AssertionError error = new AssertionFailedError("boom");
    defaultAssertionErrorCollector.collectAssertionError(error);
    // WHEN
    AssertionError decoratedError = defaultAssertionErrorCollector.assertionErrorsCollected().get(0);
    // THEN
    then(decoratedError).isInstanceOf(AssertionFailedError.class).hasMessageContainingAll(error.getMessage(), "(DefaultAssertionErrorCollector_Test.java:69)");
    AssertionFailedError decoratedAssertionFailedError = (AssertionFailedError) decoratedError;
    then(decoratedAssertionFailedError.isActualDefined()).isFalse();
    then(decoratedAssertionFailedError.isExpectedDefined()).isFalse();
}
Also used : AssertionsUtil.expectAssertionError(org.assertj.core.util.AssertionsUtil.expectAssertionError) AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Aggregations

AssertionFailedError (org.opentest4j.AssertionFailedError)153 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 Collectors (java.util.stream.Collectors)5 File (java.io.File)4 ArrayList (java.util.ArrayList)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 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)3 Search (io.zulia.client.command.builder.Search)3 SearchResult (io.zulia.client.result.SearchResult)3 ExecutionException (java.util.concurrent.ExecutionException)3 Assertions (org.junit.jupiter.api.Assertions)3