Search in sources :

Example 86 with TestDescription

use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.

the class ShouldNotHaveFailed_create_Test method should_create_error_message.

@Test
public void should_create_error_message() throws Exception {
    // GIVEN
    CompletableFuture<Object> future = new CompletableFuture<>();
    future.completeExceptionally(new RuntimeException());
    // WHEN
    String error = shouldNotHaveFailed(future).create(new TestDescription("TEST"));
    // THEN
    assertThat(error).startsWith(format("[TEST] %nExpecting%n  <CompletableFuture[Failed: java.lang.RuntimeException]%n")).contains("Caused by: java.lang.RuntimeException").endsWith(format("to not have failed.%n%s", WARNING));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) TestDescription(org.assertj.core.internal.TestDescription) Test(org.junit.Test)

Example 87 with TestDescription

use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.

the class ShouldHaveHost_create_Test method should_create_error_message_for_uri.

@Test
public void should_create_error_message_for_uri() throws Exception {
    String error = shouldHaveHost(new URI("http://assertj.org/news"), "foo.org").create(new TestDescription("TEST"));
    assertThat(error).isEqualTo(format("[TEST] %n" + "Expecting host of%n" + "  <http://assertj.org/news>%n" + "to be:%n" + "  <\"foo.org\">%n" + "but was:%n" + "  <\"assertj.org\">"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) URI(java.net.URI) Test(org.junit.Test)

Example 88 with TestDescription

use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.

the class ShouldHaveHost_create_Test method should_create_error_message_for_url.

@Test
public void should_create_error_message_for_url() throws Exception {
    String error = shouldHaveHost(new URL("http://assertj.org/news"), "foo.org").create(new TestDescription("TEST"));
    assertThat(error).isEqualTo(format("[TEST] %n" + "Expecting host of%n" + "  <http://assertj.org/news>%n" + "to be:%n" + "  <\"foo.org\">%n" + "but was:%n" + "  <\"assertj.org\">"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) URL(java.net.URL) Test(org.junit.Test)

Example 89 with TestDescription

use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.

the class ShouldHaveParameter_create_Test method should_create_error_message_for_url_parameter_with_value_that_has_no_value.

@Test
public void should_create_error_message_for_url_parameter_with_value_that_has_no_value() throws Exception {
    URL url = new URL("http://assertj.org/news?article");
    String error = shouldHaveParameter(url, "article", "10", newArrayList((String) null)).create(new TestDescription("TEST"));
    assertThat(error).isEqualTo(format("[TEST] %n" + "Expecting:%n" + "  <http://assertj.org/news?article>%n" + "to have parameter:%n" + "  <\"article\">%n" + "with value:%n" + "  <\"10\">%n" + "but parameter had no value"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) URL(java.net.URL) Test(org.junit.Test)

Example 90 with TestDescription

use of org.assertj.core.internal.TestDescription in project assertj-core by joel-costigliola.

the class ShouldHaveParameter_create_Test method should_create_error_message_for_uri_parameter_with_value_that_has_no_value.

@Test
public void should_create_error_message_for_uri_parameter_with_value_that_has_no_value() throws Exception {
    URI uri = new URI("http://assertj.org/news?article");
    String error = shouldHaveParameter(uri, "article", "10", newArrayList((String) null)).create(new TestDescription("TEST"));
    assertThat(error).isEqualTo(format("[TEST] %n" + "Expecting:%n" + "  <http://assertj.org/news?article>%n" + "to have parameter:%n" + "  <\"article\">%n" + "with value:%n" + "  <\"10\">%n" + "but parameter had no value"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) URI(java.net.URI) Test(org.junit.Test)

Aggregations

TestDescription (org.assertj.core.internal.TestDescription)126 Test (org.junit.Test)112 StandardRepresentation (org.assertj.core.presentation.StandardRepresentation)48 URI (java.net.URI)27 URL (java.net.URL)24 CompletableFuture (java.util.concurrent.CompletableFuture)9 Before (org.junit.Before)9 Description (org.assertj.core.description.Description)4 Path (java.nio.file.Path)2 EmptyTextDescription.emptyDescription (org.assertj.core.description.EmptyTextDescription.emptyDescription)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 AtomicStampedReference (java.util.concurrent.atomic.AtomicStampedReference)1 ShouldHaveToString.shouldHaveToString (org.assertj.core.error.ShouldHaveToString.shouldHaveToString)1 Representation (org.assertj.core.presentation.Representation)1 CaseInsensitiveStringComparator (org.assertj.core.util.CaseInsensitiveStringComparator)1