Search in sources :

Example 51 with TestDescription

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

the class ShouldHavePort_create_Test method should_create_error_message_for_url.

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

Example 52 with TestDescription

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

the class ShouldHaveQuery_create_Test method should_create_error_message_for_uri_has_no_query.

@Test
public void should_create_error_message_for_uri_has_no_query() throws Exception {
    URI uri = new URI("http://assertj.org/news?type=beta");
    String error = shouldHaveQuery(uri, null).create(new TestDescription("TEST"));
    assertThat(error).isEqualTo(format("[TEST] %n" + "Expecting:%n" + "  <http://assertj.org/news?type=beta>%n" + "not to have a query but had:%n" + "  <\"type=beta\">"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) URI(java.net.URI) Test(org.junit.Test)

Example 53 with TestDescription

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

the class ShouldNotExist_create_Test method setUp.

@Before
public void setUp() {
    description = new TestDescription("Test");
    representation = new StandardRepresentation();
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) StandardRepresentation(org.assertj.core.presentation.StandardRepresentation) Before(org.junit.Before)

Example 54 with TestDescription

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

the class ShouldNotHaveAnyElementsOfTypes_create_Test method should_create_error_message.

@Test
public void should_create_error_message() {
    // GIVEN
    List<Number> actual = new ArrayList<>();
    actual.add(1);
    actual.add(2);
    actual.add(3.0);
    actual.add(4.1);
    actual.add(BigDecimal.ONE);
    Class<?>[] unexpectedTypes = { Long.class, Double.class, BigDecimal.class };
    Map<Class<?>, List<Object>> nonMatchingElementsByType = new LinkedHashMap<>();
    nonMatchingElementsByType.put(BigDecimal.class, asObjectList(BigDecimal.ONE));
    nonMatchingElementsByType.put(Double.class, asObjectList(3.0, 4.1));
    ShouldNotHaveAnyElementsOfTypes shouldNotHaveAnyElementsOfTypes = shouldNotHaveAnyElementsOfTypes(actual, unexpectedTypes, nonMatchingElementsByType);
    // WHEN
    String message = shouldNotHaveAnyElementsOfTypes.create(new TestDescription("Test"), CONFIGURATION_PROVIDER.representation());
    // THEN
    assertThat(message).isEqualTo(format("[Test] %n" + "Expecting:%n" + "  <[1, 2, 3.0, 4.1, 1]>%n" + "to not have any elements of the following types:%n" + "  <[java.lang.Long, java.lang.Double, java.math.BigDecimal]>%n" + "but found:%n" + "  <{java.math.BigDecimal=[1], java.lang.Double=[3.0, 4.1]}>"));
}
Also used : TestDescription(org.assertj.core.internal.TestDescription) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 55 with TestDescription

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

the class ShouldHaveScheme_create_Test method should_create_error_message.

@Test
public void should_create_error_message() throws Exception {
    String error = shouldHaveScheme(new URI("http://assertj.org/"), "ftp").create(new TestDescription("TEST"));
    assertThat(error).isEqualTo(format("[TEST] %n" + "Expecting scheme of%n" + "  <http://assertj.org/>%n" + "to be:%n" + "  <\"ftp\">%n" + "but was:%n" + "  <\"http\">"));
}
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