Search in sources :

Example 31 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project PowerNukkitX by BlocklyNukkit.

the class EnchantmentTest method beforeAll.

@BeforeAll
static void beforeAll() throws IOException {
    try (InputStream is = EnchantmentTest.class.getResourceAsStream("enchantments.json");
        Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
        enchantmentDataList = new Gson().fromJson(reader, EnchantmentTestList.class);
        for (EnchantmentData enchantmentData : enchantmentDataList) {
            try {
                assertTrue(enchantmentData.primary.stream().noneMatch(Objects::isNull));
                assertTrue(enchantmentData.secondary.stream().noneMatch(Objects::isNull));
            } catch (AssertionFailedError e) {
                throw new AssertionFailedError("One of the primary or secondary items in enchantment data of the " + enchantmentData.getId() + " enchantment was null", e);
            }
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Gson(com.google.gson.Gson) AssertionFailedError(org.opentest4j.AssertionFailedError) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 32 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 33 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 34 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 35 with AssertionFailedError

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

the class AbstractAssert_failWithActualExpectedAndMessage_Test method should_keep_description_set_by_user.

@Test
void should_keep_description_set_by_user() {
    // WHEN
    AssertionFailedError afe = expectAssertionFailedError(() -> assertion.as("user description").failWithActualExpectedAndMessage(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)

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