Search in sources :

Example 91 with AssertionFailedError

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

the class AbstractAssert_failureWithActualExpected_Test method should_create_failure_with_message_having_args.

@Test
void should_create_failure_with_message_having_args() {
    // WHEN
    AssertionFailedError afe = assertion.failureWithActualExpected(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 92 with AssertionFailedError

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

the class AbstractAssert_failureWithActualExpected_Test method should_keep_description_set_by_user.

@Test
void should_keep_description_set_by_user() {
    // WHEN
    AssertionFailedError afe = assertion.as("user description").failureWithActualExpected(actual, expected, "fail %d %s", 5, "times");
    // THEN
    then(afe).hasMessage("[user description] fail 5 times");
    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 93 with AssertionFailedError

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

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 94 with AssertionFailedError

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

the class OptionalLongAssert_hasValue_Test method should_fail_if_OptionalLong_does_not_have_expected_value.

@Test
void should_fail_if_OptionalLong_does_not_have_expected_value() {
    // GIVEN
    OptionalLong actual = OptionalLong.of(5L);
    long expectedValue = 10L;
    // 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.getAsLong()));
    assertThat(error.getExpected().getStringRepresentation()).isEqualTo(String.valueOf(expectedValue));
}
Also used : OptionalLong(java.util.OptionalLong) AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Example 95 with AssertionFailedError

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

the class AssertionErrorCreator_assertionError_Test method should_create_AssertionFailedError_using_reflection.

@Test
void should_create_AssertionFailedError_using_reflection() {
    // GIVEN
    String actual = "actual";
    String expected = "expected";
    String message = "error message";
    Representation representation = mock(Representation.class);
    // WHEN
    AssertionError assertionError = assertionErrorCreator.assertionError(message, actual, expected, representation);
    // THEN
    then(assertionError).isInstanceOf(AssertionFailedError.class).hasMessage(message);
    AssertionFailedError assertionFailedError = (AssertionFailedError) assertionError;
    then(assertionFailedError.getActual().getValue()).isSameAs(actual);
    then(assertionFailedError.getExpected().getValue()).isSameAs(expected);
}
Also used : Representation(org.assertj.core.presentation.Representation) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) 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