diff --git a/src/main/java/org/assertj/core/api/AbstractAssert.java b/src/main/java/org/assertj/core/api/AbstractAssert.java index 894528b7a4..31066dfd19 100644 --- a/src/main/java/org/assertj/core/api/AbstractAssert.java +++ b/src/main/java/org/assertj/core/api/AbstractAssert.java @@ -119,6 +119,59 @@ public S as(Description description) { return describedAs(description); } + /** + * Use hexadecimal object representation instead of standard representation in error messages. + *

+ * It can be useful when comparing UNICODE characters - many unicode chars have duplicate characters assigned, + * it is thus impossible to find differences from the standard error message: + *

+ * With standard message: + *

+   * assertThat("µµµ").contains("μμμ");
+   *
+   * java.lang.AssertionError:
+   * Expecting:
+   *   <"µµµ">
+   * to contain:
+   *   <"μμμ">
+   * 
+ * + * With Hexadecimal message: + *
+   * assertThat("µµµ").asHexadecimal().contains("μμμ");
+   *
+   * java.lang.AssertionError:
+   * Expecting:
+   *   <"['00B5', '00B5', '00B5']">
+   * to contain:
+   *   <"['03BC', '03BC', '03BC']">
+   * 
+ * + * @return {@code this} assertion object. + */ + protected S asHexadecimal() { + info.representationAsHexadecimal(); + return myself; + } + + /** + * Use binary object representation instead of standard representation in error messages. + *

+ * Example: + *

+   * assertThat(1).asBinary().isEqualTo(2);
+   *
+   * org.junit.ComparisonFailure:
+   * Expected :0b00000000_00000000_00000000_00000010
+   * Actual   :0b00000000_00000000_00000000_00000001
+   *
+   * @return {@code this} assertion object.
+   */
+  protected S asBinary() {
+    info.representationAsBinary();
+    return myself;
+  }
+
   /** {@inheritDoc} */
   @Override
   public S describedAs(String description, Object... args) {
diff --git a/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java b/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java
index ed8da5ea30..5e605b0ced 100644
--- a/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java
+++ b/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java
@@ -594,4 +594,45 @@ public S usingDefaultComparator() {
     this.strings = Strings.instance();
     return myself;
   }
+
+  @Override
+  public S asHexadecimal() {
+    return super.asHexadecimal();
+  }
+
+  /**
+   * Use unicode character representation instead of standard representation in error messages.
+   * 

+ * It can be useful when comparing UNICODE characters - many unicode chars have duplicate characters assigned, + * it is thus impossible to find differences from the standard error message: + *

+ * With standard message: + *

+   * assertThat("µµµ").contains("μμμ");
+   *
+   * java.lang.AssertionError:
+   * Expecting:
+   *   <"µµµ">
+   * to contain:
+   *   <"μμμ">
+   * 
+ * + * With Hexadecimal message: + *
+   * assertThat("µµµ").asUnicode().contains("μμμ");
+   *
+   * java.lang.AssertionError:
+   * Expecting:
+   *   <\u00b5\u00b5\u00b5>
+   * to contain:
+   *   <\u03bc\u03bc\u03bc>
+   * 
+ * + * @return {@code this} assertion object. + */ + public S asUnicode() { + info.representationAsUnicode(); + return myself; + } + } diff --git a/src/main/java/org/assertj/core/api/AbstractCharacterAssert.java b/src/main/java/org/assertj/core/api/AbstractCharacterAssert.java index 069f6026c9..c8ab721893 100644 --- a/src/main/java/org/assertj/core/api/AbstractCharacterAssert.java +++ b/src/main/java/org/assertj/core/api/AbstractCharacterAssert.java @@ -150,6 +150,38 @@ public S isGreaterThan(char other) { return myself; } + /** + /** + * Use unicode character representation instead of standard representation in error messages. + *

+ * It can be useful when comparing UNICODE characters - many unicode chars have duplicate characters assigned, + * it is thus impossible to find differences from the standard error message: + *

+ * With standard error message: + *

+   * assertThat('µ').isEqualTo('μ');
+   *
+   * org.junit.ComparisonFailure:
+   * Expected :'μ'
+   * Actual   :'µ'
+   * 
+ * + * With unicode based error message: + *
+   * assertThat('µ').asUnicode().isEqualTo('μ');
+   *
+   * org.junit.ComparisonFailure:
+   * Expected :\u03bc
+   * Actual   :\u00b5
+   * 
+ * + * @return {@code this} assertion object. + */ + public S asUnicode() { + info.representationAsUnicode(); + return myself; + } + /** * Verifies that the actual value is greater than or equal to the given one. *

@@ -195,6 +227,7 @@ public S isGreaterThanOrEqualTo(char other) { * @throws AssertionError if the actual value is {@code null}. * @throws AssertionError if the actual value is not a lowercase character. */ + public S isLowerCase() { characters.assertLowerCase(info, actual); return myself; diff --git a/src/main/java/org/assertj/core/api/AbstractComparableAssert.java b/src/main/java/org/assertj/core/api/AbstractComparableAssert.java index 31ad297599..3644b475c8 100644 --- a/src/main/java/org/assertj/core/api/AbstractComparableAssert.java +++ b/src/main/java/org/assertj/core/api/AbstractComparableAssert.java @@ -80,4 +80,14 @@ public S usingDefaultComparator() { this.comparables = Comparables.instance(); return myself; } + + @Override + public S asHexadecimal() { + return super.asHexadecimal(); + } + + @Override + public S asBinary() { + return super.asBinary(); + } } diff --git a/src/main/java/org/assertj/core/api/AbstractDateAssert.java b/src/main/java/org/assertj/core/api/AbstractDateAssert.java index 2ef205c0a7..efbe9698b2 100644 --- a/src/main/java/org/assertj/core/api/AbstractDateAssert.java +++ b/src/main/java/org/assertj/core/api/AbstractDateAssert.java @@ -3,7 +3,6 @@ import static org.assertj.core.util.Dates.newIsoDateFormat; import static org.assertj.core.util.Dates.newIsoDateTimeFormat; import static org.assertj.core.util.Dates.newIsoDateTimeWithMsFormat; -import static org.assertj.core.util.ToString.toStringOf; import java.text.DateFormat; import java.text.ParseException; @@ -2157,7 +2156,7 @@ public static void useDefaultDateFormats() { * @throws AssertionError if the string can't be parsed as a Date */ @VisibleForTesting - static Date parse(String dateAsString) { + Date parse(String dateAsString) { if (dateAsString == null) return null; // use synchronized block because SimpleDateFormat which is not thread safe (sigh). // parse with date format specified by user @@ -2167,7 +2166,7 @@ static Date parse(String dateAsString) { return customDateFormat.parse(dateAsString); } catch (ParseException e) { throw new AssertionError("Failed to parse " + dateAsString + " with date format: " - + toStringOf(customDateFormat)); + + info.representation().toStringOf(customDateFormat)); } } } @@ -2182,7 +2181,7 @@ static Date parse(String dateAsString) { } // no suitable date format throw new AssertionError("Failed to parse " + dateAsString + " with any of these date formats: " - + toStringOf(defaultDateFormats)); + + info.representation().toStringOf(defaultDateFormats)); } } diff --git a/src/main/java/org/assertj/core/api/AbstractEnumerableAssert.java b/src/main/java/org/assertj/core/api/AbstractEnumerableAssert.java index a76e8c3836..fd47403c4e 100644 --- a/src/main/java/org/assertj/core/api/AbstractEnumerableAssert.java +++ b/src/main/java/org/assertj/core/api/AbstractEnumerableAssert.java @@ -40,4 +40,47 @@ public S hasSameSizeAs(Object other) { protected AbstractEnumerableAssert(final A actual, final Class selfType) { super(actual, selfType); } + + /** + * Enable hexadecimal object representation of Itearble elements instead of standard java representation in error messages. + *

+ * It can be useful to better understand what the error was with a more meaningful error message. + *

+ * Example + *

+   * assertThat(new byte[]{0x10,0x20}).asHex().contains(new byte[]{0x30});
+   * 
+ * + * With standard error message: + *
+   * Expecting:
+   *  <[16, 32]>
+   * to contain:
+   *  <[48]>
+   * but could not find:
+   *  <[48]>
+   * 
+ * + * With Hexadecimal error message: + *
+   * Expecting:
+   *  <[0x10, 0x20]>
+   * to contain:
+   *  <[0x30]>
+   * but could not find:
+   *  <[0x30]>
+   * 
+ * + * @return {@code this} assertion object. + */ + @Override + public S asHexadecimal() { + return super.asHexadecimal(); + } + + @Override + public S asBinary() { + return super.asBinary(); + } + } diff --git a/src/main/java/org/assertj/core/api/AbstractIterableAssert.java b/src/main/java/org/assertj/core/api/AbstractIterableAssert.java index 7a99931787..a0e2b649da 100644 --- a/src/main/java/org/assertj/core/api/AbstractIterableAssert.java +++ b/src/main/java/org/assertj/core/api/AbstractIterableAssert.java @@ -763,4 +763,84 @@ protected S usingComparisonStrategy(ComparisonStrategy comparisonStrategy) { public S usingElementComparatorIgnoringFields(String... fields) { return usingComparisonStrategy(new IgnoringFieldsComparisonStrategy(fields)); } + + /** + * Enable hexadecimal representation of Iterable elements instead of standard representation in error messages. + *

+ * It can be useful to better understand what the error was with a more meaningful error message. + *

+ * Example + *

+   * final List bytes = newArrayList((byte)0x10, (byte) 0x20);
+   * 
+ * + * With standard error message: + *
+   * assertThat(bytes).contains((byte)0x30);
+   *
+   * Expecting:
+   *  <[16, 32]>
+   * to contain:
+   *  <[48]>
+   * but could not find:
+   *  <[48]>
+   * 
+ * + * With Hexadecimal error message: + *
+   * assertThat(bytes).asHexadecimal().contains((byte)0x30);
+   *
+   * Expecting:
+   *  <[0x10, 0x20]>
+   * to contain:
+   *  <[0x30]>
+   * but could not find:
+   *  <[0x30]>
+   * 
+ * + * @return {@code this} assertion object. + */ + @Override + public S asHexadecimal() { // TODO rename to asHexadecimalElements() ? + return super.asHexadecimal(); + } + + /** + * Enable binary representation of Iterable elements instead of standard representation in error messages. + *

+ * Example: + *

+   * final List bytes = newArrayList((byte)0x10, (byte) 0x20);
+   * 
+ * + * With standard error message: + *
+   * assertThat(bytes).contains((byte)0x30);
+   *
+   * Expecting:
+   *  <[16, 32]>
+   * to contain:
+   *  <[48]>
+   * but could not find:
+   *  <[48]>
+   * 
+ * + * With binary error message: + *
+   * assertThat(bytes).asBinary().contains((byte)0x30);
+   *
+   * Expecting:
+   *  <[0b00010000, 0b00100000]>
+   * to contain:
+   *  <[0b00110000]>
+   * but could not find:
+   *  <[0b00110000]>
+   * 
+ * + * @return {@code this} assertion object. + */ + @Override + public S asBinary() { + return super.asBinary(); + } } diff --git a/src/main/java/org/assertj/core/api/AbstractObjectArrayAssert.java b/src/main/java/org/assertj/core/api/AbstractObjectArrayAssert.java index 5bcdb3d408..522f14ae90 100644 --- a/src/main/java/org/assertj/core/api/AbstractObjectArrayAssert.java +++ b/src/main/java/org/assertj/core/api/AbstractObjectArrayAssert.java @@ -528,5 +528,46 @@ public

ObjectArrayAssert

extractingResultOf(String method, Class

extra return new ObjectArrayAssert

(values); } - + + /** + * Enable hexadecimal object representation of Itearble elements instead of standard java representation in error messages. + *

+ * It can be useful to better understand what the error was with a more meaningful error message. + *

+ * Example + *

+   * assertThat(new Byte[]{0x10,0x20}).asHexadecimal().contains(new Byte[]{0x30});
+   * 
+ * + * With standard error message: + *
+   * Expecting:
+   *  <[16, 32]>
+   * to contain:
+   *  <[48]>
+   * but could not find:
+   *  <[48]>
+   * 
+ * + * With Hexadecimal error message: + *
+   * Expecting:
+   *  <[0x10, 0x20]>
+   * to contain:
+   *  <[0x30]>
+   * but could not find:
+   *  <[0x30]>
+   * 
+ * + * @return {@code this} assertion object. + */ + @Override + public S asHexadecimal() { + return super.asHexadecimal(); + } + + @Override + public S asBinary() { + return super.asBinary(); + } } diff --git a/src/main/java/org/assertj/core/api/AssertionInfo.java b/src/main/java/org/assertj/core/api/AssertionInfo.java index c7a843983e..f5f2a0c22a 100644 --- a/src/main/java/org/assertj/core/api/AssertionInfo.java +++ b/src/main/java/org/assertj/core/api/AssertionInfo.java @@ -15,6 +15,7 @@ package org.assertj.core.api; import org.assertj.core.description.Description; +import org.assertj.core.presentation.Representation; /** * Information about an assertion. @@ -36,4 +37,5 @@ public interface AssertionInfo { */ Description description(); + Representation representation(); } \ No newline at end of file diff --git a/src/main/java/org/assertj/core/api/WritableAssertionInfo.java b/src/main/java/org/assertj/core/api/WritableAssertionInfo.java index 475d5fe91c..bb901b02da 100644 --- a/src/main/java/org/assertj/core/api/WritableAssertionInfo.java +++ b/src/main/java/org/assertj/core/api/WritableAssertionInfo.java @@ -21,11 +21,14 @@ import org.assertj.core.description.Description; import org.assertj.core.description.EmptyTextDescription; +import org.assertj.core.presentation.*; +import org.assertj.core.presentation.BinaryRepresentation; +import org.assertj.core.presentation.HexadecimalRepresentation; /** * Writable information about an assertion. - * + * * @author Alex Ruiz * @author Yvonne Wang */ @@ -33,8 +36,11 @@ public class WritableAssertionInfo implements AssertionInfo { private String overridingErrorMessage; private Description description; + private Representation representation; - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public String overridingErrorMessage() { return overridingErrorMessage; @@ -42,20 +48,25 @@ public String overridingErrorMessage() { /** * Sets the message that will replace the default message of an assertion failure. + * * @param newErrorMessage the new message. It can be {@code null}. */ public void overridingErrorMessage(String newErrorMessage) { overridingErrorMessage = newErrorMessage; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public Description description() { return description; } + /** * Returns the text of this object's description, or {@code null} if such description is {@code null}. + * * @return the text of this object's description, or {@code null} if such description is {@code null}. */ public String descriptionText() { @@ -64,8 +75,9 @@ public String descriptionText() { /** * Sets the description of an assertion. + * * @param newDescription the new description. - * @param args if {@code newDescription} is a format String, {@code args} is argument of {@link String#format(String, Object...)} + * @param args if {@code newDescription} is a format String, {@code args} is argument of {@link String#format(String, Object...)} * @throws NullPointerException if the given description is {@code null}. * @see #description(Description) */ @@ -76,6 +88,7 @@ public void description(String newDescription, Object... args) { /** * Sets the description of an assertion. To remove or clear the description, pass a {@link EmptyTextDescription} as * argument. + * * @param newDescription the new description. * @throws NullPointerException if the given description is {@code null}. */ @@ -83,7 +96,36 @@ public void description(Description newDescription) { description = checkIsNotNull(newDescription); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ + @Override + public Representation representation() { + if (representation == null) { + representation = new StandardRepresentation(); + } + return representation; + } + + public void representationAsHexadecimal() { + representation = new HexadecimalRepresentation(); + } + + public void representationAsUnicode() { + representation = new UnicodeRepresentation(); + } + + public void representationAsBinary() { + representation = new BinaryRepresentation(); + } + + public void representation(Representation newRepresentation) { + representation = newRepresentation; + } + + /** + * {@inheritDoc} + */ @Override public String toString() { String format = "%s[overridingErrorMessage=%s, description=%s]"; diff --git a/src/main/java/org/assertj/core/error/AbstractShouldHaveTextContent.java b/src/main/java/org/assertj/core/error/AbstractShouldHaveTextContent.java index 293423b8f6..5927bb5e20 100644 --- a/src/main/java/org/assertj/core/error/AbstractShouldHaveTextContent.java +++ b/src/main/java/org/assertj/core/error/AbstractShouldHaveTextContent.java @@ -5,6 +5,7 @@ import java.util.List; import org.assertj.core.description.Description; +import org.assertj.core.presentation.Representation; /** @@ -23,7 +24,7 @@ public AbstractShouldHaveTextContent(String format, Object... arguments) { } @Override - public String create(Description d) { + public String create(Description d, Representation representation) { // we append diffs here as we can't add in super constructor call, see why below. // // case 1 - append diffs to String passed in super : @@ -37,7 +38,7 @@ public String create(Description d) { // error message. This is not what we want // // The solution is to keep diffs as an attribute and append it after String.format has been applied on the error message. - return super.create(d) + diffs; + return super.create(d, representation) + diffs; } protected static String diffsAsString(List diffsList) { diff --git a/src/main/java/org/assertj/core/error/AssertionErrorFactory.java b/src/main/java/org/assertj/core/error/AssertionErrorFactory.java index c70ddbe1af..d36b6a24b0 100644 --- a/src/main/java/org/assertj/core/error/AssertionErrorFactory.java +++ b/src/main/java/org/assertj/core/error/AssertionErrorFactory.java @@ -15,6 +15,7 @@ package org.assertj.core.error; import org.assertj.core.description.Description; +import org.assertj.core.presentation.Representation; /** * Factory of {@link AssertionError}s. @@ -27,7 +28,8 @@ public interface AssertionErrorFactory { /** * Creates an {@link AssertionError}. * @param d the description of the failed assertion. + * @param representation * @return the created {@code AssertionError}. */ - AssertionError newAssertionError(Description d); + AssertionError newAssertionError(Description d, Representation representation); } diff --git a/src/main/java/org/assertj/core/error/BasicErrorMessageFactory.java b/src/main/java/org/assertj/core/error/BasicErrorMessageFactory.java index 86f2823beb..8063622a7a 100644 --- a/src/main/java/org/assertj/core/error/BasicErrorMessageFactory.java +++ b/src/main/java/org/assertj/core/error/BasicErrorMessageFactory.java @@ -26,6 +26,8 @@ import org.assertj.core.description.Description; import org.assertj.core.description.EmptyTextDescription; +import org.assertj.core.presentation.Representation; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.VisibleForTesting; /** @@ -114,14 +116,14 @@ public BasicErrorMessageFactory(String format, Object... arguments) { /** {@inheritDoc} */ @Override - public String create(Description d) { - return formatter.format(d, format, arguments); + public String create(Description d, Representation representation) { + return formatter.format(d, representation, format, arguments); } /** {@inheritDoc} */ @Override public String create() { - return formatter.format(EmptyTextDescription.emptyText(), format, arguments); + return formatter.format(EmptyTextDescription.emptyText(), new StandardRepresentation(), format, arguments); } /** @@ -161,7 +163,8 @@ public int hashCode() { @Override public String toString() { - return format("%s[format=%s, arguments=%s]", getClass().getSimpleName(), quote(format), format(arguments)); + return format("%s[format=%s, arguments=%s]", getClass().getSimpleName(), quote(format), + format(new StandardRepresentation(), arguments)); } } diff --git a/src/main/java/org/assertj/core/error/ErrorMessageFactory.java b/src/main/java/org/assertj/core/error/ErrorMessageFactory.java index 410a8bccbf..f74f249bc3 100644 --- a/src/main/java/org/assertj/core/error/ErrorMessageFactory.java +++ b/src/main/java/org/assertj/core/error/ErrorMessageFactory.java @@ -15,6 +15,7 @@ package org.assertj.core.error; import org.assertj.core.description.Description; +import org.assertj.core.presentation.Representation; /** * Factory of error messages. @@ -26,9 +27,10 @@ public interface ErrorMessageFactory { /** * Creates a new error message as a result of a failed assertion. * @param d the description of the failed assertion. + * @param p * @return the created error message. */ - String create(Description d); + String create(Description d, Representation p); /** * Creates a new error message as a result of a failed assertion without description. diff --git a/src/main/java/org/assertj/core/error/MessageFormatter.java b/src/main/java/org/assertj/core/error/MessageFormatter.java index 327e206b58..c9b9f2e912 100644 --- a/src/main/java/org/assertj/core/error/MessageFormatter.java +++ b/src/main/java/org/assertj/core/error/MessageFormatter.java @@ -16,15 +16,13 @@ import static org.assertj.core.util.Preconditions.checkNotNull; import static org.assertj.core.util.Strings.formatIfArgs; -import static org.assertj.core.util.ToString.toStringOf; import org.assertj.core.description.Description; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; import org.assertj.core.internal.StandardComparisonStrategy; -import org.assertj.core.util.ToString; +import org.assertj.core.presentation.Representation; import org.assertj.core.util.VisibleForTesting; - /** * Formats the messages to be included in assertion errors. * @@ -41,7 +39,8 @@ public static MessageFormatter instance() { DescriptionFormatter descriptionFormatter = DescriptionFormatter.instance(); @VisibleForTesting - MessageFormatter() {} + MessageFormatter() { + } /** * Interprets a printf-style format {@code String} for failed assertion messages. It is similar to @@ -50,7 +49,7 @@ public static MessageFormatter instance() { *
  • the value of the given {@link Description} is used as the first argument referenced in the format * string
  • *
  • each of the arguments in the given array is converted to a {@code String} by invoking - * {@link ToString#toStringOf(Object)}. + * {@link org.assertj.core.presentation.Representation#toStringOf(Object)}. * * * @param d the description of the failed assertion, may be {@code null}. @@ -59,28 +58,28 @@ public static MessageFormatter instance() { * @throws NullPointerException if the format string is {@code null}. * @return A formatted {@code String}. */ - public String format(Description d, String format, Object... args) { + public String format(Description d, Representation p, String format, Object... args) { checkNotNull(format); checkNotNull(args); - return descriptionFormatter.format(d) + formatIfArgs(format, format(args)); + return descriptionFormatter.format(d) + formatIfArgs(format, format(p, args)); } - private Object[] format(Object[] args) { + private Object[] format(Representation p, Object[] args) { int argCount = args.length; String[] formatted = new String[argCount]; for (int i = 0; i < argCount; i++) { - formatted[i] = asText(args[i]); + formatted[i] = asText(p, args[i]); } return formatted; } - private String asText(Object o) { + private String asText(Representation p, Object o) { if (o instanceof ComparatorBasedComparisonStrategy) { return "according to " + o + " comparator"; } if (o instanceof StandardComparisonStrategy) { return ""; } - return toStringOf(o); + return p.toStringOf(o); } } diff --git a/src/main/java/org/assertj/core/error/ShouldBeBetween.java b/src/main/java/org/assertj/core/error/ShouldBeBetween.java index 7c08e94149..d7177588f8 100644 --- a/src/main/java/org/assertj/core/error/ShouldBeBetween.java +++ b/src/main/java/org/assertj/core/error/ShouldBeBetween.java @@ -92,7 +92,7 @@ private ShouldBeBetween(Date actual, Date start, Date end, boolean inclusiveStar } private > ShouldBeBetween(T actual, T start, T end, boolean inclusiveStart, boolean inclusiveEnd, - ComparisonStrategy comparisonStrategy) { + ComparisonStrategy comparisonStrategy) { super("\nExpecting:\n <%s>\nto be between:\n " + (inclusiveStart ? '[' : ']') +"%s, %s%s" + (inclusiveEnd ? ']' : '['), actual, start, end, comparisonStrategy); } diff --git a/src/main/java/org/assertj/core/error/ShouldBeEqual.java b/src/main/java/org/assertj/core/error/ShouldBeEqual.java index 66431b0d6f..6863f63f2b 100644 --- a/src/main/java/org/assertj/core/error/ShouldBeEqual.java +++ b/src/main/java/org/assertj/core/error/ShouldBeEqual.java @@ -21,10 +21,10 @@ import static org.assertj.core.util.Arrays.array; import static org.assertj.core.util.Objects.*; -import static org.assertj.core.util.ToString.toStringOf; import org.assertj.core.description.Description; import org.assertj.core.internal.*; +import org.assertj.core.presentation.Representation; import org.assertj.core.util.VisibleForTesting; @@ -51,6 +51,7 @@ public class ShouldBeEqual implements AssertionErrorFactory { @VisibleForTesting final MessageFormatter messageFormatter = MessageFormatter.instance(); private final ComparisonStrategy comparisonStrategy; + private Representation representation; @VisibleForTesting ConstructorInvoker constructorInvoker = new ConstructorInvoker(); @VisibleForTesting @@ -63,8 +64,8 @@ public class ShouldBeEqual implements AssertionErrorFactory { * @param expected the expected value in the failed assertion. * @return the created {@code AssertionErrorFactory}. */ - public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected) { - return new ShouldBeEqual(actual, expected, StandardComparisonStrategy.instance()); + public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected, Representation representation) { + return new ShouldBeEqual(actual, expected, StandardComparisonStrategy.instance(), representation); } /** @@ -76,15 +77,16 @@ public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected * @return the created {@code AssertionErrorFactory}. */ public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected, - ComparisonStrategy comparisonStrategy) { - return new ShouldBeEqual(actual, expected, comparisonStrategy); + ComparisonStrategy comparisonStrategy, Representation representation) { + return new ShouldBeEqual(actual, expected, comparisonStrategy, representation); } @VisibleForTesting - ShouldBeEqual(Object actual, Object expected, ComparisonStrategy comparisonStrategy) { + ShouldBeEqual(Object actual, Object expected, ComparisonStrategy comparisonStrategy, Representation representation) { this.actual = actual; this.expected = expected; this.comparisonStrategy = comparisonStrategy; + this.representation = representation; } /** @@ -98,10 +100,11 @@ public static AssertionErrorFactory shouldBeEqual(Object actual, Object expected * (see {@link Failures#setRemoveAssertJRelatedElementsFromStackTrace(boolean)}). * * @param description the description of the failed assertion. + * @param representation * @return the created {@code AssertionError}. */ @Override - public AssertionError newAssertionError(Description description) { + public AssertionError newAssertionError(Description description, Representation representation) { if (actualAndExpectedHaveSameStringRepresentation()) { // Example : actual = 42f and expected = 42d gives actual : "42" and expected : "42" and // JUnit 4 manages this case even worst, it will output something like : @@ -109,7 +112,7 @@ public AssertionError newAssertionError(Description description) { // which does not solve the problem and makes things even more confusing since we lost the fact that 42 was a // float or a double, it is then better to built our own description, with the drawback of not using a // ComparisonFailure (which looks nice in eclipse) - return Failures.instance().failure(defaultDetailedErrorMessage(description)); + return Failures.instance().failure(defaultDetailedErrorMessage(description, representation)); } // if comparison strategy was based on a custom comparator, we build the assertion error message, the result is // better than the JUnit ComparisonFailure we could build (that would not mention the comparator). @@ -119,11 +122,11 @@ public AssertionError newAssertionError(Description description) { if (error != null) { return error; } } // No JUnit in the classpath => fall back to default error message. - return Failures.instance().failure(defaultErrorMessage(description)); + return Failures.instance().failure(defaultErrorMessage(description, representation)); } /** - * Tells {@link #newAssertionError(Description)} if it should try a build a {@link org.junit.ComparisonFailure}.
    + * Tells {@link AssertionErrorFactory#newAssertionError(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)} if it should try a build a {@link org.junit.ComparisonFailure}.
    * Returns true as we try in this class (may not be the case in subclasses). * * @return true @@ -136,7 +139,7 @@ private boolean isJUnitComparisonFailureRelevant() { } private boolean actualAndExpectedHaveSameStringRepresentation() { - return areEqual(toStringOf(actual), toStringOf(expected)); + return areEqual(representation.toStringOf(actual), representation.toStringOf(expected)); } /** @@ -144,13 +147,14 @@ private boolean actualAndExpectedHaveSameStringRepresentation() { * representation. * * @param description the {@link Description} used to build the returned error message + * @param representation the {@link org.assertj.core.presentation.Representation} used to build String representation of object * @return the error message from description using {@link #expected} and {@link #actual} basic representation. */ - private String defaultErrorMessage(Description description) { + private String defaultErrorMessage(Description description, Representation representation) { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) return messageFormatter - .format(description, EXPECTED_BUT_WAS_MESSAGE_USING_COMPARATOR, actual, expected, comparisonStrategy); - return messageFormatter.format(description, EXPECTED_BUT_WAS_MESSAGE, expected, actual); + .format(description, representation, EXPECTED_BUT_WAS_MESSAGE_USING_COMPARATOR, actual, expected, comparisonStrategy); + return messageFormatter.format(description, representation, EXPECTED_BUT_WAS_MESSAGE, expected, actual); } /** @@ -158,14 +162,15 @@ private String defaultErrorMessage(Description description) { * #detailedActual()} detailed representation. * * @param description the {@link Description} used to build the returned error message + * @param representation the {@link org.assertj.core.presentation.Representation} used to build String representation of object * @return the error message from description using {@link #detailedExpected()} and {@link #detailedActual()} * detailed representation. */ - private String defaultDetailedErrorMessage(Description description) { + private String defaultDetailedErrorMessage(Description description, Representation representation) { if (comparisonStrategy instanceof ComparatorBasedComparisonStrategy) - return messageFormatter.format(description, EXPECTED_BUT_WAS_MESSAGE_USING_COMPARATOR, detailedActual(), + return messageFormatter.format(description, representation, EXPECTED_BUT_WAS_MESSAGE_USING_COMPARATOR, detailedActual(), detailedExpected(), comparisonStrategy); - return messageFormatter.format(description, EXPECTED_BUT_WAS_MESSAGE, detailedExpected(), detailedActual()); + return messageFormatter.format(description, representation, EXPECTED_BUT_WAS_MESSAGE, detailedExpected(), detailedActual()); } private AssertionError comparisonFailure(Description description) { @@ -185,11 +190,11 @@ private AssertionError newComparisonFailure(String description) throws Exception } private Object[] msgArgs(String description) { - return array(description, toStringOf(expected), toStringOf(actual)); + return array(description, representation.toStringOf(expected), representation.toStringOf(actual)); } - private static String detailedToStringOf(Object obj) { - return toStringOf(obj) + " (" + obj.getClass().getSimpleName() + "@" + toHexString(obj.hashCode()) + ")"; + private String detailedToStringOf(Object obj) { + return representation.toStringOf(obj) + " (" + obj.getClass().getSimpleName() + "@" + toHexString(obj.hashCode()) + ")"; } private String detailedActual() { diff --git a/src/main/java/org/assertj/core/groups/Tuple.java b/src/main/java/org/assertj/core/groups/Tuple.java index 1dd4ca3427..8eb860979d 100644 --- a/src/main/java/org/assertj/core/groups/Tuple.java +++ b/src/main/java/org/assertj/core/groups/Tuple.java @@ -19,12 +19,8 @@ import java.util.ArrayList; import java.util.List; -import org.assertj.core.util.Collections; - public class Tuple { - private static final String END = ")"; - private static final String START = "("; private final List datas = newArrayList(); public Tuple(Object... values) { @@ -35,6 +31,10 @@ public void addData(Object data) { datas.add(data); } + public Object[] toArray() { + return datas.toArray(); + } + @Override public int hashCode() { final int prime = 31; @@ -57,7 +57,7 @@ public boolean equals(Object obj) { @Override public String toString() { - return Collections.format(datas, START, END); + return java.util.Arrays.toString(toArray()); } public static List buildTuples(int n) { diff --git a/src/main/java/org/assertj/core/internal/Booleans.java b/src/main/java/org/assertj/core/internal/Booleans.java index 9b97498bf5..4e004a51cd 100644 --- a/src/main/java/org/assertj/core/internal/Booleans.java +++ b/src/main/java/org/assertj/core/internal/Booleans.java @@ -57,7 +57,7 @@ public static Booleans instance() { public void assertEqual(AssertionInfo info, Boolean actual, boolean expected) { assertNotNull(info, actual); if (actual == expected) return; - throw failures.failure(info, shouldBeEqual(actual, expected)); + throw failures.failure(info, shouldBeEqual(actual, expected, info.representation())); } /** diff --git a/src/main/java/org/assertj/core/internal/Comparables.java b/src/main/java/org/assertj/core/internal/Comparables.java index d9ae874dc3..76a314f16a 100644 --- a/src/main/java/org/assertj/core/internal/Comparables.java +++ b/src/main/java/org/assertj/core/internal/Comparables.java @@ -92,7 +92,7 @@ public void assertEqual(AssertionInfo info, T actual, T expected) { assertNotNull(info, actual); if (areEqual(actual, expected)) return; - throw failures.failure(info, shouldBeEqual(actual, expected, comparisonStrategy)); + throw failures.failure(info, shouldBeEqual(actual, expected, comparisonStrategy, info.representation())); } protected boolean areEqual(T actual, T expected) { @@ -134,7 +134,7 @@ public > void assertEqualByComparison(AssertionI // we don't delegate to comparisonStrategy, as this assertion makes it clear it relies on Comparable if (actual.compareTo(expected) == 0) return; - throw failures.failure(info, shouldBeEqual(actual, expected)); + throw failures.failure(info, shouldBeEqual(actual, expected, info.representation())); } /** diff --git a/src/main/java/org/assertj/core/internal/Failures.java b/src/main/java/org/assertj/core/internal/Failures.java index cc2c7f2e65..e8af5d6bbf 100644 --- a/src/main/java/org/assertj/core/internal/Failures.java +++ b/src/main/java/org/assertj/core/internal/Failures.java @@ -17,6 +17,7 @@ import static org.assertj.core.util.Strings.isNullOrEmpty; import org.assertj.core.api.AssertionInfo; +import org.assertj.core.description.Description; import org.assertj.core.error.AssertionErrorFactory; import org.assertj.core.error.ErrorMessageFactory; import org.assertj.core.error.MessageFormatter; @@ -74,7 +75,7 @@ public void setRemoveAssertJRelatedElementsFromStackTrace(boolean removeAssertJR public AssertionError failure(AssertionInfo info, AssertionErrorFactory factory) { AssertionError error = failureIfErrorMessageIsOverriden(info); if (error != null) return error; - return factory.newAssertionError(info.description()); + return factory.newAssertionError(info.description(), info.representation()); } /** @@ -93,7 +94,7 @@ public AssertionError failure(AssertionInfo info, AssertionErrorFactory factory) public AssertionError failure(AssertionInfo info, ErrorMessageFactory message) { AssertionError error = failureIfErrorMessageIsOverriden(info); if (error != null) return error; - AssertionError assertionError = new AssertionError(message.create(info.description())); + AssertionError assertionError = new AssertionError(message.create(info.description(), info.representation())); removeAssertJRelatedElementsFromStackTraceIfNeeded(assertionError); return assertionError; } @@ -101,7 +102,7 @@ public AssertionError failure(AssertionInfo info, ErrorMessageFactory message) { private AssertionError failureIfErrorMessageIsOverriden(AssertionInfo info) { String overridingErrorMessage = info.overridingErrorMessage(); return isNullOrEmpty(overridingErrorMessage) ? null : failure(MessageFormatter.instance().format(info.description(), - overridingErrorMessage)); + info.representation(), overridingErrorMessage)); } /** @@ -147,7 +148,7 @@ public AssertionError failure(String message) { at examples.StackTraceFilterExample.main(StackTraceFilterExample.java:20) * * - * Method is public because we need to call it from {@link ShouldBeEqual#newAssertionError(org.assertj.core.description.Description)} that is building a junit ComparisonFailure by reflection. + * Method is public because we need to call it from {@link ShouldBeEqual#newAssertionError(Description, org.assertj.core.presentation.Representation)} that is building a junit ComparisonFailure by reflection. * * @param assertionError the {@code AssertionError} to filter stack trace if option is set. */ diff --git a/src/main/java/org/assertj/core/internal/Objects.java b/src/main/java/org/assertj/core/internal/Objects.java index fccc14ca61..84b95b366f 100644 --- a/src/main/java/org/assertj/core/internal/Objects.java +++ b/src/main/java/org/assertj/core/internal/Objects.java @@ -38,7 +38,6 @@ import static org.assertj.core.internal.CommonValidations.checkTypeIsNotNull; import static org.assertj.core.util.Lists.*; import static org.assertj.core.util.Sets.*; -import static org.assertj.core.util.ToString.toStringOf; import java.lang.reflect.Field; import java.util.Comparator; @@ -93,7 +92,7 @@ public Comparator getComparator() { /** * Verifies that the given object is an instance of the given type. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param type the type to check the given object against. @@ -107,7 +106,7 @@ public void assertIsInstanceOf(AssertionInfo info, Object actual, Class type) /** * Verifies that the given object is an instance of any of the given types. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param types the types to check the given object against. @@ -128,7 +127,7 @@ private boolean objectIsInstanceOfOneOfGivenClasses(Object actual, Class[] ty for (Class type : types) { if (type == null) { String format = "The given array of types:<%s> should not have null elements"; - throw new NullPointerException(format(format, toStringOf(types))); + throw new NullPointerException(format(format, info.representation().toStringOf(types))); } if (type.isInstance(actual)) { return true; @@ -139,7 +138,7 @@ private boolean objectIsInstanceOfOneOfGivenClasses(Object actual, Class[] ty /** * Verifies that the given object is not an instance of the given type. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param type the type to check the given object against. @@ -159,7 +158,7 @@ private boolean isInstanceOfClass(Object actual, Class clazz, AssertionInfo i /** * Verifies that the given object is not an instance of any of the given types. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param types the types to check the given object against. @@ -176,7 +175,7 @@ public void assertIsNotInstanceOfAny(AssertionInfo info, Object actual, Class /** * Verifies that the actual value has the same class as the given object. - * + * * @param info contains information about the assertion. * @param actual the given object. * @throws AssertionError if the actual has not the same type has the given object. @@ -199,7 +198,7 @@ private boolean haveSameClass(Object actual, Object other, AssertionInfo info) { /** * Verifies that the actual value does not have the same class as the given object. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to check type against. @@ -213,7 +212,7 @@ public void assertDoesNotHaveSameClassAs(AssertionInfo info, Object actual, Obje /** * Verifies that the actual value is exactly a instance of given type. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param type the type to check the actual value against. @@ -234,7 +233,7 @@ private boolean actualIsExactlyInstanceOfType(Object actual, Class expectedTy /** * Verifies that the actual value is not exactly a instance of given type. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param type the type to check the actual value against. @@ -249,7 +248,7 @@ public void assertIsNotExactlyInstanceOf(AssertionInfo info, Object actual, Clas /** * Verifies that the actual value type is in given types. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param types the types to check the actual value against. @@ -270,7 +269,7 @@ private boolean isOfOneOfGivenTypes(Object actual, Class[] types, AssertionIn /** * Verifies that the actual value type is not in given types. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param types the types to check the actual value against. @@ -294,7 +293,7 @@ private void checkIsNotNullAndIsNotEmpty(Class[] types) { /** * Asserts that two objects are equal. - * + * * @param info contains information about the assertion. * @param actual the "actual" object. * @param expected the "expected" object. @@ -306,12 +305,12 @@ public void assertEqual(AssertionInfo info, Object actual, Object expected) { if (areEqual(actual, expected)) { return; } - throw failures.failure(info, shouldBeEqual(actual, expected, comparisonStrategy)); + throw failures.failure(info, shouldBeEqual(actual, expected, comparisonStrategy, info.representation())); } /** * Asserts that two objects are not equal. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. @@ -326,7 +325,7 @@ public void assertNotEqual(AssertionInfo info, Object actual, Object other) { /** * Compares actual and other with standard strategy (null safe equals check). - * + * * @param actual the object to compare to other * @param other the object to compare to actual * @return true if actual and other are equal (null safe equals check), false otherwise. @@ -337,7 +336,7 @@ private boolean areEqual(Object actual, Object other) { /** * Asserts that the given object is {@code null}. - * + * * @param info contains information about the assertion. * @param actual the given object. * @throws AssertionError if the given object is not {@code null}. @@ -346,12 +345,12 @@ public void assertNull(AssertionInfo info, Object actual) { if (actual == null) { return; } - throw failures.failure(info, shouldBeEqual(actual, null, comparisonStrategy)); + throw failures.failure(info, shouldBeEqual(actual, null, comparisonStrategy, info.representation())); } /** * Asserts that the given object is not {@code null}. - * + * * @param info contains information about the assertion. * @param actual the given object. * @throws AssertionError if the given object is {@code null}. @@ -365,7 +364,7 @@ public void assertNotNull(AssertionInfo info, Object actual) { /** * Asserts that two objects refer to the same object. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param expected the expected object. @@ -380,7 +379,7 @@ public void assertSame(AssertionInfo info, Object actual, Object expected) { /** * Asserts that two objects do not refer to the same object. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. @@ -395,7 +394,7 @@ public void assertNotSame(AssertionInfo info, Object actual, Object other) { /** * Asserts that the given object is present in the given array. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param values the given array. @@ -414,7 +413,7 @@ public void assertIsIn(AssertionInfo info, Object actual, Object[] values) { /** * Asserts that the given object is not present in the given array. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param values the given array. @@ -442,7 +441,7 @@ private void checkIsNotNullAndNotEmpty(Object[] values) { /** * Returns true if given item is in given array, false otherwise. - * + * * @param item the object to look for in arrayOfValues * @param arrayOfValues the array of values * @return true if given item is in given array, false otherwise. @@ -456,7 +455,7 @@ private boolean isItemInArray(Object item, Object[] arrayOfValues) { /** * Asserts that the given object is present in the given collection. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param values the given iterable. @@ -475,7 +474,7 @@ public void assertIsIn(AssertionInfo info, Object actual, Iterable values) { /** * Asserts that the given object is not present in the given collection. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param values the given collection. @@ -513,7 +512,7 @@ private boolean isActualIn(Object actual, Iterable values) { /** * Assert that the given object is lenient equals by ignoring null fields value on other object (including inherited * fields). - * + * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. @@ -552,7 +551,7 @@ public void assertIsLenientEqualsToIgnoringNullFields(AssertionInfo info, A /** * Assert that the given object is lenient equals to other object by comparing given fields value only. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. @@ -613,7 +612,7 @@ private Field findField(String fieldName, Set fields, Class clazz) { /** * Assert that the given object is lenient equals to the other by comparing all fields (including inherited fields) * unless given ignored ones. - * + * * @param info contains information about the assertion. * @param actual the given object. * @param other the object to compare {@code actual} to. @@ -679,7 +678,7 @@ private Object getFieldOrPropertyValue(A a, Field field) { /** * Returns the declared fields of given class and its superclasses stopping at superclass in java.lang * package whose fields are not included. - * + * * @param clazz the class we want the declared fields. * @return the declared fields of given class and its superclasses. */ @@ -697,7 +696,7 @@ private static Set getDeclaredFieldsIncludingInherited(Class clazz) { /** * Verifies that other object is an instance of the given type. - * + * * @param info contains information about the assertion. * @param other the object to check type against given class. * @param clazz the type to check the given object against. diff --git a/src/main/java/org/assertj/core/internal/Strings.java b/src/main/java/org/assertj/core/internal/Strings.java index 6942336d78..3258bb7256 100644 --- a/src/main/java/org/assertj/core/internal/Strings.java +++ b/src/main/java/org/assertj/core/internal/Strings.java @@ -42,7 +42,6 @@ import java.util.regex.PatternSyntaxException; import org.assertj.core.api.AssertionInfo; -import org.assertj.core.error.ShouldBeEqual; import org.assertj.core.util.VisibleForTesting; /** @@ -515,6 +514,7 @@ public void assertXmlEqualsTo(AssertionInfo info, CharSequence actualXml, CharSe final String formattedActualXml = xmlPrettyFormat(actualXml.toString()); final String formattedExpectedXml = xmlPrettyFormat(expectedXml.toString()); if (!comparisonStrategy.areEqual(formattedActualXml, formattedExpectedXml)) - throw failures.failure(info, shouldBeEqual(formattedActualXml, formattedExpectedXml, comparisonStrategy)); + throw failures.failure(info, shouldBeEqual(formattedActualXml, formattedExpectedXml, comparisonStrategy, + info.representation())); } } diff --git a/src/main/java/org/assertj/core/presentation/BinaryRepresentation.java b/src/main/java/org/assertj/core/presentation/BinaryRepresentation.java new file mode 100644 index 0000000000..e99d314924 --- /dev/null +++ b/src/main/java/org/assertj/core/presentation/BinaryRepresentation.java @@ -0,0 +1,113 @@ +/* + * Created on Dec 21, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.presentation; + +import java.util.Calendar; +import java.util.Date; + +import static org.assertj.core.util.Strings.concat; + +/** + * Binary object representation instead of standard java representation. + * + * @author Mariusz Smykula + */ +public class BinaryRepresentation implements Representation { + + public static final String BYTE_PREFIX = "0b"; + + /** + * Returns binary the {@code toString} representation of the given object. It may or not the object's own + * implementation of {@code toString}. + * + * @param object the given object. + * @return the {@code toString} representation of the given object. + */ + @Override + public String toStringOf(Object object) { + if (object instanceof Character) { + return toStringOf((Character) object); + } else if (object instanceof Number) { + return toStringOf((Number) object); + } else if (object instanceof String) { + return toStringOf(this, (String) object); + } else if (object instanceof Date || object instanceof Calendar) { + return objectToString(this, object); + } + return object == null ? null : CollectionToString.toStringOf(this, object); + } + + private static String toStringOf(Representation representation, String s) { + return concat("\"", representation.toStringOf(s.toCharArray()), "\""); + } + + private static String toStringOf(Number number) { + if (number instanceof Byte) { + return toStringOf((Byte) number); + } else if (number instanceof Short) { + return toStringOf((Short) number); + } else if (number instanceof Integer) { + return toStringOf((Integer) number); + } else if (number instanceof Long) { + return toStringOf((Long) number); + } else if (number instanceof Float) { + return toStringOf((Float) number); + } else if (number instanceof Double) { + return toStringOf((Double) number); + } + return number == null ? null : number.toString(); + } + + private static String objectToString(Representation representation, Object object) { + return ObjectToString.toStringOf(representation, object); + } + + private static String toStringOf(Byte b) { + return toGroupedBinary(Integer.toBinaryString(b & 0xFF), 8); + } + + private static String toStringOf(Short s) { + return toGroupedBinary(Integer.toBinaryString(s & 0xFFFF), 16); + } + + private static String toStringOf(Integer i) { + return toGroupedBinary(Integer.toBinaryString(i), 32); + } + + private static String toStringOf(Long l) { + return toGroupedBinary(Long.toBinaryString(l), 64); + } + + private static String toStringOf(Float f) { + return toGroupedBinary(Integer.toBinaryString(Float.floatToIntBits(f)), 32); + } + + private static String toStringOf(Double d) { + return toGroupedBinary(Long.toBinaryString(Double.doubleToRawLongBits(d)), 64); + } + + private static String toStringOf(Character character) { + return concat("'", toStringOf((short) (int) character), "'"); + } + + private static String toGroupedBinary(String value, int size) { + return BYTE_PREFIX + NumberGrouping.toBinaryLiteral(toBinary(value, size)); + } + + private static String toBinary(String value, int size) { + return String.format("%" + size + "s", value).replace(' ', '0'); + } + +} diff --git a/src/main/java/org/assertj/core/presentation/CollectionToString.java b/src/main/java/org/assertj/core/presentation/CollectionToString.java new file mode 100644 index 0000000000..abbb8bc3b8 --- /dev/null +++ b/src/main/java/org/assertj/core/presentation/CollectionToString.java @@ -0,0 +1,75 @@ +/* + * Created on Oct 7, 2009 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2012 the original author or authors. + */ +package org.assertj.core.presentation; + +import org.assertj.core.groups.Tuple; +import org.assertj.core.util.*; +import org.assertj.core.util.Collections; + +import static org.assertj.core.util.Arrays.isArray; + +import java.util.*; +import java.util.Arrays; + +/** + * Obtains the {@code toString} representation of an collection. + * + * @author Alex Ruiz + * @author Joel Costigliola + * @author Yvonne Wang + * @author Mariusz Smykula + */ +final class CollectionToString { + + /** + * Returns the {@code toString} representation of the given collection. It may or not the object's own implementation + * of {@code toString}. + * + * @param o the given object. + * @return the {@code toString} representation of the given object. + */ + public static String toStringOf(Representation representation, Object o) { + if (isArray(o)) { + return org.assertj.core.util.Arrays.format(representation, o); + } else if (o instanceof Collection) { + return toStringOf((Collection) o, representation); + } else if (o instanceof Map) { + return toStringOf((Map) o, representation); + } else if (o instanceof Tuple) { + return toStringOf((Tuple) o, representation); + } + return defaultToString(o); + } + + private static String toStringOf(Collection c, Representation p) { + return org.assertj.core.util.Collections.format(p, c); + } + + private static String toStringOf(Map m, Representation p) { + return Maps.format(p, m); + } + + private static String toStringOf(Tuple tuple, Representation representation) { + return Collections.format(representation, Arrays.asList(tuple.toArray()), "(", ")"); + } + + private static String defaultToString(Object o) { + return o == null ? null : o.toString(); + } + + private CollectionToString() { + + } +} diff --git a/src/main/java/org/assertj/core/presentation/HexadecimalRepresentation.java b/src/main/java/org/assertj/core/presentation/HexadecimalRepresentation.java new file mode 100644 index 0000000000..b7ae5d4539 --- /dev/null +++ b/src/main/java/org/assertj/core/presentation/HexadecimalRepresentation.java @@ -0,0 +1,114 @@ +/* + * Created on Dec 21, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.presentation; + +import java.util.Calendar; +import java.util.Date; + +import static org.assertj.core.util.Strings.concat; + +/** + * Hexadecimal object representation instead of standard java representation. + * + * @author Mariusz Smykula + */ +public class HexadecimalRepresentation implements Representation { + + public static final String PREFIX = "0x"; + public static final int NIBBLE_SIZE = 4; + + /** + * Returns hexadecimal the {@code toString} representation of the given object. It may or not the object's own + * implementation of {@code toString}. + * + * @param object the given object. + * @return the {@code toString} representation of the given object. + */ + @Override + public String toStringOf(Object object) { + if (object instanceof Number) { + return toStringOf((Number) object); + } else if (object instanceof String) { + return toStringOf(this, (String) object); + } else if (object instanceof Character) { + return toStringOf((Character) object); + } else if (object instanceof Date || object instanceof Calendar) { + return objectToString(this, object); + } + return object == null ? null : CollectionToString.toStringOf(this, object); + } + + private static String objectToString(Representation representation, Object object) { + return ObjectToString.toStringOf(representation, object); + } + + private static String toStringOf(Number number) { + if (number instanceof Byte) { + return toStringOf((Byte) number); + } else if (number instanceof Short) { + return toStringOf((Short) number); + } else if (number instanceof Integer) { + return toStringOf((Integer) number); + } else if (number instanceof Long) { + return toStringOf((Long) number); + } else if (number instanceof Float) { + return toStringOf((Float) number); + } else if (number instanceof Double) { + return toStringOf((Double) number); + } + return number == null ? null : number.toString(); + } + + private static String toStringOf(Byte b) { + return toGroupedHex(b, 8); + } + + private static String toStringOf(Short s) { + return toGroupedHex(s, 16); + } + + private static String toStringOf(Integer i) { + return toGroupedHex(i, 32); + } + + private static String toStringOf(Long l) { + return toGroupedHex(l, 64); + } + + private static String toStringOf(Float f) { + return toGroupedHex(Float.floatToIntBits(f), 32); + } + + private static String toStringOf(Double d) { + return toGroupedHex(Double.doubleToRawLongBits(d), 64); + } + + private static String toStringOf(Character character) { + return concat("'", toStringOf((short) (int) character), "'"); + } + + private static String toStringOf(Representation representation, String s) { + return concat("\"", representation.toStringOf(s.toCharArray()), "\""); + } + + private static String toGroupedHex(Number value, int size) { + return PREFIX + NumberGrouping.toHexLiteral(toHex(value, size)); + } + + private static String toHex(Number value, int sizeInBits) { + return String.format("%0" + sizeInBits / NIBBLE_SIZE + "X", value); + } + +} diff --git a/src/main/java/org/assertj/core/presentation/NumberGrouping.java b/src/main/java/org/assertj/core/presentation/NumberGrouping.java new file mode 100644 index 0000000000..58cf01fe3b --- /dev/null +++ b/src/main/java/org/assertj/core/presentation/NumberGrouping.java @@ -0,0 +1,63 @@ +/* + * Created on Dec 28, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.presentation; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author Mariusz Smykula + */ +final class NumberGrouping { + + private static final String UNDERSCORE_SEPARATOR = "_"; + private static Pattern hexGroupPattern = Pattern.compile("([0-9|A-Z]{4})"); + private static Pattern binaryGroupPattern = Pattern.compile("([0-1]{8})"); + + static String toHexLiteral(String value) { + if (value.length() > 4) { + return toHexLiteral(hexGroupPattern, value); + } else { + return value; + } + } + + static String toBinaryLiteral(String value) { + return toHexLiteral(binaryGroupPattern, value); + } + + private static String toHexLiteral(Pattern pattern, String value) { + + Matcher matcher = pattern.matcher(value); + StringBuilder literalBuilder = new StringBuilder(); + while (matcher.find()) { + String byteGroup = matcher.group(1); + if (notEmpty(literalBuilder)) { + literalBuilder.append(UNDERSCORE_SEPARATOR); + } + literalBuilder.append(byteGroup); + } + + return literalBuilder.toString(); + } + + private static boolean notEmpty(StringBuilder sb) { + return sb.length() != 0; + } + + private NumberGrouping() { + } + +} \ No newline at end of file diff --git a/src/main/java/org/assertj/core/presentation/ObjectToString.java b/src/main/java/org/assertj/core/presentation/ObjectToString.java new file mode 100644 index 0000000000..efded82f56 --- /dev/null +++ b/src/main/java/org/assertj/core/presentation/ObjectToString.java @@ -0,0 +1,37 @@ +/* + * Created on Dec 28, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2012 the original author or authors. + */ +package org.assertj.core.presentation; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; + +/** + * @author Mariusz Smykula + */ +public class ObjectToString { + static String toStringOf(Representation representation, Object object) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos; + try { + oos = new ObjectOutputStream(baos); + oos.writeObject(object); + } catch (IOException e) { + // silent exception + } + + return CollectionToString.toStringOf(representation, baos.toByteArray()); + } +} diff --git a/src/main/java/org/assertj/core/presentation/Representation.java b/src/main/java/org/assertj/core/presentation/Representation.java new file mode 100644 index 0000000000..c3036b0b15 --- /dev/null +++ b/src/main/java/org/assertj/core/presentation/Representation.java @@ -0,0 +1,31 @@ +/* + * Created on Dec 21, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2012 the original author or authors. + */ +package org.assertj.core.presentation; + +/** + * @author Mariusz Smykula + */ +public interface Representation { + + /** + * Returns the {@code toString} representation of the given object. It may or not the object's own implementation of + * {@code toString}. + * + * @param object the given object. + * @return the {@code toString} representation of the given object. + */ + String toStringOf(Object object); + +} diff --git a/src/main/java/org/assertj/core/presentation/StandardRepresentation.java b/src/main/java/org/assertj/core/presentation/StandardRepresentation.java new file mode 100644 index 0000000000..d75d854096 --- /dev/null +++ b/src/main/java/org/assertj/core/presentation/StandardRepresentation.java @@ -0,0 +1,130 @@ +/* + * Created on Dec 21, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2012 the original author or authors. + */ +package org.assertj.core.presentation; + +import org.assertj.core.groups.Tuple; +import org.assertj.core.util.Collections; +import org.assertj.core.util.Dates; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Comparator; +import java.util.Date; + +import static org.assertj.core.util.Strings.concat; +import static org.assertj.core.util.Strings.quote; + +/** + * Standard java object representation.. + * + * @author Mariusz Smykula + */ +public class StandardRepresentation implements Representation { + + /** + * Returns standard the {@code toString} representation of the given object. It may or not the object's own + * implementation of {@code toString}. + * + * @param object the given object. + * @return the {@code toString} representation of the given object. + */ + @Override + public String toStringOf(Object object) { + if (object instanceof Calendar) { + return toStringOf((Calendar) object); + } else if (object instanceof Class) { + return toStringOf((Class) object); + } else if (object instanceof Date) { + return toStringOf((Date) object); + } else if (object instanceof Number) { + return toStringOf((Number) object, this); + } else if (object instanceof File) { + return toStringOf((File) object); + } else if (object instanceof String) { + return toStringOf((String) object); + } else if (object instanceof Character) { + return toStringOf((Character) object); + } else if (object instanceof Comparator) { + return toStringOf((Comparator) object); + } else if (object instanceof SimpleDateFormat) { + return toStringOf((SimpleDateFormat) object); + } else if (object instanceof Tuple) { + return toStringOf((Tuple) object, this); + } + return defaultToString(object, this); + } + + private static String toStringOf(Number number, Representation representation) { + if (number instanceof Float) { + return toStringOf((Float) number); + } + if (number instanceof Long) { + return toStringOf((Long) number); + } + return defaultToString(number, representation); + } + + private static String toStringOf(Comparator comparator) { + String comparatorSimpleClassName = comparator.getClass().getSimpleName(); + return quote(!comparatorSimpleClassName.isEmpty() ? comparatorSimpleClassName : "Anonymous Comparator class"); + } + + private static String toStringOf(Calendar c) { + return Dates.formatAsDatetime(c); + } + + private static String toStringOf(Class c) { + return c.getCanonicalName(); + } + + private static String toStringOf(String s) { + return concat("\"", s, "\""); + } + + private static String toStringOf(Character c) { + return concat("'", c, "'"); + } + + private static String toStringOf(Date d) { + return Dates.formatAsDatetime(d); + } + + private static String toStringOf(Float f) { + return String.format("%sf", f); + } + + private static String toStringOf(Long l) { + return String.format("%sL", l); + } + + private static String toStringOf(File f) { + return f.getAbsolutePath(); + } + + private static String toStringOf(SimpleDateFormat dateFormat) { + return dateFormat.toPattern(); + } + + private static String toStringOf(Tuple tuple, Representation representation) { + return Collections.format(representation, Arrays.asList(tuple.toArray()), "(", ")"); + } + + private static String defaultToString(Object object, Representation representation) { + return object == null ? null : CollectionToString.toStringOf(representation, object); + } + +} diff --git a/src/main/java/org/assertj/core/presentation/UnicodeRepresentation.java b/src/main/java/org/assertj/core/presentation/UnicodeRepresentation.java new file mode 100644 index 0000000000..e3b3170403 --- /dev/null +++ b/src/main/java/org/assertj/core/presentation/UnicodeRepresentation.java @@ -0,0 +1,66 @@ +/* + * Created on Dec 21, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.presentation; + +import java.util.Formatter; + +/** + * Unicode object representation instead of standard java representation. + * + * @author Mariusz Smykula + */ +public class UnicodeRepresentation implements Representation { + + + /** + * Returns hexadecimal the {@code toString} representation of the given String or Character. + * + * @param object the given object. + * @return the {@code toString} representation of the given object. + */ + @Override + public String toStringOf(Object object) { + if (object instanceof String) { + return toStringOf((String) object); + } + if (object instanceof Character) { + return toStringOf((Character) object); + } + + return object == null ? null : CollectionToString.toStringOf(this, object); + } + + private String toStringOf(Character string) { + return escapeUnicode(string.toString()); + } + + private String toStringOf(String string) { + return escapeUnicode(string); + } + + private String escapeUnicode(String input) { + StringBuilder b = new StringBuilder(input.length()); + Formatter f = new Formatter(b); + for (char c : input.toCharArray()) { + if (c < 128) { + b.append(c); + } else { + f.format("\\u%04x", (int) c); + } + } + return b.toString(); + } + +} diff --git a/src/main/java/org/assertj/core/util/ArrayFormatter.java b/src/main/java/org/assertj/core/util/ArrayFormatter.java index d1a09e568c..20f21813cb 100644 --- a/src/main/java/org/assertj/core/util/ArrayFormatter.java +++ b/src/main/java/org/assertj/core/util/ArrayFormatter.java @@ -14,9 +14,10 @@ */ package org.assertj.core.util; +import org.assertj.core.presentation.Representation; + import static java.lang.reflect.Array.getLength; import static org.assertj.core.util.Arrays.isArray; -import static org.assertj.core.util.ToString.toStringOf; import java.lang.reflect.Array; import java.util.HashSet; @@ -31,25 +32,25 @@ final class ArrayFormatter { private static final String NULL = "null"; - String format(Object o) { + String format(Representation p, Object o) { if (!isArray(o)) { return null; } - return isObjectArray(o) ? formatObjectArray(o) : formatPrimitiveArray(o); + return isObjectArray(o) ? formatObjectArray(p, o) : formatPrimitiveArray(p, o); } - private String formatObjectArray(Object o) { + private String formatObjectArray(Representation p, Object o) { Object[] array = (Object[]) o; int size = array.length; if (size == 0) { return "[]"; } StringBuilder buffer = new StringBuilder((20 * (size - 1))); - deepToString(array, buffer, new HashSet()); + deepToString(p, array, buffer, new HashSet()); return buffer.toString(); } - private void deepToString(Object[] array, StringBuilder buffer, Set alreadyFormatted) { + private void deepToString(Representation p, Object[] array, StringBuilder buffer, Set alreadyFormatted) { if (array == null) { buffer.append(NULL); return; @@ -63,18 +64,18 @@ private void deepToString(Object[] array, StringBuilder buffer, Set al } Object element = array[i]; if (!isArray(element)) { - buffer.append(element == null ? NULL : toStringOf(element)); + buffer.append(element == null ? NULL : p.toStringOf(element)); continue; } if (!isObjectArray(element)) { - buffer.append(formatPrimitiveArray(element)); + buffer.append(formatPrimitiveArray(p, element)); continue; } if (alreadyFormatted.contains(element)) { buffer.append("[...]"); continue; } - deepToString((Object[]) element, buffer, alreadyFormatted); + deepToString(p, (Object[]) element, buffer, alreadyFormatted); } buffer.append(']'); alreadyFormatted.remove(array); @@ -84,7 +85,7 @@ private boolean isObjectArray(Object o) { return isArray(o) && !isArrayTypePrimitive(o); } - private String formatPrimitiveArray(Object o) { + private String formatPrimitiveArray(Representation p, Object o) { if (!isArray(o)) { return null; } @@ -97,11 +98,11 @@ private String formatPrimitiveArray(Object o) { } StringBuilder buffer = new StringBuilder(); buffer.append('['); - buffer.append(toStringOf(Array.get(o, 0))); + buffer.append(p.toStringOf(Array.get(o, 0))); for (int i = 1; i < size; i++) { Object element = Array.get(o, i); buffer.append(", "); - buffer.append(toStringOf(element)); + buffer.append(p.toStringOf(element)); } buffer.append("]"); return buffer.toString(); diff --git a/src/main/java/org/assertj/core/util/Arrays.java b/src/main/java/org/assertj/core/util/Arrays.java index 028d15d0ee..5e15fada92 100644 --- a/src/main/java/org/assertj/core/util/Arrays.java +++ b/src/main/java/org/assertj/core/util/Arrays.java @@ -14,6 +14,8 @@ */ package org.assertj.core.util; +import org.assertj.core.presentation.Representation; + import static java.util.Collections.emptyList; import static org.assertj.core.util.Preconditions.checkNotNull; @@ -63,12 +65,13 @@ public static T[] array(T... values) { /** * Returns the {@code String} representation of the given array, or {@code null} if the given object is either * {@code null} or not an array. This method supports arrays having other arrays as elements. - * + * + * @param representation * @param array the object that is expected to be an array. * @return the {@code String} representation of the given array. */ - public static String format(Object array) { - return FORMATTER.format(array); + public static String format(Representation representation, Object array) { + return FORMATTER.format(representation, array); } /** diff --git a/src/main/java/org/assertj/core/util/Collections.java b/src/main/java/org/assertj/core/util/Collections.java index dbcbf71ce8..f6a631168a 100644 --- a/src/main/java/org/assertj/core/util/Collections.java +++ b/src/main/java/org/assertj/core/util/Collections.java @@ -14,8 +14,9 @@ */ package org.assertj.core.util; +import org.assertj.core.presentation.Representation; + import static java.util.Collections.emptyList; -import static org.assertj.core.util.ToString.toStringOf; import java.util.ArrayList; import java.util.Collection; @@ -74,21 +75,25 @@ public static boolean isNullOrEmpty(Collection c) { * Returns the {@code String} representation of the given {@code Collection}, or {@code null} if the given * {@code Collection} is {@code null}. * + * + * @param p * @param c the {@code Collection} to format. * @return the {@code String} representation of the given {@code Collection}. */ - public static String format(Collection c) { - return format(c, DEFAULT_START, DEFAULT_END); + public static String format(Representation p, Collection c) { + return format(p, c, DEFAULT_START, DEFAULT_END); } /** * Returns the {@code String} representation of the given {@code Collection}, or {@code null} if the given * {@code Collection} is {@code null}. * + * + * @param p * @param c the {@code Collection} to format. * @return the {@code String} representation of the given {@code Collection}. */ - public static String format(Collection c, String start, String end) { + public static String format(Representation p, Collection c, String start, String end) { if (c == null) { return null; } @@ -100,14 +105,15 @@ public static String format(Collection c, String start, String end) { b.append(start); for (;;) { Object e = i.next(); - b.append(e == c ? "(this Collection)" : toStringOf(e)); + b.append(e == c ? "(this Collection)" : p.toStringOf(e)); if (!i.hasNext()) { return b.append(end).toString(); } b.append(", "); } } - + + /** * Returns all the non-{@code null} elements in the given {@link Collection}. * diff --git a/src/main/java/org/assertj/core/util/Hexadecimals.java b/src/main/java/org/assertj/core/util/Hexadecimals.java new file mode 100644 index 0000000000..ce7656ae25 --- /dev/null +++ b/src/main/java/org/assertj/core/util/Hexadecimals.java @@ -0,0 +1,33 @@ +/* + * Created on Dec 20, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.util; + +/** + * @author Mariusz Smykula + */ +public class Hexadecimals { + + protected static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray(); + + public static String byteToHexString(Byte b) { + int v = b & 0xFF; + return new String(new char[]{HEX_ARRAY[v >>> 4], HEX_ARRAY[v & 0x0F]}); + } + + private Hexadecimals() { + + } + +} diff --git a/src/main/java/org/assertj/core/util/Maps.java b/src/main/java/org/assertj/core/util/Maps.java index d7dec4ae96..17f1a65fdc 100644 --- a/src/main/java/org/assertj/core/util/Maps.java +++ b/src/main/java/org/assertj/core/util/Maps.java @@ -14,7 +14,7 @@ */ package org.assertj.core.util; -import static org.assertj.core.util.ToString.toStringOf; +import org.assertj.core.presentation.Representation; import java.util.Iterator; import java.util.Map; @@ -43,7 +43,7 @@ public static boolean isNullOrEmpty(Map map) { * @param map the map to format. * @return the {@code String} representation of the given map. */ - public static String format(Map map) { + public static String format(Representation p, Map map) { if (map == null) { return null; } @@ -55,9 +55,9 @@ public static String format(Map map) { buffer.append("{"); for (;;) { Entry e = (Entry) i.next(); - buffer.append(format(map, e.getKey())); + buffer.append(format(map, e.getKey(), p)); buffer.append('='); - buffer.append(format(map, e.getValue())); + buffer.append(format(map, e.getValue(), p)); if (!i.hasNext()) { return buffer.append("}").toString(); } @@ -65,8 +65,8 @@ public static String format(Map map) { } } - private static Object format(Map map, Object o) { - return o == map ? "(this Map)" : toStringOf(o); + private static Object format(Map map, Object o, Representation p) { + return o == map ? "(this Map)" : p.toStringOf(o); } private Maps() {} diff --git a/src/main/java/org/assertj/core/util/ToString.java b/src/main/java/org/assertj/core/util/ToString.java deleted file mode 100644 index db12bf48ff..0000000000 --- a/src/main/java/org/assertj/core/util/ToString.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Created on Oct 7, 2009 - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * Copyright @2009-2012 the original author or authors. - */ -package org.assertj.core.util; - -import static org.assertj.core.util.Arrays.isArray; -import static org.assertj.core.util.Strings.concat; -import static org.assertj.core.util.Strings.quote; - -import java.io.File; -import java.text.SimpleDateFormat; -import java.util.*; - -/** - * Obtains the {@code toString} representation of an object. - * - * @author Alex Ruiz - * @author Joel Costigliola - * @author Yvonne Wang - */ -public final class ToString { - - final protected static char[] hexArray = "0123456789ABCDEF".toCharArray(); - - /** - * Returns the {@code toString} representation of the given object. It may or not the object's own implementation of - * {@code toString}. - * - * @param o the given object. - * @return the {@code toString} representation of the given object. - */ - public static String toStringOf(Object o) { - if (isArray(o)) { - return Arrays.format(o); - } - if (o instanceof Calendar) { - return toStringOf((Calendar) o); - } - if (o instanceof Class) { - return toStringOf((Class) o); - } - if (o instanceof Collection) { - return toStringOf((Collection) o); - } - if (o instanceof Date) { - return toStringOf((Date) o); - } - if (o instanceof Byte) { - return toStringOf((Byte) o); - } - if (o instanceof Float) { - return toStringOf((Float) o); - } - if (o instanceof Long) { - return toStringOf((Long) o); - } - if (o instanceof File) { - return toStringOf((File) o); - } - if (o instanceof Map) { - return toStringOf((Map) o); - } - if (o instanceof String) { - return toStringOf((String) o); - } - if (o instanceof Character) { - return toStringOf((Character) o); - } - if (o instanceof Comparator) { - return toStringOf((Comparator) o); - } - if (o instanceof SimpleDateFormat) { - return toStringOf((SimpleDateFormat) o); - } - return o == null ? null : o.toString(); - } - private static String toStringOf(Comparator comparator) { - String comparatorSimpleClassName = comparator.getClass().getSimpleName(); - return quote(!comparatorSimpleClassName.isEmpty() ? comparatorSimpleClassName : "Anonymous Comparator class"); - } - - private static String toStringOf(Calendar c) { - return Dates.formatAsDatetime(c); - } - - private static String toStringOf(Class c) { - return c.getCanonicalName(); - } - - private static String toStringOf(String s) { - return concat("\"", s, "\""); - } - - private static String toStringOf(Character c) { - return concat("'", c, "'"); - } - - private static String toStringOf(Collection c) { - return Collections.format(c); - } - - private static String toStringOf(Date d) { - return Dates.formatAsDatetime(d); - } - - private static String toStringOf(Float f) { - return String.format("%sf", f); - } - - private static String toStringOf(Long l) { - return String.format("%sL", l); - } - - private static String toStringOf(File f) { - return f.getAbsolutePath(); - } - - private static String toStringOf(Map m) { - return Maps.format(m); - } - - private static String toStringOf(SimpleDateFormat dateFormat) { - return dateFormat.toPattern(); - } - - private static String toStringOf(Byte b) { - return "0x" + byteToStringHex(b); - } - - private static String byteToStringHex(Byte b) { - int v = b & 0xFF; - return new String(new char[]{hexArray[v >>> 4], hexArray[v & 0x0F]}); - } - - private ToString() {} -} diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_asBinary_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_asBinary_Test.java new file mode 100644 index 0000000000..814d2c8d61 --- /dev/null +++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_asBinary_Test.java @@ -0,0 +1,125 @@ +/* + * Created on Dec 21, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.api; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.test.ExpectedException.none; + +import org.assertj.core.test.ExpectedException; +import org.junit.Rule; +import org.junit.Test; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Tests for {@link org.assertj.core.presentation.BinaryRepresentation#toStringOf(Object)}. + * + * @author Mariusz Smykula + */ +public class Assertions_assertThat_asBinary_Test { + + @Rule + public ExpectedException thrown = none(); + + @Test + public void should_assert_byte_as_binary() { + thrown.expectMessage("expected:<0b0000001[1]> but was:<0b0000001[0]>"); + assertThat((byte) 2).asBinary().isEqualTo((byte) 3); + } + + @Test + public void should_assert_signed_byte_as_binary() { + thrown.expectMessage("expected:<0b[00000011]> but was:<0b[11111110]>"); + assertThat((byte) -2).asBinary().isEqualTo((byte) 3); + } + + @Test + public void should_assert_bytes_as_binary() { + thrown.expectMessage("expected:<[0b000000[0]1]> but was:<[0b000000[10, 0b0000001]1]>"); + assertThat(new byte[]{2, 3}).asBinary().isEqualTo(new byte[]{1}); + } + + @Test + public void should_assert_short_as_binary() { + thrown.expectMessage("expected:<0b00000000_0000001[1]> but was:<0b00000000_0000001[0]>"); + assertThat((short) 2).asBinary().isEqualTo((short) 3); + } + + @Test + public void should_assert_signed_short_as_binary() { + thrown.expectMessage("expected:<0b[00000000_000000]11> but was:<0b[11111111_111111]11>"); + assertThat((short) -1).asBinary().isEqualTo((short) 3); + } + + @Test + public void should_assert_integer_as_binary() { + thrown.expectMessage("expected:<...000_00000000_0000001[1]> but was:<...000_00000000_0000001[0]>"); + assertThat(2).asBinary().isEqualTo(3); + } + + @Test + public void should_assert_negative_integer_as_binary() { + thrown.expectMessage( + "expected:<0b[11111111_11111111_11111111_1111110]1> but was:<0b[00000000_00000000_00000000_0000001]1>"); + assertThat(3).asBinary().isEqualTo(-3); + } + + @Test + public void should_assert_long_as_binary() { + thrown.expectMessage("expected:<...000_00000000_0000001[1]> but was:<...000_00000000_0000001[0]>"); + assertThat((long) 2).asBinary().isEqualTo((long) 3); + } + + @Test + public void should_assert_negative_long_as_binary() { + thrown.expectMessage("expected:<0b[00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000011]> " + + "but was:<0b[11111111_11111111_11111111_11111111_11111111_11111111_11111111_11111110]>"); + assertThat((long) -2).asBinary().isEqualTo((long) 3); + } + + @Test + public void should_assert_float_as_binary() { + thrown.expectMessage( + "expected:<0b01000000_0[1000000_00000000_0000000]0> but was:<0b01000000_0[0000110_01100110_0110011]0>"); + assertThat(2.1f).asBinary().isEqualTo(3f); + } + + @Test + public void should_assert_double_as_binary() { + thrown.expectMessage("expected:<0b01000000_0000[1000_00000000_00000000_00000000_00000000_00000000_00000000]> " + + "but was:<0b01000000_0000[0000_11001100_11001100_11001100_11001100_11001100_11001101]>"); + assertThat(2.1d).asBinary().isEqualTo(3d); + } + + @Test + public void should_assert_String_as_binary() { + thrown.expectMessage( + "expected:<...0001', '0b00000000_0[01101]10']\"> but was:<...0001', '0b00000000_0[11000]10']\">"); + assertThat("ab").asBinary().isEqualTo("a6"); + } + + @Test + public void should_assert_Date_as_hex() throws ParseException { + thrown.expectMessage("expected:<...000, 0b00000000, 0b1[1001011, 0b00100111, 0b11010001, 0b011]10111, 0b00000000, 0...> " + + "but was:<...000, 0b00000000, 0b1[0110101, 0b00011011, 0b10010111, 0b100]10111, 0b00000000, 0...>"); + assertThat(toDate("26/08/1994")).asBinary().isEqualTo(toDate("26/08/1997")); + } + + private Date toDate(String source) throws ParseException { + return new SimpleDateFormat("dd/MM/yyyy").parse(source); + } +} diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_asHexadecimal_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_asHexadecimal_Test.java new file mode 100644 index 0000000000..cd901b5053 --- /dev/null +++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_asHexadecimal_Test.java @@ -0,0 +1,167 @@ +/* + * Created on Dec 21, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.api; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.test.ExpectedException.none; + +import org.assertj.core.test.ExpectedException; +import org.junit.Rule; +import org.junit.Test; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; + +/** + * Tests for {@link org.assertj.core.presentation.HexadecimalRepresentation#toStringOf(Object)}. + * + * @author Mariusz Smykula + */ +public class Assertions_assertThat_asHexadecimal_Test { + + @Rule + public ExpectedException thrown = none(); + + @Test + public void should_assert_byte_as_hexadecimal() { + thrown.expectMessage("expected:<0x0[3]> but was:<0x0[2]>"); + assertThat((byte) 2).asHexadecimal().isEqualTo((byte) 3); + } + + @Test + public void should_assert_signed_byte_as_hexadecimal() { + thrown.expectMessage("expected:<0x[03]> but was:<0x[FE]>"); + assertThat((byte) -2).asHexadecimal().isEqualTo((byte) 3); + } + + @Test + public void should_assert_bytes_as_hexadecimal() { + thrown.expectMessage("expected:<[0x0[1]]> but was:<[0x0[2, 0x03]]>"); + assertThat(new byte[]{2, 3}).asHexadecimal().isEqualTo(new byte[]{1}); + } + + @Test + public void should_assert_bytes_contains_as_hexadecimal() { + thrown.expectMessage("Expecting:\n" + + " <[0x02, 0x03]>\n" + + "to contain:\n" + + " <[0x01]>\n" + + "but could not find:\n" + + " <[0x01]>"); + assertThat(new byte[]{2, 3}).asHexadecimal().contains(new byte[]{1}); + } + + @Test + public void should_assert_short_as_hexadecimal() { + thrown.expectMessage("expected:<0x000[3]> but was:<0x000[2]>"); + assertThat((short) 2).asHexadecimal().isEqualTo((short) 3); + } + + @Test + public void should_assert_signed_short_as_hexadecimal() { + thrown.expectMessage("expected:<0x[0003]> but was:<0x[FFFE]>"); + assertThat((short) -2).asHexadecimal().isEqualTo((short) 3); + } + + @Test + public void should_assert_shorts_as_hexadecimal() { + thrown.expectMessage("expected:<[0x000[3]]> but was:<[0x000[1, 0x0002]]>"); + assertThat(new short[]{(short) 1, (short) 2}).asHexadecimal().isEqualTo(new short[]{(short) 3}); + } + + @Test + public void should_assert_integer_as_hexadecimal() { + thrown.expectMessage("expected:<0x0000_000[3]> but was:<0x0000_000[2]>"); + assertThat(2).asHexadecimal().isEqualTo(3); + } + + @Test + public void should_assert_integers_as_hexadecimal() { + thrown.expectMessage("expected:<[0x0000_000[]2]> but was:<[0x0000_000[1, 0x0000_000]2]>"); + assertThat(new int[]{1, 2}).asHexadecimal().isEqualTo(new int[]{2}); + } + + @Test + public void should_assert_long_as_hexadecimal() { + thrown.expectMessage("expected:<0x[8000_0000_0000_0000]> but was:<0x[7FFF_FFFF_FFFF_FFFF]>"); + assertThat(Long.MAX_VALUE).asHexadecimal().isEqualTo(Long.MIN_VALUE); + } + + @Test + public void should_assert_signed_long_as_hexadecimal() { + thrown.expectMessage("expected:<0x[0000_0000_0000_0002]> but was:<0x[FFFF_FFFF_FFFF_FFFE]>"); + assertThat(-2L).asHexadecimal().isEqualTo(2L); + } + + @Test + public void should_assert_longs_as_hexadecimal() { + thrown.expectMessage("expected:<[0x[0000_0000_0000_0003]]> but was:<[0x[FFFF_FFFF_FFFF_FFFF, 0x0000_0000_0000_0002]]>"); + assertThat(new long[]{-1L, 2L}).asHexadecimal().isEqualTo(new long[]{3L}); + } + + @Test + public void should_assert_float_as_hexadecimal() { + thrown.expectMessage("expected:<0x40[13_3333]> but was:<0x40[89_999A]>"); + assertThat(4.3f).asHexadecimal().isEqualTo(2.3f); + } + + @Test + public void should_assert_floats_as_hexadecimal() { + thrown.expectMessage("expected:<[0x408[3_3333]]> but was:<[0x408[9_999A, 0xC000_0000]]>"); + assertThat(new float[]{4.3f, -2f}).asHexadecimal().isEqualTo(new float[]{4.1f}); + } + + @Test + public void should_assert_double_as_hexadecimal() { + thrown.expectMessage("expected:<0x40[02_6666_6666_6666]> but was:<0x40[11_3333_3333_3333]>"); + assertThat(4.3d).asHexadecimal().isEqualTo(2.3d); + } + + @Test + public void should_assert_doubles_as_hexadecimal() { + thrown.expectMessage("expected:<[0x[4008]_0000_0000_0000]> but was:<[0x[3FF0_0000_0000_0000, 0x4000]_0000_0000_0000]>"); + assertThat(new double[]{1d, 2d}).asHexadecimal().isEqualTo(new double[]{3d}); + } + + @Test + public void should_assert_collections_as_hexadecimal() { + thrown.expectMessage("expected:<[0x0000_000[3]]> but was:<[0x0000_000[1, 0x0000_0002]]>"); + assertThat(Arrays.asList(1, 2)).asHexadecimal().isEqualTo(Arrays.asList(3)); + } + + @Test + public void should_assert_Character_as_hexadecimal() { + thrown.expectMessage("expected:<'0x006[2]'> but was:<'0x006[1]'>"); + assertThat('a').asHexadecimal().isEqualTo('b'); + } + + @Test + public void should_assert_String_as_hexadecimal() { + thrown.expectMessage("expected:<\"['0x0061', '0x00[62]', '0x0063']\"> but was:<\"['0x0061', '0x00[36]', '0x0063']\">"); + assertThat("a6c").asHexadecimal().isEqualTo("abc"); + } + + @Test + public void should_assert_Date_as_hexadecimal() throws ParseException { + thrown.expectMessage("expected:<...0x00, 0x00, 0x00, 0x[CB, 0x27, 0xD1, 0x7]7, 0x00, 0x78]> but was:<...0x00, 0x00, 0x00, 0x[B5, 0x1B, 0x97, 0x9]7, 0x00, 0x78]>"); + assertThat(toDate("26/08/1994")).asHexadecimal().isEqualTo(toDate("26/08/1997")); + } + + private Date toDate(String source) throws ParseException { + return new SimpleDateFormat("dd/MM/yyyy").parse(source); + } +} diff --git a/src/test/java/org/assertj/core/api/Assertions_assertThat_asUnicode_Test.java b/src/test/java/org/assertj/core/api/Assertions_assertThat_asUnicode_Test.java new file mode 100644 index 0000000000..1c94960271 --- /dev/null +++ b/src/test/java/org/assertj/core/api/Assertions_assertThat_asUnicode_Test.java @@ -0,0 +1,50 @@ +/* + * Created on Dec 21, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.api; + +import org.assertj.core.test.ExpectedException; +import org.junit.Rule; +import org.junit.Test; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Date; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.test.ExpectedException.none; + +/** + * Tests for {@link org.assertj.core.presentation.UnicodeRepresentation#toStringOf(Object)}. + * + * @author Mariusz Smykula + */ +public class Assertions_assertThat_asUnicode_Test { + + @Rule + public ExpectedException thrown = none(); + + @Test + public void should_assert_String_as_unicode() { + thrown.expectMessage("expected: but was:"); + assertThat("a6c").asUnicode().isEqualTo("abó"); + } + @Test + public void should_assert_Character_as_unicode() { + thrown.expectMessage("expected:<[\\u00f3]> but was:<[o]>"); + assertThat('o').asUnicode().isEqualTo('ó'); + } + +} diff --git a/src/test/java/org/assertj/core/api/DateAssertBaseTest.java b/src/test/java/org/assertj/core/api/DateAssertBaseTest.java index 3fbbec4ac7..5729c12bee 100644 --- a/src/test/java/org/assertj/core/api/DateAssertBaseTest.java +++ b/src/test/java/org/assertj/core/api/DateAssertBaseTest.java @@ -32,7 +32,7 @@ public void setUp() { } protected Date parse(String dateAsString) { - return DateAssert.parse(dateAsString); + return assertions.parse(dateAsString); } protected AssertionInfo getInfo(DateAssert someAssertions) { diff --git a/src/test/java/org/assertj/core/api/SoftAssertionsTest.java b/src/test/java/org/assertj/core/api/SoftAssertionsTest.java index be3795931d..defc4ca897 100644 --- a/src/test/java/org/assertj/core/api/SoftAssertionsTest.java +++ b/src/test/java/org/assertj/core/api/SoftAssertionsTest.java @@ -56,7 +56,7 @@ public void should_be_able_to_catch_exceptions_thrown_by_all_proxied_methods() { softly.assertThat(new boolean[]{false}).isEqualTo(new boolean[]{true}); softly.assertThat(new Byte((byte) 0)).isEqualTo((byte) 1); - softly.assertThat((byte) 2).isEqualTo((byte) 3); + softly.assertThat((byte) 2).asHexadecimal().isEqualTo((byte) 3); softly.assertThat(new byte[]{4}).isEqualTo(new byte[]{5}); softly.assertThat(new Character((char) 65)).isEqualTo(new Character((char) 66)); @@ -141,9 +141,9 @@ public String toString() { assertThat(errors.get(2)).isEqualTo("expected:<[tru]e> but was:<[fals]e>"); assertThat(errors.get(3)).isEqualTo("expected:<[[tru]e]> but was:<[[fals]e]>"); - assertThat(errors.get(4)).isEqualTo("expected:<0x0[1]> but was:<0x0[0]>"); + assertThat(errors.get(4)).isEqualTo("expected:<[1]> but was:<[0]>"); assertThat(errors.get(5)).isEqualTo("expected:<0x0[3]> but was:<0x0[2]>"); - assertThat(errors.get(6)).isEqualTo("expected:<[0x0[5]]> but was:<[0x0[4]]>"); + assertThat(errors.get(6)).isEqualTo("expected:<[[5]]> but was:<[[4]]>"); assertThat(errors.get(7)).isEqualTo("expected:<'[B]'> but was:<'[A]'>"); assertThat(errors.get(8)).isEqualTo("expected:<'[D]'> but was:<'[C]'>"); diff --git a/src/test/java/org/assertj/core/error/BasicErrorMessageFactory_create_Test.java b/src/test/java/org/assertj/core/error/BasicErrorMessageFactory_create_Test.java index 368efdfd48..bed0fdc629 100644 --- a/src/test/java/org/assertj/core/error/BasicErrorMessageFactory_create_Test.java +++ b/src/test/java/org/assertj/core/error/BasicErrorMessageFactory_create_Test.java @@ -19,13 +19,13 @@ import org.assertj.core.description.Description; -import org.assertj.core.error.BasicErrorMessageFactory; -import org.assertj.core.error.MessageFormatter; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.Representation; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link BasicErrorMessageFactory#create(Description)}. + * Tests for {@link BasicErrorMessageFactory#create(Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -44,8 +44,9 @@ public void setUp() { @Test public void should_implement_toString() { Description description = new TestDescription("Test"); + Representation representation = new StandardRepresentation(); String formattedMessage = "[Test] Hello Yoda"; - when(formatter.format(description, "Hello %s", "Yoda")).thenReturn(formattedMessage); - assertEquals(formattedMessage, factory.create(description)); + when(formatter.format(description, representation, "Hello %s", "Yoda")).thenReturn(formattedMessage); + assertEquals(formattedMessage, factory.create(description, representation)); } } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldBeAtLeast_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldBeAtLeast_create_Test.java index 21aac981f8..dcafb19ff6 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldBeAtLeast_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldBeAtLeast_create_Test.java @@ -20,9 +20,9 @@ import static org.junit.Assert.assertEquals; import org.assertj.core.api.TestCondition; +import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldBeAtLeast; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -44,7 +44,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\", \"Solo\", \"Leia\"]>\n to be at least 2 times ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldBeAtMost_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldBeAtMost_create_Test.java index b148b45f2a..14195f3f53 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldBeAtMost_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldBeAtMost_create_Test.java @@ -21,8 +21,7 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldBeAtMost; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\", \"Luke\", \"Obiwan\"]>\n to be at most 2 times ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldBeExactly_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldBeExactly_create_Test.java index 5382a79131..fea0ebf0d4 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldBeExactly_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldBeExactly_create_Test.java @@ -20,16 +20,14 @@ import static org.junit.Assert.assertEquals; import org.assertj.core.api.TestCondition; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldBeExactly; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ElementsShouldBeExactly#create(Description)}. + * Tests for {@link ElementsShouldBeExactly#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François * @author Joel Costigliola @@ -45,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\", \"Solo\", \"Leia\"]>\n to be exactly 2 times ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldBe_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldBe_create_Test.java index 4816985f42..0e22df7d61 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldBe_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldBe_create_Test.java @@ -20,9 +20,9 @@ import static org.junit.Assert.assertEquals; import org.assertj.core.api.TestCondition; +import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldBe; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -44,7 +44,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Leia\"]>\n of \n<[\"Yoda\", \"Luke\", \"Leia\"]>\n to be ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldHaveAtLeast_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldHaveAtLeast_create_Test.java index 8be175cc68..370c4ba5ea 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldHaveAtLeast_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldHaveAtLeast_create_Test.java @@ -22,14 +22,13 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldBeExactly; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ElementsShouldBeExactly#create(Description)}. + * Tests for {@link ElementsShouldBeExactly#create(Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -44,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\", \"Solo\", \"Leia\"]>\n to have at least 2 times ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldHaveAtMost_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldHaveAtMost_create_Test.java index d5727e3094..e1b3ff5d99 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldHaveAtMost_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldHaveAtMost_create_Test.java @@ -21,8 +21,7 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldHaveAtMost; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\", \"Luke\", \"Obiwan\"]>\n to have at most 2 times ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldHaveExactly_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldHaveExactly_create_Test.java index 4c8634eb8c..22c462edd1 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldHaveExactly_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldHaveExactly_create_Test.java @@ -21,8 +21,7 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldHaveAtLeast; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\", \"Solo\", \"Leia\"]>\n to have at least 2 times ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldHave_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldHave_create_Test.java index 3fc7b23376..8187b1ca92 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldHave_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldHave_create_Test.java @@ -22,14 +22,13 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldHave; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ElementsShouldHave#create(Description)}. + * Tests for {@link ElementsShouldHave#create(Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -44,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Leia\"]>\n of \n<[\"Yoda\", \"Luke\", \"Leia\"]>\n to have ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldNotBe_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldNotBe_create_Test.java index 4230d0348d..c71d346e4d 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldNotBe_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldNotBe_create_Test.java @@ -22,14 +22,13 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldNotBe; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ElementsShouldNotBe#create(Description)}. + * Tests for {@link ElementsShouldNotBe#create(Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -44,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Yoda\"]>\n of \n<[\"Darth Vader\", \"Leia\", \"Yoda\"]>\n not to be ", message); } diff --git a/src/test/java/org/assertj/core/error/ElementsShouldNotHave_create_Test.java b/src/test/java/org/assertj/core/error/ElementsShouldNotHave_create_Test.java index c4bfea148a..4cb0d6878d 100644 --- a/src/test/java/org/assertj/core/error/ElementsShouldNotHave_create_Test.java +++ b/src/test/java/org/assertj/core/error/ElementsShouldNotHave_create_Test.java @@ -22,14 +22,13 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ElementsShouldNotHave; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ElementsShouldNotHave#create(Description)}. + * Tests for {@link ElementsShouldNotHave#create(Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -44,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting elements:\n<[\"Leia\"]>\n of \n<[\"Yoda\", \"Luke\", \"Leia\"]>\n not to have ", message); } diff --git a/src/test/java/org/assertj/core/error/MessageFormatter_format_Test.java b/src/test/java/org/assertj/core/error/MessageFormatter_format_Test.java index a71fd2aaba..202aaf2d4d 100644 --- a/src/test/java/org/assertj/core/error/MessageFormatter_format_Test.java +++ b/src/test/java/org/assertj/core/error/MessageFormatter_format_Test.java @@ -20,8 +20,8 @@ import org.assertj.core.description.*; -import org.assertj.core.error.DescriptionFormatter; -import org.assertj.core.error.MessageFormatter; +import org.assertj.core.presentation.Representation; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.test.ExpectedException; import org.junit.*; @@ -48,20 +48,21 @@ public void setUp() { @Test public void should_throw_error_if_format_string_is_null() { thrown.expect(NullPointerException.class); - messageFormatter.format(null, null); + messageFormatter.format(null, null, null); } @Test public void should_throw_error_if_args_array_is_null() { thrown.expect(NullPointerException.class); Object[] args = null; - messageFormatter.format(null, "", args); + messageFormatter.format(null, null, "", args); } @Test public void should_format_message() { Description description = new TextDescription("Test"); - String s = messageFormatter.format(description, "Hello %s", "World"); + Representation representation = new StandardRepresentation(); + String s = messageFormatter.format(description, representation, "Hello %s", "World"); assertEquals("[Test] Hello \"World\"", s); verify(descriptionFormatter).format(description); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeAbsolutePath_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeAbsolutePath_create_Test.java index e7ad521c69..5f28e8fe3c 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeAbsolutePath_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeAbsolutePath_create_Test.java @@ -19,13 +19,12 @@ import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeAbsolutePath; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeAbsolutePath#create(Description)}. + * Tests for {@link ShouldBeAbsolutePath#create(Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n \nto be an absolute path", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeAfterOrEqualsTo_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeAfterOrEqualsTo_create_Test.java index b61cc32881..59eeb16dd1 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeAfterOrEqualsTo_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeAfterOrEqualsTo_create_Test.java @@ -21,14 +21,13 @@ import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeAfterOrEqualsTo; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeAfterOrEqualsTo#create(Description)}. + * Tests for {@link ShouldBeAfterOrEqualsTo#create(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2011-01-01T00:00:00>\nto be after or equals to:\n <2012-01-01T00:00:00>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeAfter_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeAfter_create_Test.java index 934d27dfc6..f46a4f6e5b 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeAfter_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeAfter_create_Test.java @@ -21,14 +21,13 @@ import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeAfter; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeAfter#create(Description)}. + * Tests for {@link ShouldBeAfter#create(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2011-01-01T00:00:00>\nto be strictly after:\n <2012-01-01T00:00:00>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeAssignableFrom_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeAssignableFrom_create_Test.java index b13141b402..52411019f0 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeAssignableFrom_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeAssignableFrom_create_Test.java @@ -17,6 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.error.ShouldBeAssignableFrom.shouldBeAssignableFrom; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -41,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo( "[Test] \n" + "Expecting\n" diff --git a/src/test/java/org/assertj/core/error/ShouldBeAtIndex_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeAtIndex_create_Test.java index 5e6afcbd3f..8e99a12f4b 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeAtIndex_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeAtIndex_create_Test.java @@ -7,14 +7,14 @@ import static org.junit.Assert.assertEquals; import org.assertj.core.api.TestCondition; +import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeAtIndex; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldBeAtIndex#create(org.assertj.core.description.Description)}. + * Tests for {@link ShouldBeAtIndex#create(Description, org.assertj.core.presentation.Representation)}. * * @author Bo Gotthardt */ @@ -24,7 +24,7 @@ public class ShouldBeAtIndex_create_Test { public void should_create_error_message() { ErrorMessageFactory factory = shouldBeAtIndex(newArrayList("Yoda", "Luke"), new TestCondition("red lightsaber"), atIndex(1), "Luke"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Luke\">\nat index <1> to be:\n \nin:\n <[\"Yoda\", \"Luke\"]>\n", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeBeforeOrEqualsTo_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeBeforeOrEqualsTo_create_Test.java index 9f17921149..366a98a391 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeBeforeOrEqualsTo_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeBeforeOrEqualsTo_create_Test.java @@ -21,14 +21,13 @@ import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeBeforeOrEqualsTo; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeBeforeOrEqualsTo#create(Description)}. + * Tests for {@link ShouldBeBeforeOrEqualsTo#create(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2011-01-01T00:00:00>\nto be before or equals to:\n <2012-01-01T00:00:00>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeBefore_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeBefore_create_Test.java index ab317a5f78..a6ecbfe798 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeBefore_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeBefore_create_Test.java @@ -21,14 +21,13 @@ import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeBefore; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeBefore#create(Description)}. + * Tests for {@link ShouldBeBefore#create(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2011-01-01T00:00:00>\nto be strictly before:\n <2012-01-01T00:00:00>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeBetween_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeBetween_create_Test.java index dad40d03a3..133839d9cd 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeBetween_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeBetween_create_Test.java @@ -20,13 +20,12 @@ import static org.assertj.core.util.Dates.parse; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeBetween; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldBeBetween#create(Description)}. + * Tests for {@link ShouldBeBetween#create(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -35,28 +34,28 @@ public class ShouldBeBetween_create_Test { @Test public void should_create_error_message_with_period_boundaries_included() { ErrorMessageFactory factory = shouldBeBetween(parse("2010-01-01"), parse("2011-01-01"), parse("2012-01-01"), true, true); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2010-01-01T00:00:00>\nto be in period:\n [2011-01-01T00:00:00, 2012-01-01T00:00:00]", message); } @Test public void should_create_error_message_with_period_lower_boundary_included() { ErrorMessageFactory factory = shouldBeBetween(parse("2010-01-01"), parse("2011-01-01"), parse("2012-01-01"), true, false); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2010-01-01T00:00:00>\nto be in period:\n [2011-01-01T00:00:00, 2012-01-01T00:00:00[", message); } @Test public void should_create_error_message_with_period_upper_boundary_included() { ErrorMessageFactory factory = shouldBeBetween(parse("2010-01-01"), parse("2011-01-01"), parse("2012-01-01"), false, true); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2010-01-01T00:00:00>\nto be in period:\n ]2011-01-01T00:00:00, 2012-01-01T00:00:00]", message); } @Test public void should_create_error_message_with_period_boundaries_excluded() { ErrorMessageFactory factory = shouldBeBetween(parse("2010-01-01"), parse("2011-01-01"), parse("2012-01-01"), false, false); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2010-01-01T00:00:00>\nto be in period:\n ]2011-01-01T00:00:00, 2012-01-01T00:00:00[", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeCloseTo_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeCloseTo_create_Test.java index b86bfb43b2..7435c219c5 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeCloseTo_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeCloseTo_create_Test.java @@ -22,14 +22,13 @@ import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeCloseTo; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.Dates; import org.junit.Test; /** - * Tests for {@link ShouldBeCloseTo#create(Description)}. + * Tests for {@link ShouldBeCloseTo#create(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -39,7 +38,7 @@ public class ShouldBeCloseTo_create_Test { public void should_create_error_message_with_period_boundaries_included() throws ParseException { ErrorMessageFactory factory = shouldBeCloseTo(Dates.parseDatetimeWithMs("2011-01-01T00:00:00.000"), Dates.parseDatetimeWithMs("2011-01-01T00:00:00.101"), 100, 101); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <2011-01-01T00:00:00.000>\nto be close to:\n <2011-01-01T00:00:00.101>\nby less than 100ms but difference was 101ms", message); diff --git a/src/test/java/org/assertj/core/error/ShouldBeDirectory_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeDirectory_create_Test.java index 1f1498cec8..58e02f8e24 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeDirectory_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeDirectory_create_Test.java @@ -19,13 +19,12 @@ import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeDirectory; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeDirectory#create(Description)}. + * Tests for {@link ShouldBeDirectory#create(Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n \nto be an existing directory", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeEmpty_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEmpty_create_Test.java index a3212ec39d..f333585597 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEmpty_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEmpty_create_Test.java @@ -20,13 +20,12 @@ import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeEmpty; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeEmpty#create(Description)}. + * Tests for {@link ShouldBeEmpty#create(Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -42,7 +41,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting empty but was:<[\"Luke\", \"Yoda\"]>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqualComparingOnlyGivenFields_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqualComparingOnlyGivenFields_create_Test.java index d106449069..e7fd46778e 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqualComparingOnlyGivenFields_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqualComparingOnlyGivenFields_create_Test.java @@ -22,9 +22,9 @@ import static org.assertj.core.util.Lists.*; import static org.junit.Assert.assertEquals; -import org.assertj.core.api.Assertions; import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.test.Jedi; import org.junit.Test; @@ -45,7 +45,7 @@ public void should_create_error_message_with_all_fields_differences() { newArrayList((Object) "Luke", "blue"), newArrayList((Object) "Yoda", "green"), newArrayList("name", "lightSaberColor")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \n" + "Expecting values:\n" + " <[\"Yoda\", \"green\"]>\n" + @@ -63,7 +63,7 @@ public void should_create_error_message_with_single_field_difference() { factory = shouldBeEqualComparingOnlyGivenFields(new Jedi("Yoda", "green"), newArrayList("lightSaberColor"), newArrayList((Object) "green"), newArrayList((Object) "blue"), newArrayList("lightSaberColor")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting value <\"blue\">" + " in field <\"lightSaberColor\">" + " but was <\"green\">" + diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqualIgnoringCase_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqualIgnoringCase_create_Test.java index 87c47bc561..ec0611ea7f 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqualIgnoringCase_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqualIgnoringCase_create_Test.java @@ -19,12 +19,13 @@ import org.assertj.core.description.Description; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeEqualIgnoringCase#create(Description)}. + * Tests for {@link ShouldBeEqualIgnoringCase#create(Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -40,7 +41,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto be equal to:\n <\"Luke\">\nignoring case considerations", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqualIgnoringGivenFields_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqualIgnoringGivenFields_create_Test.java index 0ea990b048..1903fccbe4 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqualIgnoringGivenFields_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqualIgnoringGivenFields_create_Test.java @@ -20,6 +20,7 @@ import java.util.List; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; import org.assertj.core.description.Description; @@ -42,7 +43,7 @@ public void should_create_error_message_with_all_fields_differences() { newArrayList((Object) "Yoda", "blue"), newArrayList((Object) "Yoda", "green"), newArrayList("someIgnoredField")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \n" + "Expecting values:\n" + " <[\"Yoda\", \"green\"]>\n" + @@ -59,7 +60,7 @@ public void should_create_error_message_with_single_field_difference() { factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("lightSaberColor"), newArrayList((Object) "blue"), newArrayList((Object) "green"), newArrayList("someIgnoredField")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \n" + "Expecting value <\"green\"> in field <\"lightSaberColor\"> " + "but was <\"blue\"> in .\n" + @@ -72,7 +73,7 @@ public void should_create_error_message_with_all_fields_differences_without_igno factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("name", "lightSaberColor"), newArrayList((Object) "Yoda", "blue"), newArrayList((Object) "Yoda", "green"), ignoredFields); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting values:\n" + " <[\"Yoda\", \"green\"]>\n" + "in fields:\n" + @@ -89,7 +90,7 @@ public void should_create_error_message_with_single_field_difference_without_ign factory = shouldBeEqualToIgnoringGivenFields(new Jedi("Yoda", "blue"), newArrayList("lightSaberColor"), newArrayList((Object) "blue"), newArrayList((Object) "green"), ignoredFields); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting value <\"green\"> " + "in field <\"lightSaberColor\"> " + "but was <\"blue\"> in .\n" + diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqualWithTimePrecision_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqualWithTimePrecision_create_Test.java index 64df771698..9aa759b154 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqualWithTimePrecision_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqualWithTimePrecision_create_Test.java @@ -7,13 +7,14 @@ import java.text.ParseException; import java.util.concurrent.TimeUnit; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; import org.assertj.core.description.TextDescription; /** - * Tests for {@link ShouldBeEqualWithTimePrecision#create(org.assertj.core.description.Description)}. + * Tests for {@link ShouldBeEqualWithTimePrecision#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -24,7 +25,7 @@ public void should_create_error_message_ignoring_millisseconds() throws ParseExc ErrorMessageFactory factory = shouldBeEqual(parseDatetimeWithMs("2011-01-01T05:00:00.000"), parseDatetimeWithMs("2011-01-01T06:05:17.003"), TimeUnit.MILLISECONDS); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <2011-01-01T05:00:00>\n" + "to have same year, month, day, hour, minute and second as:\n " + "<2011-01-01T06:05:17>\n" + @@ -36,7 +37,7 @@ public void should_create_error_message_ignoring_seconds() throws ParseException ErrorMessageFactory factory = shouldBeEqual(parseDatetimeWithMs("2011-01-01T05:00:00.000"), parseDatetimeWithMs("2011-01-01T06:05:17.003"), TimeUnit.SECONDS); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <2011-01-01T05:00:00>\n" + "to have same year, month, day, hour and minute as:\n " + "<2011-01-01T06:05:17>\n" + @@ -48,7 +49,7 @@ public void should_create_error_message_ignoring_miinutes() throws ParseExceptio ErrorMessageFactory factory = shouldBeEqual(parseDatetimeWithMs("2011-01-01T05:00:00.000"), parseDatetimeWithMs("2011-01-01T06:05:17.003"), TimeUnit.MINUTES); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <2011-01-01T05:00:00>\n" + "to have same year, month, day and hour as:\n " + "<2011-01-01T06:05:17>\n" + @@ -60,7 +61,7 @@ public void should_create_error_message_ignoring_hours() throws ParseException { ErrorMessageFactory factory = shouldBeEqual(parseDatetimeWithMs("2011-01-01T05:00:00.000"), parseDatetimeWithMs("2011-01-01T06:05:17.003"), TimeUnit.HOURS); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <2011-01-01T05:00:00>\n" + "to have same year, month and day as:\n " + "<2011-01-01T06:05:17>\n" + diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqualWithinOffset_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqualWithinOffset_create_Test.java index 22cc2549d1..2557aa32f3 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqualWithinOffset_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqualWithinOffset_create_Test.java @@ -20,15 +20,14 @@ import static org.assertj.core.error.ShouldBeEqualWithinOffset.shouldBeEqual; import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeEqualWithinOffset; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeEqualWithinOffset#create(Description)}. + * Tests for {@link ShouldBeEqualWithinOffset#create(Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <8.0f>\nto be close to:\n <6.0f>\nwithin offset <1.0f> but offset was <2.0f>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqual_equals_hashCode_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqual_equals_hashCode_Test.java index 3130ed3b2b..835e01ef60 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqual_equals_hashCode_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqual_equals_hashCode_Test.java @@ -19,8 +19,7 @@ import static org.assertj.core.error.ShouldBeEqual.shouldBeEqual; import static org.assertj.core.test.EqualsHashCodeContractAssert.*; - -import org.assertj.core.error.ShouldBeEqual; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** @@ -34,7 +33,7 @@ public class ShouldBeEqual_equals_hashCode_Test { @BeforeClass public static void setUpOnce() { - factory = (ShouldBeEqual) shouldBeEqual("Yoda", "Luke"); + factory = (ShouldBeEqual) shouldBeEqual("Yoda", "Luke", new StandardRepresentation()); } @Test @@ -44,17 +43,18 @@ public void should_have_reflexive_equals() { @Test public void should_have_symmetric_equals() { - assertEqualsIsSymmetric(factory, shouldBeEqual("Yoda", "Luke")); + assertEqualsIsSymmetric(factory, shouldBeEqual("Yoda", "Luke", new StandardRepresentation())); } @Test public void should_have_transitive_equals() { - assertEqualsIsTransitive(factory, shouldBeEqual("Yoda", "Luke"), shouldBeEqual("Yoda", "Luke")); + assertEqualsIsTransitive(factory, shouldBeEqual("Yoda", "Luke", new StandardRepresentation()), + shouldBeEqual("Yoda", "Luke", new StandardRepresentation())); } @Test public void should_maintain_equals_and_hashCode_contract() { - assertMaintainsEqualsAndHashCodeContract(factory, shouldBeEqual("Yoda", "Luke")); + assertMaintainsEqualsAndHashCodeContract(factory, shouldBeEqual("Yoda", "Luke", new StandardRepresentation())); } @Test @@ -69,11 +69,11 @@ public void should_not_be_equal_to_null() { @Test public void should_not_be_equal_to_IsNotEqual_with_different_actual() { - assertFalse(factory.equals(shouldBeEqual("Leia", "Luke"))); + assertFalse(factory.equals(shouldBeEqual("Leia", "Luke", new StandardRepresentation()))); } @Test public void should_not_be_equal_to_IsNotEqual_with_different_expected() { - assertFalse(factory.equals(shouldBeEqual("Yoda", "Leia"))); + assertFalse(factory.equals(shouldBeEqual("Yoda", "Leia", new StandardRepresentation()))); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_Test.java index 195b81c860..440f3c6917 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_Test.java @@ -23,16 +23,15 @@ import org.assertj.core.description.Description; -import org.assertj.core.error.DescriptionFormatter; -import org.assertj.core.error.ShouldBeEqual; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; import org.junit.runner.RunWith; import org.junit.runners.*; import org.junit.runners.Parameterized.Parameters; /** - * Tests for {@link ShouldBeEqual#newAssertionError(Description)}. + * Tests for {@link ShouldBeEqual#newAssertionError(Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -57,7 +56,7 @@ public ShouldBeEqual_newAssertionError_Test(String formattedDescription) { @Before public void setUp() { description = new TestDescription("Jedi"); - factory = (ShouldBeEqual) shouldBeEqual("Luke", "Yoda"); + factory = (ShouldBeEqual) shouldBeEqual("Luke", "Yoda", new StandardRepresentation()); factory.descriptionFormatter = mock(DescriptionFormatter.class); formatter = factory.descriptionFormatter; } @@ -65,7 +64,7 @@ public void setUp() { @Test public void should_create_ComparisonFailure_if_JUnit4_is_present_and_trim_spaces_in_formatted_description() { when(formatter.format(description)).thenReturn(formattedDescription); - AssertionError error = factory.newAssertionError(description); + AssertionError error = factory.newAssertionError(description, new StandardRepresentation()); assertEquals(ComparisonFailure.class, error.getClass()); assertEquals("[Jedi] expected:<\"[Yoda]\"> but was:<\"[Luke]\">", error.getMessage()); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test.java index 625d7c4442..f46b0b91cf 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_differentiating_expected_and_actual_Test.java @@ -27,11 +27,12 @@ import org.assertj.core.internal.ComparatorBasedComparisonStrategy; import org.assertj.core.internal.ComparisonStrategy; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeEqual#newAssertionError(Description)}. + * Tests for {@link ShouldBeEqual#newAssertionError(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola (based on Tomasz Nurkiewicz ideas) */ @@ -50,10 +51,10 @@ public void setUp() { public void should_create_AssertionError_with_message_differentiating_expected_double_and_actual_float() { Float actual = 42f; Double expected = 42d; - shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected); + shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, new StandardRepresentation()); shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class); when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription); - AssertionError error = shouldBeEqual.newAssertionError(description); + AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation()); assertEquals("[my test] expected:<42.0[]> but was:<42.0[f]>", error.getMessage()); } @@ -61,10 +62,10 @@ public void should_create_AssertionError_with_message_differentiating_expected_d public void should_create_AssertionError_with_message_differentiating_expected_and_actual_persons() { Person actual = new Person("Jake", 43); Person expected = new Person("Jake", 47); - shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected); + shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, new StandardRepresentation()); shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class); when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription); - AssertionError error = shouldBeEqual.newAssertionError(description); + AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation()); assertEquals("[my test] \nExpecting:\n <\"Person[name=Jake] (Person@" + toHexString(expected.hashCode()) + ")\">\nto be equal to:\n <\"Person[name=Jake] (Person@" + toHexString(actual.hashCode()) + ")\">\nbut was not.", error.getMessage()); @@ -75,10 +76,11 @@ public void should_create_AssertionError_with_message_differentiating_expected_a Person actual = new Person("Jake", 43); Person expected = new Person("Jake", 47); ComparisonStrategy ageComparisonStrategy = new ComparatorBasedComparisonStrategy(new PersonComparator()); - shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, ageComparisonStrategy); + shouldBeEqual = (ShouldBeEqual) shouldBeEqual(actual, expected, ageComparisonStrategy, + new StandardRepresentation()); shouldBeEqual.descriptionFormatter = mock(DescriptionFormatter.class); when(shouldBeEqual.descriptionFormatter.format(description)).thenReturn(formattedDescription); - AssertionError error = shouldBeEqual.newAssertionError(description); + AssertionError error = shouldBeEqual.newAssertionError(description, new StandardRepresentation()); assertEquals("[my test] \nExpecting:\n <\"Person[name=Jake] (Person@" + toHexString(actual.hashCode()) + ")\">\nto be equal to:\n <\"Person[name=Jake] (Person@" + toHexString(expected.hashCode()) + ")\">\naccording to 'PersonComparator' comparator but was not.", error.getMessage()); diff --git a/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_without_JUnit_Test.java b/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_without_JUnit_Test.java index 585d3130d7..79c9c05bc6 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_without_JUnit_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeEqual_newAssertionError_without_JUnit_Test.java @@ -22,16 +22,15 @@ import static org.mockito.Mockito.*; import org.assertj.core.description.Description; -import org.assertj.core.error.ConstructorInvoker; -import org.assertj.core.error.ShouldBeEqual; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.ComparisonFailure; import org.junit.Test; /** - * Tests for {@link ShouldBeEqual#newAssertionError(Description)}. + * Tests for {@link ShouldBeEqual#newAssertionError(Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -45,7 +44,7 @@ public class ShouldBeEqual_newAssertionError_without_JUnit_Test { @Before public void setUp() { description = new TestDescription("Jedi"); - factory = (ShouldBeEqual) shouldBeEqual("Luke", "Yoda"); + factory = (ShouldBeEqual) shouldBeEqual("Luke", "Yoda", new StandardRepresentation()); constructorInvoker = mock(ConstructorInvoker.class); factory.constructorInvoker = constructorInvoker; } @@ -53,14 +52,14 @@ public void setUp() { @Test public void should_create_AssertionError_if_created_ComparisonFailure_is_null() throws Exception { when(createComparisonFailure()).thenReturn(null); - AssertionError error = factory.newAssertionError(description); + AssertionError error = factory.newAssertionError(description, new StandardRepresentation()); check(error); } @Test public void should_create_AssertionError_if_error_is_thrown_when_creating_ComparisonFailure() throws Exception { when(createComparisonFailure()).thenThrow(new AssertionError("Thrown on purpose")); - AssertionError error = factory.newAssertionError(description); + AssertionError error = factory.newAssertionError(description, new StandardRepresentation()); check(error); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeExactlyInstance_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeExactlyInstance_create_Test.java index 5fa480cee7..24456690aa 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeExactlyInstance_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeExactlyInstance_create_Test.java @@ -21,11 +21,12 @@ import org.assertj.core.description.Description; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeExactlyInstanceOf#create(Description)}. + * Tests for {@link ShouldBeExactlyInstanceOf#create(Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -40,7 +41,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"Yoda\">\nto be exactly an instance of:\n \nbut was an instance of:\n ", message); diff --git a/src/test/java/org/assertj/core/error/ShouldBeExecutableTest.java b/src/test/java/org/assertj/core/error/ShouldBeExecutableTest.java index 2491367f61..e05a20a43b 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeExecutableTest.java +++ b/src/test/java/org/assertj/core/error/ShouldBeExecutableTest.java @@ -17,9 +17,8 @@ import static org.junit.Assert.assertEquals; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeExecutable; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -38,7 +37,7 @@ public class ShouldBeExecutableTest { } @Test public void createExpectedMessage() { - String actualMessage = factory.create(new TestDescription("Test")); + String actualMessage = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n \nto be executable", actualMessage); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeFile_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeFile_create_Test.java index b44e6242cf..05eb163728 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeFile_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeFile_create_Test.java @@ -19,13 +19,12 @@ import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeFile; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeFile#create(Description)}. + * Tests for {@link ShouldBeFile#create(Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n \nto be a file", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeGreaterOrEqual_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeGreaterOrEqual_create_Test.java index 431d823aeb..b97a9bf35a 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeGreaterOrEqual_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeGreaterOrEqual_create_Test.java @@ -20,12 +20,13 @@ import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.AbsValueComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeGreaterOrEqual#create(Description)}. + * Tests for {@link ShouldBeGreaterOrEqual#create(Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -41,14 +42,14 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <6>\nto be greater than or equal to:\n <8> ", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldBeGreaterOrEqual(6, 8, new ComparatorBasedComparisonStrategy(new AbsValueComparator())); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <6>\nto be greater than or equal to:\n <8> according to 'AbsValueComparator' comparator", message); diff --git a/src/test/java/org/assertj/core/error/ShouldBeGreater_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeGreater_create_Test.java index 0c7c14f83c..5e36f630cd 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeGreater_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeGreater_create_Test.java @@ -20,12 +20,13 @@ import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.AbsValueComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeGreater#create(Description)}. + * Tests for {@link ShouldBeGreater#create(Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -41,14 +42,14 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <6>\nto be greater than:\n <8> ", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldBeGreater(6, 8, new ComparatorBasedComparisonStrategy(new AbsValueComparator())); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <6>\nto be greater than:\n <8> according to 'AbsValueComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeInSameDay_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeInSameDay_create_Test.java index c38f11c2cf..ff55355bef 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeInSameDay_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeInSameDay_create_Test.java @@ -20,13 +20,12 @@ import static org.assertj.core.util.Dates.parse; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeInSameDay; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldBeInSameDay#create(Description)}. + * Tests for {@link ShouldBeInSameDay#create(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -35,7 +34,7 @@ public class ShouldBeInSameDay_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldBeInSameDay(parse("2010-01-01"), parse("2010-01-25")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2010-01-01T00:00:00>\nto be on same year, month and day as:\n <2010-01-25T00:00:00>", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeInSameHourWindow_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeInSameHourWindow_create_Test.java index aa51df2df9..198d5a0e33 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeInSameHourWindow_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeInSameHourWindow_create_Test.java @@ -6,14 +6,15 @@ import java.text.ParseException; +import org.assertj.core.description.Description; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; /** - * Tests for {@link ShouldBeInSameHourWindow#create(Description)}. + * Tests for {@link ShouldBeInSameHourWindow#create(Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola * @author Mikhail Mazursky @@ -25,7 +26,7 @@ public void should_create_error_message() throws ParseException { ErrorMessageFactory factory = shouldBeInSameHourWindow(parseDatetimeWithMs("2011-01-01T05:00:00.000"), parseDatetimeWithMs("2011-01-01T06:05:17.003")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <2011-01-01T05:00:00>\nto be close to:\n " + "<2011-01-01T06:05:17>\n" + "by less than one hour (strictly) but difference was: 1h 5m 17s and 3ms"); diff --git a/src/test/java/org/assertj/core/error/ShouldBeInSameMinuteWindow_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeInSameMinuteWindow_create_Test.java index 503581be2a..888d4436b4 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeInSameMinuteWindow_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeInSameMinuteWindow_create_Test.java @@ -23,14 +23,14 @@ import java.text.ParseException; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; /** - * Tests for {@link ShouldBeInSameMinuteWindow#create(Description)}. + * Tests for {@link ShouldBeInSameMinuteWindow#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola * @author Mikhail Mazursky @@ -42,7 +42,7 @@ public void should_create_error_message() throws ParseException { ErrorMessageFactory factory = shouldBeInSameMinuteWindow(parseDatetime("2011-01-01T05:00:00"), parseDatetime("2011-01-01T05:02:01")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <2011-01-01T05:00:00>\nto be close to:\n " + "<2011-01-01T05:02:01>\n" + "by less than one minute (strictly) but difference was: 2m and 1s"); diff --git a/src/test/java/org/assertj/core/error/ShouldBeInSameMonth_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeInSameMonth_create_Test.java index db607cbdf1..87a17cda32 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeInSameMonth_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeInSameMonth_create_Test.java @@ -20,13 +20,12 @@ import static org.assertj.core.util.Dates.parse; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeInSameMonth; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldBeInSameMonth#create(Description)}. + * Tests for {@link ShouldBeInSameMonth#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -35,7 +34,7 @@ public class ShouldBeInSameMonth_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldBeInSameMonth(parse("2010-01-01"), parse("2010-02-01")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2010-01-01T00:00:00>\nto be on same year and month as:\n <2010-02-01T00:00:00>", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeInSameSecondWindow_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeInSameSecondWindow_create_Test.java index d77c9f6e2a..8e0698cfee 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeInSameSecondWindow_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeInSameSecondWindow_create_Test.java @@ -6,14 +6,14 @@ import java.text.ParseException; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; /** - * Tests for {@link ShouldBeInSameSecondWindow#create(Description)}. + * Tests for {@link ShouldBeInSameSecondWindow#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola * @author Mikhail Mazursky @@ -24,7 +24,7 @@ public class ShouldBeInSameSecondWindow_create_Test { public void should_create_error_message() throws ParseException { ErrorMessageFactory factory = shouldBeInSameSecondWindow(parseDatetimeWithMs("2011-01-01T05:00:01.000"), parseDatetimeWithMs("2011-01-01T05:00:02.001")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <2011-01-01T05:00:01>\nto be close to:\n " + "<2011-01-01T05:00:02>\nby less than one second (strictly) but difference was: 1s" + " and 1ms"); diff --git a/src/test/java/org/assertj/core/error/ShouldBeInSameYear_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeInSameYear_create_Test.java index 495400a74f..0e2440b94b 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeInSameYear_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeInSameYear_create_Test.java @@ -20,13 +20,12 @@ import static org.assertj.core.util.Dates.parse; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeInSameYear; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldBeInSameYear#create(Description)}. + * Tests for {@link ShouldBeInSameYear#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -35,7 +34,7 @@ public class ShouldBeInSameYear_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldBeInSameYear(parse("2010-01-01"), parse("2011-01-01")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2010-01-01T00:00:00>\nto be on same year as:\n <2011-01-01T00:00:00>", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeIn_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeIn_create_Test.java index a6b60d5c34..081ea0e56d 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeIn_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeIn_create_Test.java @@ -21,12 +21,13 @@ import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeIn#create(Description)}. + * Tests for {@link ShouldBeIn#create(Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang * @author Joel Costigliola @@ -42,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto be in:\n <[\"Luke\", \"Leia\"]>\n", message); } @@ -50,7 +51,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldBeIn("Yoda", array("Luke", "Leia"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"Yoda\">\nto be in:\n <[\"Luke\", \"Leia\"]>\naccording to 'CaseInsensitiveStringComparator' comparator", message); diff --git a/src/test/java/org/assertj/core/error/ShouldBeInstanceOfAny_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeInstanceOfAny_create_Test.java index 069f813652..bdad1d24b7 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeInstanceOfAny_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeInstanceOfAny_create_Test.java @@ -20,13 +20,13 @@ import java.io.File; import java.util.regex.Pattern; -import org.assertj.core.description.Description; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeInstanceOfAny#create(Description)}. + * Tests for {@link ShouldBeInstanceOfAny#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -42,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"Yoda\">\nto be an instance of any of:\n <[java.io.File, java.util.regex.Pattern]>\nbut was instance of:\n ", message); diff --git a/src/test/java/org/assertj/core/error/ShouldBeInstance_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeInstance_create_Test.java index edb7485df1..dd276c8f8a 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeInstance_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeInstance_create_Test.java @@ -21,16 +21,14 @@ import java.io.File; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeInstance; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeInstance#create(Description)}. + * Tests for {@link ShouldBeInstance#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -46,7 +44,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"Yoda\">\nto be an instance of:\n \nbut was instance of:\n ", message); @@ -55,7 +53,7 @@ public void should_create_error_message() { @Test public void should_create_shouldBeInstanceButWasNull_error_message() { factory = shouldBeInstanceButWasNull("other", File.class); - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting object:\n \"other\"\nto be an instance of:\n \nbut was null", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeLess_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeLess_create_Test.java index 957b8f1f50..0fc7c59940 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeLess_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeLess_create_Test.java @@ -17,15 +17,15 @@ import static org.assertj.core.error.ShouldBeLess.shouldBeLess; import static org.junit.Assert.assertEquals; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.AbsValueComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeLess#create(Description)}. + * Tests for {@link ShouldBeLess#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -41,14 +41,14 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <8>\nto be less than:\n <6> ", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldBeLess(8, 6, new ComparatorBasedComparisonStrategy(new AbsValueComparator())); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <8>\nto be less than:\n <6> according to 'AbsValueComparator' comparator", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeLowerCase_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeLowerCase_create_Test.java index 6278304972..531281752c 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeLowerCase_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeLowerCase_create_Test.java @@ -18,12 +18,11 @@ import static org.assertj.core.error.ShouldBeLowerCase.shouldBeLowerCase; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeLowerCase; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeLowerCase#create(Description)}. + * Tests for {@link ShouldBeLowerCase#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -38,7 +37,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting <'A'> to be a lowercase character", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeNullOrEmpty_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeNullOrEmpty_create_Test.java index ea0759b47a..0d93eec559 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeNullOrEmpty_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeNullOrEmpty_create_Test.java @@ -19,12 +19,11 @@ import static org.assertj.core.util.Lists.newArrayList; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeNullOrEmpty; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeNullOrEmpty#create(Description)}. + * Tests for {@link ShouldBeNullOrEmpty#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -40,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting null or empty but was:<[\"Luke\", \"Yoda\"]>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeOfClassIn_Test.java b/src/test/java/org/assertj/core/error/ShouldBeOfClassIn_Test.java index 7a939ca00f..537a6e98c3 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeOfClassIn_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeOfClassIn_Test.java @@ -21,15 +21,13 @@ import java.io.File; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeOfClassIn; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeOfClassIn#create(Description)}. + * Tests for {@link ShouldBeOfClassIn#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -45,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto be of one these types:\n <[java.lang.Long, java.io.File]>\nbut was:\n ", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeReadableTest.java b/src/test/java/org/assertj/core/error/ShouldBeReadableTest.java index 7425bd8c0f..5158090222 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeReadableTest.java +++ b/src/test/java/org/assertj/core/error/ShouldBeReadableTest.java @@ -18,9 +18,8 @@ import static org.junit.Assert.assertEquals; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeReadable; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -38,7 +37,7 @@ public class ShouldBeReadableTest { } @Test public void createExpectedMessage() { - String actualMessage = factory.create(new TestDescription("Test")); + String actualMessage = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting file:\n \nto be readable", actualMessage); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeRelativePath_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeRelativePath_create_Test.java index 9d25f6b8c5..ef39e77909 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeRelativePath_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeRelativePath_create_Test.java @@ -18,14 +18,12 @@ import static org.assertj.core.error.ShouldBeRelativePath.shouldBeRelativePath; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeRelativePath; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeRelativePath#create(Description)}. + * Tests for {@link ShouldBeRelativePath#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +38,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting file:\n \nto be a relative path", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeSameGenericBetweenIterableAndCondition_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeSameGenericBetweenIterableAndCondition_create_Test.java index e7d02b460e..1ebccfc5af 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeSameGenericBetweenIterableAndCondition_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeSameGenericBetweenIterableAndCondition_create_Test.java @@ -22,7 +22,7 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -42,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting: <[\"Yoda\", \"Leia\"]> have the same generic type as condition ", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldBeSame_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeSame_create_Test.java index 6e4f381f4d..161dcc8504 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeSame_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeSame_create_Test.java @@ -18,12 +18,11 @@ import static org.assertj.core.error.ShouldBeSame.shouldBeSame; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeSame; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeSame#create(Description)}. + * Tests for {@link ShouldBeSame#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -38,7 +37,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Luke\">\nand actual:\n <\"Yoda\">\nto refer to the same object", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeSortedAccordingToComparator_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeSortedAccordingToComparator_create_Test.java index 9904bd455b..32f721f5a6 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeSortedAccordingToComparator_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeSortedAccordingToComparator_create_Test.java @@ -20,13 +20,13 @@ import java.util.Comparator; -import org.assertj.core.description.Description; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Test; /** - * Tests for {@link ShouldBeSorted#create(Description)}. + * Tests for {@link ShouldBeSorted#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -36,7 +36,7 @@ public class ShouldBeSortedAccordingToComparator_create_Test { public void should_create_error_message_with_comparator() { ErrorMessageFactory factory = shouldBeSortedAccordingToGivenComparator(1, array("b", "c", "A"), new CaseInsensitiveStringComparator()); - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \ngroup is not sorted according to 'CaseInsensitiveStringComparator' comparator because element 1:\n <\"c\">\nis not less or equal than element 2:\n <\"A\">\ngroup was:\n <[\"b\", \"c\", \"A\"]>", message); @@ -46,7 +46,7 @@ public void should_create_error_message_with_comparator() { public void should_create_error_message_with_private_static_comparator() { ErrorMessageFactory factory = shouldBeSortedAccordingToGivenComparator(1, array("b", "c", "a"), new StaticStringComparator()); - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \ngroup is not sorted according to 'StaticStringComparator' comparator because element 1:\n <\"c\">\nis not less or equal than element 2:\n <\"a\">\ngroup was:\n <[\"b\", \"c\", \"a\"]>", message); diff --git a/src/test/java/org/assertj/core/error/ShouldBeSorted_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeSorted_create_Test.java index 94d66730f6..486df8f79f 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeSorted_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeSorted_create_Test.java @@ -19,15 +19,15 @@ import static org.assertj.core.util.Arrays.array; import static org.junit.rules.ExpectedException.none; -import org.assertj.core.description.Description; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; /** - * Tests for {@link ShouldBeSorted#create(Description)}. + * Tests for {@link ShouldBeSorted#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -44,7 +44,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \ngroup is not sorted because element 1:\n <\"c\">\nis not less or equal than element 2:\n <\"a\">\ngroup was:\n <[\"b\", \"c\", \"a\"]>", message); diff --git a/src/test/java/org/assertj/core/error/ShouldBeSubsetOf_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeSubsetOf_create_Test.java index 26d97ad90b..93263243d7 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeSubsetOf_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeSubsetOf_create_Test.java @@ -18,15 +18,15 @@ import static org.assertj.core.error.ShouldBeSubsetOf.shouldBeSubsetOf; import static org.assertj.core.util.Lists.*; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeSubsetOf#create(Description)}. + * Tests for {@link ShouldBeSubsetOf#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Maciej Jaskowski */ @@ -41,7 +41,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting :\n <[\"Yoda\", \"Luke\"]>\nto be subset of\n <[\"Han\", \"Luke\"]>\nbut found those extra elements:\n <[\"Yoda\"]>", message); @@ -51,7 +51,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldBeSubsetOf(newArrayList("Yoda", "Luke"), newArrayList("Han", "Luke"), newArrayList("Yoda"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting according to 'CaseInsensitiveStringComparator' comparator:\n <[\"Yoda\", \"Luke\"]>\nto be subset of\n <[\"Han\", \"Luke\"]>\nbut found those extra elements:\n <[\"Yoda\"]>", message); diff --git a/src/test/java/org/assertj/core/error/ShouldBeUpperCase_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBeUpperCase_create_Test.java index 9bbe0ffcae..8ab19f0818 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeUpperCase_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBeUpperCase_create_Test.java @@ -18,12 +18,11 @@ import static org.assertj.core.error.ShouldBeUpperCase.shouldBeUpperCase; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeUpperCase; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeUpperCase#create(Description)}. + * Tests for {@link ShouldBeUpperCase#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -38,7 +37,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:<'a'> to be a uppercase character", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBeWritableTest.java b/src/test/java/org/assertj/core/error/ShouldBeWritableTest.java index 8564b32e36..16f18f871c 100644 --- a/src/test/java/org/assertj/core/error/ShouldBeWritableTest.java +++ b/src/test/java/org/assertj/core/error/ShouldBeWritableTest.java @@ -18,6 +18,7 @@ import static org.junit.Assert.assertEquals; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; @@ -35,7 +36,7 @@ public class ShouldBeWritableTest { } @Test public void createExpectedMessage() { - String actualMessage = factory.create(new TestDescription("Test")); + String actualMessage = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nFile:\n \nshould be writable", actualMessage); } } diff --git a/src/test/java/org/assertj/core/error/ShouldBe_create_Test.java b/src/test/java/org/assertj/core/error/ShouldBe_create_Test.java index ae951c4bd4..e0a3cc1c18 100644 --- a/src/test/java/org/assertj/core/error/ShouldBe_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldBe_create_Test.java @@ -21,14 +21,13 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBe; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBe#create(Description)}. + * Tests for {@link ShouldBe#create(Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -43,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto be ", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldContainAtIndex_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainAtIndex_create_Test.java index a4170f7635..cfe62e1e45 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainAtIndex_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainAtIndex_create_Test.java @@ -19,14 +19,14 @@ import static org.assertj.core.error.ShouldContainAtIndex.shouldContainAtIndex; import static org.assertj.core.util.Lists.*; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Test; /** - * Tests for {@link ShouldContainAtIndex#create(Description)}. + * Tests for {@link ShouldContainAtIndex#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -36,7 +36,7 @@ public class ShouldContainAtIndex_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldContainAtIndex(newArrayList("Yoda", "Luke"), "Leia", atIndex(1), "Luke"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Leia\">\nat index <1> but found:\n <\"Luke\">\nin:\n <[\"Yoda\", \"Luke\"]>\n", message); } @@ -45,7 +45,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainAtIndex(newArrayList("Yoda", "Luke"), "Leia", atIndex(1), "Luke", new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Leia\">\nat index <1> but found:\n <\"Luke\">\nin:\n <[\"Yoda\", \"Luke\"]>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldContainExactly_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainExactly_create_Test.java index c5afaa28d0..59306e7307 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainExactly_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainExactly_create_Test.java @@ -20,18 +20,16 @@ import static org.assertj.core.util.Lists.newArrayList; import static org.assertj.core.util.Sets.newLinkedHashSet; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldContainExactly; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldContainExactly#create(Description)}. + * Tests for {@link ShouldContainExactly#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -47,7 +45,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <[\"Yoda\", \"Han\"]>\nto contain exactly (and in same order):\n" + " <[\"Luke\", \"Yoda\"]>\nbut some elements were not found:\n <[\"Luke\"]>\nand others were not expected:\n <[\"Han\"]>\n", @@ -59,7 +57,7 @@ public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainExactly(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Han\"]>\nto contain exactly (and in same order):\n" + " <[\"Luke\", \"Yoda\"]>\nbut some elements were not found:\n <[\"Luke\"]>\nand others were not expected:\n" + " <[\"Han\"]>\naccording to 'CaseInsensitiveStringComparator' comparator", message); @@ -68,7 +66,7 @@ public void should_create_error_message_with_custom_comparison_strategy() { @Test public void should_create_error_message_when_only_elements_order_differs() { factory = shouldContainExactly("Luke", "Han", 1); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nActual and expected have the same elements but not in the same order, at index 1 actual element was:\n" + " <\"Luke\">\nwhereas expected element was:\n <\"Han\">\n", message); @@ -78,7 +76,7 @@ public void should_create_error_message_when_only_elements_order_differs() { public void should_create_error_message_when_only_elements_order_differs_according_to_custom_comparison_strategy() { factory = shouldContainExactly("Luke", "Han", 1, new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nActual and expected have the same elements but not in the same order, at index 1 actual element was:\n" + " <\"Luke\">\nwhereas expected element was:\n <\"Han\">\naccording to 'CaseInsensitiveStringComparator' comparator", diff --git a/src/test/java/org/assertj/core/error/ShouldContainKeys_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainKeys_create_Test.java index 18ee364b98..60a64ad5c7 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainKeys_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainKeys_create_Test.java @@ -22,13 +22,14 @@ import java.util.Map; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; /** - * Tests for {@link ShoulContainKey#create(Description)}. + * Tests for {@link ShouldContainKeys#create(Description)}. * * @author Nicolas François * @author Willima Telloue @@ -40,7 +41,7 @@ public class ShouldContainKeys_create_Test { public void should_create_error_message() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldContainKeys(map, newLinkedHashSet("name")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <{\"name\"=\"Yoda\", \"color\"=\"green\"}>\nto contain key:\n <\"name\">"); } @@ -48,7 +49,7 @@ public void should_create_error_message() { public void should_create_error_message_with_multiple_keys() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldContainKeys(map, newLinkedHashSet("name", "color")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo("[Test] \nExpecting:\n <{\"name\"=\"Yoda\", \"color\"=\"green\"}>\nto contain keys:\n <[\"name\", \"color\"]>"); } } diff --git a/src/test/java/org/assertj/core/error/ShouldContainOnly_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainOnly_create_Test.java index cd4a062731..0710807fac 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainOnly_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainOnly_create_Test.java @@ -20,17 +20,15 @@ import static org.assertj.core.util.Sets.newLinkedHashSet; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldContainOnly; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldContainOnly#create(Description)}. + * Tests for {@link ShouldContainOnly#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -47,7 +45,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Han\"]>\nto contain only:\n <[\"Luke\", \"Yoda\"]>\n" + "elements not found:\n <[\"Luke\"]>\nand elements not expected:\n <[\"Han\"]>\n", message); } @@ -56,7 +54,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainOnly(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Han\"]>\nto contain only:\n <[\"Luke\", \"Yoda\"]>\n" + "elements not found:\n <[\"Luke\"]>\nand elements not expected:\n <[\"Han\"]>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); diff --git a/src/test/java/org/assertj/core/error/ShouldContainSequenceString_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainSequenceString_create_Test.java index d8ef0bb478..e2538bf400 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainSequenceString_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainSequenceString_create_Test.java @@ -18,15 +18,15 @@ import static org.assertj.core.error.ShouldContainCharSequenceSequence.shouldContainSequence; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; import org.assertj.core.util.CaseInsensitiveStringComparator; /** - * Tests for {@link ShouldContainCharSequenceSequence#create(Description)}. + * Tests for {@link ShouldContainCharSequenceSequence#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -40,7 +40,7 @@ public void should_create_error_message() { String actual = "{ 'title':'A Game of Thrones', 'author':'George Martin'}"; factory = shouldContainSequence(actual, sequenceValues, 1); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"" + actual + "\">\n" + "to contain the following CharSequences in this order:\n" + " <[\"{\", \"author\", \"title\", \"}\"]>\n" @@ -54,7 +54,7 @@ public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldContainSequence(actual, sequenceValues, 1, new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"" + actual + "\">\n" + "to contain the following CharSequences in this order:\n" + " <[\"{\", \"author\", \"title\", \"}\"]>\n" diff --git a/src/test/java/org/assertj/core/error/ShouldContainSequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainSequence_create_Test.java index 18af486d09..7df5868ee3 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainSequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainSequence_create_Test.java @@ -19,18 +19,16 @@ import static org.assertj.core.error.ShouldContainSequence.shouldContainSequence; import static org.assertj.core.util.Lists.newArrayList; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldContainSequence; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldContainSequence#create(Description)}. + * Tests for {@link ShouldContainSequence#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -46,7 +44,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nto contain sequence:\n <[\"Han\", \"Leia\"]>\n", message); } @@ -54,7 +52,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainSequence(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nto contain sequence:\n <[\"Han\", \"Leia\"]>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldContainString_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainString_create_Test.java index ca17544921..924a49ed29 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainString_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainString_create_Test.java @@ -20,14 +20,14 @@ import static org.assertj.core.util.Arrays.array; import static org.mockito.internal.util.collections.Sets.newSet; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Test; /** - * Tests for {@link ShouldContainCharSequence#create(Description)}. + * Tests for {@link ShouldContainCharSequence#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -40,7 +40,7 @@ public class ShouldContainString_create_Test { @Test public void should_create_error_message() { factory = shouldContain("Yoda", "Luke"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto contain:\n <\"Luke\"> ", message); } @@ -48,7 +48,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldContain("Yoda", "Luke", new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto contain:\n <\"Luke\"> according to 'CaseInsensitiveStringComparator' comparator", message); } @@ -56,14 +56,14 @@ public void should_create_error_message_with_custom_comparison_strategy() { @Test public void should_create_error_message_when_ignoring_case() { factory = shouldContainIgnoringCase("Yoda", "Luke"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto contain:\n <\"Luke\">\n (ignoring case)", message); } @Test public void should_create_error_message_with_several_string_values() { factory = shouldContain("Yoda, Luke", array("Luke", "Vador", "Solo"), newSet("Vador", "Solo")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda, Luke\">\nto contain:\n <[\"Luke\", \"Vador\", \"Solo\"]>\nbut could not find:\n <[\"Vador\", \"Solo\"]>\n ", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldContainSubsequence_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainSubsequence_create_Test.java index 7ba9dbd427..29e5dee931 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainSubsequence_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainSubsequence_create_Test.java @@ -18,15 +18,15 @@ import static org.assertj.core.error.ShouldContainSubsequence.shouldContainSubsequence; import static org.assertj.core.util.Lists.newArrayList; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldContainSubsequence#create(Description)}. + * Tests for {@link ShouldContainSubsequence#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Marcin Mikosik */ @@ -42,7 +42,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nto contain subsequence:\n <[\"Han\", \"Leia\"]>\n", message); } @@ -50,7 +50,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainSubsequence(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nto contain subsequence:\n <[\"Han\", \"Leia\"]>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldContainValue_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainValue_create_Test.java index c1f26e13de..75c308e378 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainValue_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainValue_create_Test.java @@ -22,14 +22,12 @@ import java.util.Map; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldContainValue; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldContainValue#create(Description)}. + * Tests for {@link ShouldContainValue#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -39,7 +37,7 @@ public class ShouldContainValue_create_Test { public void should_create_error_message() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldContainValue(map, "VeryOld"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <{\"name\"=\"Yoda\", \"color\"=\"green\"}>\nto contain value:\n <\"VeryOld\">", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldContain_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContain_create_Test.java index 08502d7813..77924fa160 100644 --- a/src/test/java/org/assertj/core/error/ShouldContain_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContain_create_Test.java @@ -20,17 +20,15 @@ import static org.assertj.core.util.Sets.newLinkedHashSet; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldContain; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldContain#create(Description)}. + * Tests for {@link ShouldContain#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -47,7 +45,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\"]>\nto contain:\n <[\"Luke\", \"Yoda\"]>\nbut could not find:\n" + " <[\"Luke\"]>\n", message); } @@ -56,7 +54,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldContain(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\"]>\nto contain:\n <[\"Luke\", \"Yoda\"]>\nbut could not find:\n" + " <[\"Luke\"]>\naccording to 'CaseInsensitiveStringComparator' comparator", message); } @@ -65,7 +63,7 @@ public void should_create_error_message_with_custom_comparison_strategy() { @Test public void should_create_error_message_differentiating_long_from_integer() { factory = shouldContain(5L, 5, 5); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <5L>\nto contain:\n <5>\nbut could not find:\n" + " <5>\n", message); } @@ -73,7 +71,7 @@ public void should_create_error_message_differentiating_long_from_integer() { @Test public void should_create_error_message_differentiating_long_from_integer_in_arrays() { factory = shouldContain(newArrayList(5L, 7L), newArrayList(5, 7), newLinkedHashSet(5, 7)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[5L, 7L]>\nto contain:\n <[5, 7]>\nbut could not find:\n" + " <[5, 7]>\n", message); } @@ -81,7 +79,7 @@ public void should_create_error_message_differentiating_long_from_integer_in_arr @Test public void should_create_error_message_differentiating_double_from_float() { factory = shouldContain(newArrayList(5d, 7d), newArrayList(5f, 7f), newLinkedHashSet(5f, 7f)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[5.0, 7.0]>\nto contain:\n <[5.0f, 7.0f]>\nbut could not find:\n" + " <[5.0f, 7.0f]>\n", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldContainsOnlyOnce_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainsOnlyOnce_create_Test.java index 2819b437f7..0ca57d8728 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainsOnlyOnce_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainsOnlyOnce_create_Test.java @@ -19,15 +19,15 @@ import static org.assertj.core.util.Sets.newLinkedHashSet; import static org.junit.Assert.assertEquals; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldContainsOnlyOnce#create(Description)}. + * Tests for {@link ShouldContainsOnlyOnce#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author William Delanoue */ @@ -43,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n" + " <[\"Yoda\", \"Han\", \"Han\"]>\n" + "to contain only once:\n" + @@ -59,7 +59,7 @@ public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainsOnlyOnce(newArrayList("Yoda", "Han"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Luke"), newLinkedHashSet("Han"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \n" + "Expecting:\n" + " <[\"Yoda\", \"Han\"]>\n" + @@ -76,7 +76,7 @@ public void should_create_error_message_with_custom_comparison_strategy() { public void should_create_error_message_without_not_found_elements() { factory = shouldContainsOnlyOnce(newArrayList("Yoda", "Han", "Han"), newArrayList("Yoda"), newLinkedHashSet(), newLinkedHashSet("Han")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n" + " <[\"Yoda\", \"Han\", \"Han\"]>\n" + "to contain only once:\n" + @@ -89,7 +89,7 @@ public void should_create_error_message_without_not_found_elements() { public void should_create_error_message_without_elements_found_many_times() { factory = shouldContainsOnlyOnce(newArrayList("Yoda", "Han"), newArrayList("Luke"), newLinkedHashSet("Luke"), newLinkedHashSet()); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n" + " <[\"Yoda\", \"Han\"]>\n" + "to contain only once:\n" + diff --git a/src/test/java/org/assertj/core/error/ShouldContainsStringOnlyOnce_create_Test.java b/src/test/java/org/assertj/core/error/ShouldContainsStringOnlyOnce_create_Test.java index 43cc6827c4..8fd5cc6a45 100644 --- a/src/test/java/org/assertj/core/error/ShouldContainsStringOnlyOnce_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldContainsStringOnlyOnce_create_Test.java @@ -5,8 +5,8 @@ import static org.assertj.core.error.ShouldContainCharSequenceOnlyOnce.shouldContainOnlyOnce; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; import org.assertj.core.internal.*; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; @@ -25,7 +25,7 @@ public void setUp() { @Test public void should_create_error_message_when_string_to_search_appears_several_times() { - String message = factoryWithSeveralOccurences.create(new TestDescription("Test")); + String message = factoryWithSeveralOccurences.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"motif\">\nto appear only once in:\n <\"aaamotifmotifaabbbmotifaaa\">\nbut it appeared 3 times ", message); @@ -33,7 +33,7 @@ public void should_create_error_message_when_string_to_search_appears_several_ti @Test public void should_create_error_message_when_string_to_search_does_not_appear() { - String message = factoryWithNoOccurence.create(new TestDescription("Test")); + String message = factoryWithNoOccurence.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"motif\">\nto appear only once in:\n <\"aaamodifmoifaabbbmotfaaa\">\nbut it did not appear ", message); @@ -43,7 +43,7 @@ public void should_create_error_message_when_string_to_search_does_not_appear() public void should_create_error_message_when_string_to_search_does_not_appear_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainOnlyOnce("aaamoDifmoifaabbbmotfaaa", "MOtif", 0, new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"MOtif\">\nto appear only once in:\n <\"aaamoDifmoifaabbbmotfaaa\">\nbut it did not appear according to 'CaseInsensitiveStringComparator' comparator", message); @@ -53,7 +53,7 @@ public void should_create_error_message_when_string_to_search_does_not_appear_wi public void should_create_error_message_when_string_to_search_appears_several_times_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldContainOnlyOnce("aaamotIFmoTifaabbbmotifaaa", "MOtif", 3, new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"MOtif\">\nto appear only once in:\n <\"aaamotIFmoTifaabbbmotifaaa\">\nbut it appeared 3 times according to 'CaseInsensitiveStringComparator' comparator", message); diff --git a/src/test/java/org/assertj/core/error/ShouldEndWith_create_Test.java b/src/test/java/org/assertj/core/error/ShouldEndWith_create_Test.java index a6ce995637..9c91585535 100644 --- a/src/test/java/org/assertj/core/error/ShouldEndWith_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldEndWith_create_Test.java @@ -19,17 +19,15 @@ import static org.assertj.core.error.ShouldEndWith.shouldEndWith; import static org.assertj.core.util.Lists.newArrayList; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldEndWith; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Test; /** - * Tests for {@link ShouldEndWith#create(Description)}. + * Tests for {@link ShouldEndWith#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -41,7 +39,7 @@ public class ShouldEndWith_create_Test { @Test public void should_create_error_message() { factory = shouldEndWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nto end with:\n <[\"Han\", \"Leia\"]>\n", message); } @@ -49,7 +47,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldEndWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nto end with:\n <[\"Han\", \"Leia\"]>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldExist_create_Test.java b/src/test/java/org/assertj/core/error/ShouldExist_create_Test.java index 4a887e0239..686d8a5acb 100644 --- a/src/test/java/org/assertj/core/error/ShouldExist_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldExist_create_Test.java @@ -18,14 +18,12 @@ import static org.assertj.core.error.ShouldExist.shouldExist; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldExist; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldExist#create(Description)}. + * Tests for {@link ShouldExist#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +38,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting file: to exist", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldHaveAnnotations_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveAnnotations_create_Test.java index 3909c26c41..e44b1127c0 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveAnnotations_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveAnnotations_create_Test.java @@ -20,6 +20,7 @@ import java.lang.annotation.Annotation; import org.assertj.core.description.TextDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.Lists; import org.junit.Before; import org.junit.Test; @@ -44,7 +45,7 @@ Lists.> newArrayList(Override.class, Deprecated.clas @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo( "[Test] \n" + "Expecting\n" diff --git a/src/test/java/org/assertj/core/error/ShouldHaveAtIndex_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveAtIndex_create_Test.java index 108f12cb73..a5c65784c5 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveAtIndex_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveAtIndex_create_Test.java @@ -4,8 +4,7 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.data.Index; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldHaveAtIndex; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; import static org.assertj.core.error.ShouldHaveAtIndex.shouldHaveAtIndex; @@ -13,7 +12,7 @@ import static org.junit.Assert.assertEquals; /** - * Tests for {@link ShouldHaveAtIndex#create(Description)}. + * Tests for {@link ShouldHaveAtIndex#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Bo Gotthardt */ @@ -21,7 +20,7 @@ public class ShouldHaveAtIndex_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldHaveAtIndex(newArrayList("Yoda", "Luke"), new TestCondition("red lightsaber"), Index.atIndex(1), "Luke"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Luke\">\nat index <1> to have:\n \nin:\n" + " <[\"Yoda\", \"Luke\"]>\n", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldHaveComparableElementsAccordingToComparator_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveComparableElementsAccordingToComparator_create_Test.java index f7435a5467..1378027329 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveComparableElementsAccordingToComparator_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveComparableElementsAccordingToComparator_create_Test.java @@ -19,16 +19,14 @@ import static org.assertj.core.error.ShouldBeSorted.shouldHaveComparableElementsAccordingToGivenComparator; import static org.assertj.core.util.Arrays.array; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeSorted; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.*; /** - * Tests for {@link ShouldBeSorted#create(Description)}. + * Tests for {@link ShouldBeSorted#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -43,7 +41,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nsome elements are not mutually comparable according to 'CaseInsensitiveStringComparator' comparator in group:\n<[\"b\", \"c\", \"a\"]>", message); diff --git a/src/test/java/org/assertj/core/error/ShouldHaveComparableElements_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveComparableElements_create_Test.java index e34d6f2a78..f7c7a5effb 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveComparableElements_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveComparableElements_create_Test.java @@ -18,15 +18,13 @@ import static org.assertj.core.error.ShouldBeSorted.shouldHaveMutuallyComparableElements; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeSorted; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldBeSorted#create(Description)}. + * Tests for {@link ShouldBeSorted#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -42,6 +40,6 @@ public void setUp() { @Test public void should_create_error_message() { assertEquals("[Test] \nsome elements are not mutually comparable in group:\n<[\"b\", 5, \"a\"]>", - factory.create(new TestDescription("Test"))); + factory.create(new TestDescription("Test"), new StandardRepresentation())); } } diff --git a/src/test/java/org/assertj/core/error/ShouldHaveEqualContent_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveEqualContent_create_Test.java index ef9009a03e..be69f24ca2 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveEqualContent_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveEqualContent_create_Test.java @@ -22,16 +22,14 @@ import java.io.ByteArrayInputStream; import java.util.List; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldHaveEqualContent; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldHaveEqualContent#create(Description)}. + * Tests for {@link ShouldHaveEqualContent#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang * @author Matthieu Baechler @@ -55,7 +53,7 @@ public void should_create_error_message_file_even_if_content_contains_format_spe b.append("[Test] \nFile:\n \nand file:\n \ndo not have equal content:"); for (String diff : diffs) b.append(LINE_SEPARATOR).append(diff); - assertEquals(b.toString(), factory.create(new TextDescription("Test"))); + assertEquals(b.toString(), factory.create(new TextDescription("Test"), new StandardRepresentation())); } @Test @@ -67,7 +65,7 @@ public void should_create_error_message_inputstream_even_if_content_contains_for b.append("[Test] \nInputStreams do not have equal content:"); for (String diff : diffs) b.append(LINE_SEPARATOR).append(diff); - assertEquals(b.toString(), factory.create(new TextDescription("Test"))); + assertEquals(b.toString(), factory.create(new TextDescription("Test"), new StandardRepresentation())); } } diff --git a/src/test/java/org/assertj/core/error/ShouldHaveFields_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveFields_create_Test.java index b5fcd63f2c..4ee6e9da32 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveFields_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveFields_create_Test.java @@ -19,6 +19,7 @@ import static org.assertj.core.error.ShouldHaveFields.shouldHaveFields; import static org.assertj.core.util.Sets.newLinkedHashSet; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; import org.assertj.core.description.TextDescription; @@ -34,7 +35,7 @@ public class ShouldHaveFields_create_Test { @Test public void should_create_error_message_for_fields() { ErrorMessageFactory factory = shouldHaveFields(Person.class, newLinkedHashSet("name", "address"), newLinkedHashSet("address")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo( "[Test] \n" + "Expecting\n" @@ -48,7 +49,7 @@ public void should_create_error_message_for_fields() { @Test public void should_create_error_message_for_declared_fields() { ErrorMessageFactory factory = shouldHaveDeclaredFields(Person.class, newLinkedHashSet("name", "address"), newLinkedHashSet("address")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertThat(message).isEqualTo( "[Test] \n" + "Expecting\n" diff --git a/src/test/java/org/assertj/core/error/ShouldHaveSameClass_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveSameClass_create_Test.java index 1aba38840a..bf2ea7b4b6 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveSameClass_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveSameClass_create_Test.java @@ -18,15 +18,13 @@ import static org.assertj.core.error.ShouldHaveSameClass.shouldHaveSameClass; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldHaveSameClass; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldHaveSameClass#create(Description)}. + * Tests for {@link ShouldHaveSameClass#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -41,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting\n <\"Yoda\">\nto have the same class as:\n <10L>() \nbut its class was:", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldHaveSameSizeAs_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveSameSizeAs_create_Test.java index 5309e9ab26..9a2a334547 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveSameSizeAs_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveSameSizeAs_create_Test.java @@ -19,12 +19,11 @@ import static org.assertj.core.util.Lists.newArrayList; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldHaveSameSizeAs; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldHaveSameSizeAs#create(Description)}. + * Tests for {@link ShouldHaveSameSizeAs#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -39,7 +38,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nActual and expected should have same size but actual size is:\n <2>\nwhile expected is:\n <8>\nActual was:\n<[\"Luke\", \"Yoda\"]>", message); diff --git a/src/test/java/org/assertj/core/error/ShouldHaveSize_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveSize_create_Test.java index 2e7d924b33..bed105b59c 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveSize_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveSize_create_Test.java @@ -19,12 +19,11 @@ import static org.assertj.core.util.Lists.newArrayList; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldHaveSize; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldHaveSize#create(Description)}. + * Tests for {@link ShouldHaveSize#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -40,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpected size:<8> but was:<2> in:\n<[\"Luke\", \"Yoda\"]>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldHaveTime_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHaveTime_create_Test.java index 141882eaaf..86b9ff48d4 100644 --- a/src/test/java/org/assertj/core/error/ShouldHaveTime_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHaveTime_create_Test.java @@ -21,15 +21,14 @@ import java.text.ParseException; import java.util.Date; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ShouldHaveTime; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.Dates; import org.junit.Test; /** - * Tests for {@link ShouldHaveTime#create(Description)}. + * Tests for {@link ShouldHaveTime#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Guillaume Girou * @author Nicolas François @@ -41,7 +40,7 @@ public class ShouldHaveTime_create_Test { @Test public void should_create_error_message() throws ParseException { Date date = Dates.parseDatetime("2011-01-01T05:01:00"); - String message = shouldHaveTime(date, 123).create(new TextDescription("Test")); + String message = shouldHaveTime(date, 123).create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting\n <2011-01-01T05:01:00>\nto have time:\n <123L>\nbut was:\n <" + date.getTime() + "L>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldHave_create_Test.java b/src/test/java/org/assertj/core/error/ShouldHave_create_Test.java index 08355cd280..08a7a2167b 100644 --- a/src/test/java/org/assertj/core/error/ShouldHave_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldHave_create_Test.java @@ -20,12 +20,11 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldHave; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldHave#create(Description)}. + * Tests for {@link ShouldHave#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nto have:\n ", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldMatchPattern_create_Test.java b/src/test/java/org/assertj/core/error/ShouldMatchPattern_create_Test.java index aeeb519f0c..65783a28e2 100644 --- a/src/test/java/org/assertj/core/error/ShouldMatchPattern_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldMatchPattern_create_Test.java @@ -18,12 +18,11 @@ import static org.assertj.core.error.ShouldMatchPattern.shouldMatch; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldMatchPattern; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldMatchPattern#create(Description)}. + * Tests for {@link ShouldMatchPattern#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -38,7 +37,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n \"Yoda\"\nto match pattern:\n \"Luke\"", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeBetween_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeBetween_create_Test.java index 1fe0862286..3e758d2ffb 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeBetween_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeBetween_create_Test.java @@ -19,15 +19,13 @@ import static org.assertj.core.error.ShouldNotBeBetween.shouldNotBeBetween; import static org.assertj.core.util.Dates.parse; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBeBetween; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldNotBeBetween#create(Description)}. + * Tests for {@link ShouldNotBeBetween#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Joel Costigliola */ @@ -36,28 +34,28 @@ public class ShouldNotBeBetween_create_Test { @Test public void should_create_error_message_with_period_boundaries_included() { ErrorMessageFactory factory = shouldNotBeBetween(parse("2009-01-01"), parse("2011-01-01"), parse("2012-01-01"), true, true); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2009-01-01T00:00:00>\nnot to be in period:\n [2011-01-01T00:00:00, 2012-01-01T00:00:00]", message); } @Test public void should_create_error_message_with_period_lower_boundary_included() { ErrorMessageFactory factory = shouldNotBeBetween(parse("2012-01-01"), parse("2011-01-01"), parse("2012-01-01"), true, false); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2012-01-01T00:00:00>\nnot to be in period:\n [2011-01-01T00:00:00, 2012-01-01T00:00:00[", message); } @Test public void should_create_error_message_with_period_upper_boundary_included() { ErrorMessageFactory factory = shouldNotBeBetween(parse("2011-01-01"), parse("2011-01-01"), parse("2012-01-01"), false, true); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2011-01-01T00:00:00>\nnot to be in period:\n ]2011-01-01T00:00:00, 2012-01-01T00:00:00]", message); } @Test public void should_create_error_message_with_period_boundaries_excluded() { ErrorMessageFactory factory = shouldNotBeBetween(parse("2011-01-01"), parse("2011-01-01"), parse("2012-01-01"), false, false); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <2011-01-01T00:00:00>\nnot to be in period:\n ]2011-01-01T00:00:00, 2012-01-01T00:00:00[", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeEmpty_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeEmpty_create_Test.java index 2280600e4b..f7fae7d4c2 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeEmpty_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeEmpty_create_Test.java @@ -18,14 +18,12 @@ import static org.assertj.core.error.ShouldNotBeEmpty.shouldNotBeEmpty; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBeEmpty; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldNotBeEmpty#create(Description)}. + * Tests for {@link ShouldNotBeEmpty#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -41,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting actual not to be empty", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeEqual_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeEqual_create_Test.java index 314e98c866..ed13174860 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeEqual_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeEqual_create_Test.java @@ -18,17 +18,15 @@ import static org.assertj.core.error.ShouldNotBeEqual.shouldNotBeEqual; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBeEqual; import org.assertj.core.internal.*; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldNotBeEqual#create(Description)}. + * Tests for {@link ShouldNotBeEqual#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -44,14 +42,14 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Jedi")); + String message = factory.create(new TestDescription("Jedi"), new StandardRepresentation()); assertEquals("[Jedi] \nExpecting:\n <\"Yoda\">\nnot to be equal to:\n <\"Luke\">\n", message); } @Test public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldNotBeEqual("Yoda", "Luke", new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TestDescription("Jedi")); + String message = factory.create(new TestDescription("Jedi"), new StandardRepresentation()); assertEquals( "[Jedi] \nExpecting:\n <\"Yoda\">\nnot to be equal to:\n <\"Luke\">\naccording to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeExactlyInstance_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeExactlyInstance_create_Test.java index b20589b1ed..5d59414ca0 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeExactlyInstance_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeExactlyInstance_create_Test.java @@ -19,13 +19,13 @@ import java.io.File; -import org.assertj.core.description.Description; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldNotBeExactlyInstanceOf#create(Description)}. + * Tests for {@link ShouldNotBeExactlyInstanceOf#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François * @author Joel Costigliola @@ -41,7 +41,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting\n <\"Yoda\">\nnot to be of exact type:\n \nbut was:", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeIn_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeIn_create_Test.java index b336a85011..7f16a40f4e 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeIn_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeIn_create_Test.java @@ -19,18 +19,16 @@ import static org.junit.Assert.assertEquals; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBeIn; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldNotBeIn#create(Description)}. + * Tests for {@link ShouldNotBeIn#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang * @author Joel Costigliola @@ -46,7 +44,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Luke\">\nnot to be in:\n <[\"Luke\", \"Leia\"]>\n", message); } @@ -54,7 +52,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldNotBeIn("Luke", array("Luke", "Leia"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Luke\">\nnot to be in:\n <[\"Luke\", \"Leia\"]>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeInstanceOfAny_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeInstanceOfAny_create_Test.java index 729c0373fb..6d64abd486 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeInstanceOfAny_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeInstanceOfAny_create_Test.java @@ -18,15 +18,13 @@ import static org.assertj.core.error.ShouldNotBeInstanceOfAny.shouldNotBeInstanceOfAny; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldBeInstanceOfAny; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldBeInstanceOfAny#create(Description)}. + * Tests for {@link ShouldBeInstanceOfAny#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -42,7 +40,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to be an instance of any of these types:\n <[java.lang.String, java.lang.Object]>", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeInstance_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeInstance_create_Test.java index 5001826d74..693737e3c0 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeInstance_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeInstance_create_Test.java @@ -18,15 +18,13 @@ import static org.assertj.core.error.ShouldNotBeInstance.shouldNotBeInstance; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBeInstance; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldNotBeInstance#create(Description)}. + * Tests for {@link ShouldNotBeInstance#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -41,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to be an instance of:", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeNull_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeNull_create_Test.java index 7afb040544..7c63ca9799 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeNull_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeNull_create_Test.java @@ -18,14 +18,12 @@ import static org.assertj.core.error.ShouldNotBeNull.shouldNotBeNull; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBeNull; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldNotBeNull#create(Description)}. + * Tests for {@link ShouldNotBeNull#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -41,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting actual not to be null", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeOfClassIn_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeOfClassIn_Test.java index d5bc96ed13..e49272535f 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeOfClassIn_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeOfClassIn_Test.java @@ -19,15 +19,13 @@ import static org.assertj.core.util.Lists.newArrayList; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBeOfClassIn; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldNotBeOfClassIn#create(Description)}. + * Tests for {@link ShouldNotBeOfClassIn#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -43,7 +41,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals( "[Test] \nExpecting:\n <\"Yoda\">\nnot to be of any type in:\n <[java.lang.Long, java.lang.String]>\nbut was of type:", message); diff --git a/src/test/java/org/assertj/core/error/ShouldNotBeSame_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBeSame_create_Test.java index 772f3a505c..1935af2f99 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBeSame_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBeSame_create_Test.java @@ -18,14 +18,12 @@ import static org.assertj.core.error.ShouldNotBeSame.shouldNotBeSame; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBeSame; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldNotBeSame#create(Description)}. + * Tests for {@link ShouldNotBeSame#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -41,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpected not same:<\"Yoda\">", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotBe_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotBe_create_Test.java index 58791118ca..80ddb0106d 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotBe_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotBe_create_Test.java @@ -20,12 +20,11 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotBe; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldNotBe#create(Description)}. + * Tests for {@link ShouldNotBe#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to be ", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotContainAtIndex_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContainAtIndex_create_Test.java index 952199c81b..106bc54b3d 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContainAtIndex_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContainAtIndex_create_Test.java @@ -19,15 +19,15 @@ import static org.assertj.core.error.ShouldNotContainAtIndex.shouldNotContainAtIndex; import static org.assertj.core.util.Lists.*; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldNotContainAtIndex#create(Description)}. + * Tests for {@link ShouldNotContainAtIndex#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -43,7 +43,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nnot to contain:\n <\"Luke\">\nat index <1>\n", message); } @@ -51,7 +51,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldNotContainAtIndex(newArrayList("Yoda", "Luke"), "Luke", atIndex(1), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nnot to contain:\n <\"Luke\">\n" + "at index <1>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotContainKey_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContainKey_create_Test.java index f9b623ba11..9e0d4e60e3 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContainKey_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContainKey_create_Test.java @@ -22,14 +22,12 @@ import java.util.Map; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotContainKey; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldNotContainKey#create(Description)}. + * Tests for {@link ShouldNotContainKey#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -39,7 +37,7 @@ public class ShouldNotContainKey_create_Test { public void should_create_error_message() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldNotContainKey(map, "age"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <{\"name\"=\"Yoda\", \"color\"=\"green\"}>\nnot to contain key:\n <\"age\">", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotContainString_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContainString_create_Test.java index 5ae4210d34..70fc074124 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContainString_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContainString_create_Test.java @@ -18,17 +18,15 @@ import static org.assertj.core.error.ShouldNotContainCharSequence.shouldNotContain; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotContainCharSequence; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Test; /** - * Tests for {@link ShouldNotContainCharSequence#create(Description)}. + * Tests for {@link ShouldNotContainCharSequence#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -39,7 +37,7 @@ public class ShouldNotContainString_create_Test { @Test public void should_create_error_message() { ErrorMessageFactory factory = shouldNotContain("Yoda", "od"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to contain:\n <\"od\"> ", message); } @@ -47,7 +45,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldNotContain("Yoda", "od", new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to contain:\n <\"od\"> according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotContainValue_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContainValue_create_Test.java index 284577053d..338be1074f 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContainValue_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContainValue_create_Test.java @@ -21,12 +21,12 @@ import java.util.Map; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ShouldNotContainKey#create(Description)}. + * Tests for {@link ShouldNotContainKey#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -36,7 +36,7 @@ public class ShouldNotContainValue_create_Test { public void should_create_error_message() { Map map = mapOf(entry("name", "Yoda"), entry("color", "green")); ErrorMessageFactory factory = shouldNotContainValue(map, "green"); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <{\"name\"=\"Yoda\", \"color\"=\"green\"}>\nnot to contain value:\n <\"green\">", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotContain_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotContain_create_Test.java index bca2407515..84f586b025 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotContain_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotContain_create_Test.java @@ -19,14 +19,14 @@ import static org.assertj.core.util.Lists.*; import static org.assertj.core.util.Sets.*; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Test; /** - * Tests for {@link ShouldNotContain#create(Description)}. + * Tests for {@link ShouldNotContain#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Yvonne Wang @@ -38,7 +38,7 @@ public class ShouldNotContain_create_Test { public void should_create_error_message() { ErrorMessageFactory factory = shouldNotContain(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Yoda")); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting\n <[\"Yoda\"]>\nnot to contain\n <[\"Luke\", \"Yoda\"]>\nbut found\n <[\"Yoda\"]>\n", message); } @@ -47,7 +47,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { ErrorMessageFactory factory = shouldNotContain(newArrayList("Yoda"), newArrayList("Luke", "Yoda"), newLinkedHashSet("Yoda"), new ComparatorBasedComparisonStrategy(CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting\n <[\"Yoda\"]>\nnot to contain\n <[\"Luke\", \"Yoda\"]>\n" + "but found\n <[\"Yoda\"]>\naccording to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotExist_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotExist_create_Test.java index f3fd352272..0bddedb7ad 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotExist_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotExist_create_Test.java @@ -18,14 +18,12 @@ import static org.assertj.core.error.ShouldNotExist.shouldNotExist; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotExist; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldNotExist#create(Description)}. + * Tests for {@link ShouldNotExist#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +38,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting file: not to exist", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotHaveDuplicates_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotHaveDuplicates_create_Test.java index 5870e3f0ce..8bb97ec45f 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotHaveDuplicates_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotHaveDuplicates_create_Test.java @@ -19,18 +19,16 @@ import static org.assertj.core.error.ShouldNotHaveDuplicates.shouldNotHaveDuplicates; import static org.assertj.core.util.Lists.newArrayList; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotHaveDuplicates; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldNotHaveDuplicates#create(Description)}. + * Tests for {@link ShouldNotHaveDuplicates#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -46,7 +44,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nFound duplicate(s):\n <[\"Yoda\"]>\nin:\n <[\"Yoda\", \"Yoda\", \"Luke\"]>\n", message); } @@ -54,7 +52,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldNotHaveDuplicates(newArrayList("Yoda", "Yoda", "Luke"), newArrayList("Yoda"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nFound duplicate(s):\n <[\"Yoda\"]>\nin:\n <[\"Yoda\", \"Yoda\", \"Luke\"]>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/error/ShouldNotHaveSameClass_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotHaveSameClass_create_Test.java index ba55e23fe0..7482dee105 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotHaveSameClass_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotHaveSameClass_create_Test.java @@ -18,15 +18,13 @@ import static org.assertj.core.error.ShouldNotHaveSameClass.shouldNotHaveSameClass; -import org.assertj.core.description.Description; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotHaveSameClass; import org.assertj.core.internal.TestDescription; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldNotHaveSameClass#create(Description)}. + * Tests for {@link ShouldNotHaveSameClass#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Nicolas François */ @@ -41,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TestDescription("Test")); + String message = factory.create(new TestDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to have not the same class as:\n <\"Luke\"> (java.lang.String)", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotHave_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotHave_create_Test.java index b8aa389bd0..aedc3f8385 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotHave_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotHave_create_Test.java @@ -20,12 +20,11 @@ import org.assertj.core.api.TestCondition; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotHave; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldNotHave#create(Description)}. + * Tests for {@link ShouldNotHave#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Yvonne Wang */ @@ -40,7 +39,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <\"Yoda\">\nnot to have:\n ", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldNotMatchPattern_create_Test.java b/src/test/java/org/assertj/core/error/ShouldNotMatchPattern_create_Test.java index bd0abf8b61..ba9f4ca319 100644 --- a/src/test/java/org/assertj/core/error/ShouldNotMatchPattern_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldNotMatchPattern_create_Test.java @@ -18,12 +18,11 @@ import static org.assertj.core.error.ShouldNotMatchPattern.shouldNotMatch; import org.assertj.core.description.*; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldNotMatchPattern; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.*; /** - * Tests for {@link ShouldNotMatchPattern#create(Description)}. + * Tests for {@link ShouldNotMatchPattern#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz */ @@ -38,7 +37,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n \"Yoda\"\nnot to match pattern:\n \"Luke\"", message); } } diff --git a/src/test/java/org/assertj/core/error/ShouldStartWith_create_Test.java b/src/test/java/org/assertj/core/error/ShouldStartWith_create_Test.java index fb9c725a2e..fe6cb6c75f 100644 --- a/src/test/java/org/assertj/core/error/ShouldStartWith_create_Test.java +++ b/src/test/java/org/assertj/core/error/ShouldStartWith_create_Test.java @@ -19,18 +19,16 @@ import static org.assertj.core.error.ShouldStartWith.shouldStartWith; import static org.assertj.core.util.Lists.newArrayList; -import org.assertj.core.description.Description; import org.assertj.core.description.TextDescription; -import org.assertj.core.error.ErrorMessageFactory; -import org.assertj.core.error.ShouldStartWith; import org.assertj.core.internal.ComparatorBasedComparisonStrategy; +import org.assertj.core.presentation.StandardRepresentation; import org.assertj.core.util.CaseInsensitiveStringComparator; import org.junit.Before; import org.junit.Test; /** - * Tests for {@link ShouldStartWith#create(Description)}. + * Tests for {@link ShouldStartWith#create(org.assertj.core.description.Description, org.assertj.core.presentation.Representation)}. * * @author Alex Ruiz * @author Joel Costigliola @@ -46,7 +44,7 @@ public void setUp() { @Test public void should_create_error_message() { - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nto start with:\n <[\"Han\", \"Leia\"]>\n", message); } @@ -54,7 +52,7 @@ public void should_create_error_message() { public void should_create_error_message_with_custom_comparison_strategy() { factory = shouldStartWith(newArrayList("Yoda", "Luke"), newArrayList("Han", "Leia"), new ComparatorBasedComparisonStrategy( CaseInsensitiveStringComparator.instance)); - String message = factory.create(new TextDescription("Test")); + String message = factory.create(new TextDescription("Test"), new StandardRepresentation()); assertEquals("[Test] \nExpecting:\n <[\"Yoda\", \"Luke\"]>\nto start with:\n <[\"Han\", \"Leia\"]>\n" + "according to 'CaseInsensitiveStringComparator' comparator", message); } diff --git a/src/test/java/org/assertj/core/internal/bigdecimals/BigDecimals_assertEqualByComparison_Test.java b/src/test/java/org/assertj/core/internal/bigdecimals/BigDecimals_assertEqualByComparison_Test.java index d3aadd82bf..121d873479 100644 --- a/src/test/java/org/assertj/core/internal/bigdecimals/BigDecimals_assertEqualByComparison_Test.java +++ b/src/test/java/org/assertj/core/internal/bigdecimals/BigDecimals_assertEqualByComparison_Test.java @@ -29,6 +29,7 @@ import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.BigDecimals; import org.assertj.core.internal.BigDecimalsBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; @@ -56,7 +57,7 @@ public void should_fail_if_big_decimals_are_not_equal_by_comparison() { try { bigDecimals.assertEqualByComparison(info, TEN, ONE); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(TEN, ONE)); + verify(failures).failure(info, shouldBeEqual(TEN, ONE, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -79,7 +80,8 @@ public void should_fail_if_big_decimals_are_not_equal_by_comparison_whatever_cus try { bigDecimalsWithAbsValueComparisonStrategy.assertEqualByComparison(info, TEN, ONE); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(TEN, ONE, absValueComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual(TEN, ONE, absValueComparisonStrategy, + new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/bigdecimals/BigDecimals_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/bigdecimals/BigDecimals_assertEqual_Test.java index f97417ce65..28096418fe 100644 --- a/src/test/java/org/assertj/core/internal/bigdecimals/BigDecimals_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/bigdecimals/BigDecimals_assertEqual_Test.java @@ -29,6 +29,7 @@ import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.BigDecimals; import org.assertj.core.internal.BigDecimalsBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; @@ -58,7 +59,7 @@ public void should_fail_if_big_decimals_are_not_equal() { try { bigDecimals.assertEqual(info, ONE_WITH_3_DECIMALS, ONE); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(ONE_WITH_3_DECIMALS, ONE)); + verify(failures).failure(info, shouldBeEqual(ONE_WITH_3_DECIMALS, ONE, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -81,7 +82,8 @@ public void should_fail_if_big_decimals_are_not_equal_according_to_custom_compar try { bigDecimalsWithComparatorComparisonStrategy.assertEqual(info, TEN, ONE); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(TEN, ONE, comparatorComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual(TEN, ONE, comparatorComparisonStrategy, + new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/booleanarrays/BooleanArrays_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/booleanarrays/BooleanArrays_assertHasSameSizeAs_with_Array_Test.java index 7367e62a20..7002a82be8 100644 --- a/src/test/java/org/assertj/core/internal/booleanarrays/BooleanArrays_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/booleanarrays/BooleanArrays_assertHasSameSizeAs_with_Array_Test.java @@ -51,7 +51,7 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/booleanarrays/BooleanArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/booleanarrays/BooleanArrays_assertHasSameSizeAs_with_Iterable_Test.java index 2ac87f8b77..f8e6602776 100644 --- a/src/test/java/org/assertj/core/internal/booleanarrays/BooleanArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/booleanarrays/BooleanArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -55,7 +55,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/booleans/Booleans_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/booleans/Booleans_assertEqual_Test.java index 88fe9fb2a7..0292532211 100644 --- a/src/test/java/org/assertj/core/internal/booleans/Booleans_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/booleans/Booleans_assertEqual_Test.java @@ -56,7 +56,7 @@ public void should_fail_if_booleans_are_not_equal() { try { booleans.assertEqual(info, TRUE, expected); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(TRUE, expected)); + verify(failures).failure(info, shouldBeEqual(TRUE, expected, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/bytearrays/ByteArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/bytearrays/ByteArrays_assertHasSameSizeAs_with_Iterable_Test.java index ff1bb19ee5..4287fbc1f0 100644 --- a/src/test/java/org/assertj/core/internal/bytearrays/ByteArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/bytearrays/ByteArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -27,7 +27,6 @@ import java.util.List; import org.assertj.core.api.AssertionInfo; -import org.assertj.core.internal.ByteArrays; import org.assertj.core.internal.ByteArraysBaseTest; import org.junit.Test; @@ -47,7 +46,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertEqual_Test.java index dd7599e7e1..2a733bd53e 100644 --- a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertEqual_Test.java @@ -25,6 +25,7 @@ import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.Bytes; import org.assertj.core.internal.BytesBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; @@ -53,7 +54,7 @@ public void should_fail_if_bytes_are_not_equal() { try { bytes.assertEqual(info, (byte) 6, (byte) 8); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual((byte) 6, (byte) 8)); + verify(failures).failure(info, shouldBeEqual((byte) 6, (byte) 8, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -76,7 +77,8 @@ public void should_fail_if_bytes_are_not_equal_according_to_custom_comparison_st try { bytesWithAbsValueComparisonStrategy.assertEqual(info, (byte) 6, (byte) 8); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual((byte) 6, (byte) 8, absValueComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual((byte) 6, (byte) 8, absValueComparisonStrategy, + new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNegative_Test.java b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNegative_Test.java index 4bd510a5ed..90f5525939 100644 --- a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNegative_Test.java +++ b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNegative_Test.java @@ -14,6 +14,7 @@ */ package org.assertj.core.internal.bytes; +import static org.assertj.core.test.TestData.someHexInfo; import static org.assertj.core.test.TestData.someInfo; import org.assertj.core.api.AssertionInfo; @@ -37,20 +38,37 @@ public void should_succeed_since_actual_is_negative() { @Test public void should_fail_since_actual_is_not_negative() { - thrown.expectAssertionError("\nExpecting:\n <0x06>\nto be less than:\n <0x00>"); + thrown.expectAssertionError("\nExpecting:\n <6>\nto be less than:\n <0>"); bytes.assertIsNegative(someInfo(), (byte) 0x06); } + @Test + public void should_fail_since_actual_is_not_negative_with_hex_representation() { + thrown.expectAssertionError("\nExpecting:\n <0x06>\nto be less than:\n <0x00>"); + bytes.assertIsNegative(someHexInfo(), (byte) 0x06); + } + @Test public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy() { + thrown.expectAssertionError("\nExpecting:\n <-6>\nto be less than:\n <0> according to 'AbsValueComparator' comparator"); + bytesWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (byte) -6); + } + + @Test + public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy_in_hex_representation() { thrown.expectAssertionError("\nExpecting:\n <0xFA>\nto be less than:\n <0x00> according to 'AbsValueComparator' comparator"); - bytesWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (byte) 0xFA); + bytesWithAbsValueComparisonStrategy.assertIsNegative(someHexInfo(), (byte) 0xFA); } @Test public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy2() { + thrown.expectAssertionError("\nExpecting:\n <6>\nto be less than:\n <0> according to 'AbsValueComparator' comparator"); + bytesWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (byte) 6); + } + @Test + public void should_fail_since_actual_is_not_negative_according_to_absolute_value_comparison_strategy2_in_hex_representation() { thrown.expectAssertionError("\nExpecting:\n <0x06>\nto be less than:\n <0x00> according to 'AbsValueComparator' comparator"); - bytesWithAbsValueComparisonStrategy.assertIsNegative(someInfo(), (byte) 0x06); + bytesWithAbsValueComparisonStrategy.assertIsNegative(someHexInfo(), (byte) 0x06); } } diff --git a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotNegative_Test.java b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotNegative_Test.java index 3fea0e4bca..319150dd5e 100644 --- a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotNegative_Test.java +++ b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotNegative_Test.java @@ -14,6 +14,7 @@ */ package org.assertj.core.internal.bytes; +import static org.assertj.core.test.TestData.someHexInfo; import static org.assertj.core.test.TestData.someInfo; import org.assertj.core.api.AssertionInfo; @@ -41,8 +42,14 @@ public void should_succeed_since_actual_is_zero() { @Test public void should_fail_since_actual_is_negative() { + thrown.expectAssertionError("\nExpecting:\n <-6>\nto be greater than or equal to:\n <0>"); + bytes.assertIsNotNegative(someInfo(), (byte) -6); + } + + @Test + public void should_fail_since_actual_is_negative_in_hex_representation() { thrown.expectAssertionError("\nExpecting:\n <0xFA>\nto be greater than or equal to:\n <0x00>"); - bytes.assertIsNotNegative(someInfo(), (byte) 0xFA); + bytes.assertIsNotNegative(someHexInfo(), (byte) 0xFA); } @Test diff --git a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotPositive_Test.java b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotPositive_Test.java index 20f7967338..22a1321483 100644 --- a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotPositive_Test.java +++ b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotPositive_Test.java @@ -14,6 +14,7 @@ */ package org.assertj.core.internal.bytes; +import static org.assertj.core.test.TestData.someHexInfo; import static org.assertj.core.test.TestData.someInfo; import org.assertj.core.api.AssertionInfo; @@ -41,20 +42,38 @@ public void should_succeed_since_actual_is_zero() { @Test public void should_fail_since_actual_is_positive() { + thrown.expectAssertionError("\nExpecting:\n <6>\nto be less than or equal to:\n <0>"); + bytes.assertIsNotPositive(someInfo(), (byte) 6); + } + + @Test + public void should_fail_since_actual_is_positive_in_hex_representation() { thrown.expectAssertionError("\nExpecting:\n <0x06>\nto be less than or equal to:\n <0x00>"); - bytes.assertIsNotPositive(someInfo(), (byte) 0x06); + bytes.assertIsNotPositive(someHexInfo(), (byte) 0x06); } @Test public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy() { + thrown.expectAssertionError("\nExpecting:\n <-1>\nto be less than or equal to:\n <0> according to 'AbsValueComparator' comparator"); + bytesWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), (byte) -1); + } + + @Test + public void should_fail_since_actual_can_be_positive_according_to_custom_comparison_strategy_in_hex_representation() { thrown.expectAssertionError("\nExpecting:\n <0xFF>\nto be less than or equal to:\n <0x00> according to 'AbsValueComparator' comparator"); - bytesWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), (byte) 0xFF); + bytesWithAbsValueComparisonStrategy.assertIsNotPositive(someHexInfo(), (byte) 0xFF); } @Test public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy() { + thrown.expectAssertionError("\nExpecting:\n <1>\nto be less than or equal to:\n <0> according to 'AbsValueComparator' comparator"); + bytesWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), (byte) 1); + } + + @Test + public void should_fail_since_actual_is_positive_according_to_custom_comparison_strategy_in_hex_representation() { thrown.expectAssertionError("\nExpecting:\n <0x01>\nto be less than or equal to:\n <0x00> according to 'AbsValueComparator' comparator"); - bytesWithAbsValueComparisonStrategy.assertIsNotPositive(someInfo(), (byte) 0x01); + bytesWithAbsValueComparisonStrategy.assertIsNotPositive(someHexInfo(), (byte) 0x01); } } diff --git a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotZero_Test.java b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotZero_Test.java index 8e6e6c9732..a7ba8812ca 100644 --- a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotZero_Test.java +++ b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsNotZero_Test.java @@ -3,17 +3,18 @@ * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the * License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. - * + * * Copyright @2010-2011 the original author or authors. */ package org.assertj.core.internal.bytes; +import static org.assertj.core.test.TestData.someHexInfo; import static org.assertj.core.test.TestData.someInfo; import static org.junit.Assert.assertEquals; @@ -39,8 +40,14 @@ public void should_succeed_since_actual_is_not_zero() { @Test public void should_fail_since_actual_is_zero() { + thrown.expectAssertionError("\nExpecting:\n <0>\nnot to be equal to:\n <0>\n"); + bytes.assertIsNotZero(someInfo(), (byte) 0); + } + + @Test + public void should_fail_since_actual_is_zero_in_hex_representation() { thrown.expectAssertionError("\nExpecting:\n <0x00>\nnot to be equal to:\n <0x00>\n"); - bytes.assertIsNotZero(someInfo(), (byte) 0x00); + bytes.assertIsNotZero(someHexInfo(), (byte) 0x00); } @Test @@ -48,10 +55,24 @@ public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strat bytesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (byte) 1); } + @Test + public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is_in_hex_representation() { + bytesWithAbsValueComparisonStrategy.assertIsNotZero(someHexInfo(), (byte) 0x01); + } + @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { - bytesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (byte) 0x00); + bytesWithAbsValueComparisonStrategy.assertIsNotZero(someInfo(), (byte) 0); + } catch (AssertionError e) { + assertEquals(e.getMessage(), "\nExpecting:\n <0>\nnot to be equal to:\n <0>\n"); + } + } + + @Test + public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is_in_hex_representation() { + try { + bytesWithAbsValueComparisonStrategy.assertIsNotZero(someHexInfo(), (byte) 0x00); } catch (AssertionError e) { assertEquals(e.getMessage(), "\nExpecting:\n <0x00>\nnot to be equal to:\n <0x00>\n"); } diff --git a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsPositive_Test.java b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsPositive_Test.java index b5df05897b..2847a3f005 100644 --- a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsPositive_Test.java +++ b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsPositive_Test.java @@ -14,6 +14,7 @@ */ package org.assertj.core.internal.bytes; +import static org.assertj.core.test.TestData.someHexInfo; import static org.assertj.core.test.TestData.someInfo; import org.assertj.core.api.AssertionInfo; @@ -36,8 +37,14 @@ public void should_succeed_since_actual_is_positive() { @Test public void should_fail_since_actual_is_not_positive() { + thrown.expectAssertionError("\nExpecting:\n <-1>\nto be greater than:\n <0>"); + bytes.assertIsPositive(someInfo(), (byte) -1); + } + + @Test + public void should_fail_since_actual_is_not_positive_in_hex_representation() { thrown.expectAssertionError("\nExpecting:\n <0xFA>\nto be greater than:\n <0x00>"); - bytes.assertIsPositive(someInfo(), (byte) 0xFA); + bytes.assertIsPositive(someHexInfo(), (byte) 0xFA); } @Test @@ -47,8 +54,15 @@ public void should_succeed_since_actual_is_positive_according_to_custom_comparis @Test public void should_fail_since_actual_is_not_positive_according_to_custom_comparison_strategy() { + thrown + .expectAssertionError("\nExpecting:\n <0>\nto be greater than:\n <0> according to 'AbsValueComparator' comparator"); + bytesWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), (byte) 0); + } + + @Test + public void should_fail_since_actual_is_not_positive_according_to_custom_comparison_strategy_in_hex_representation() { thrown .expectAssertionError("\nExpecting:\n <0x00>\nto be greater than:\n <0x00> according to 'AbsValueComparator' comparator"); - bytesWithAbsValueComparisonStrategy.assertIsPositive(someInfo(), (byte) 0x00); + bytesWithAbsValueComparisonStrategy.assertIsPositive(someHexInfo(), (byte) 0x00); } } diff --git a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsZero_Test.java b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsZero_Test.java index b7d3e0906a..d896989c77 100644 --- a/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsZero_Test.java +++ b/src/test/java/org/assertj/core/internal/bytes/Bytes_assertIsZero_Test.java @@ -14,6 +14,7 @@ */ package org.assertj.core.internal.bytes; +import static org.assertj.core.test.TestData.someHexInfo; import static org.assertj.core.test.TestData.someInfo; import static org.junit.Assert.assertEquals; @@ -46,7 +47,16 @@ public void should_succeed_since_actual_is_zero() { @Test public void should_fail_since_actual_is_not_zero() { try { - bytes.assertIsZero(someInfo(), (byte) 0x02); + bytes.assertIsZero(someInfo(), (byte) 2); + } catch (AssertionError e) { + assertEquals("expected:<[0]> but was:<[2]>", e.getMessage()); + } + } + + @Test + public void should_fail_since_actual_is_not_zero_in_hex_representation() { + try { + bytes.assertIsZero(someHexInfo(), (byte) 0x02); } catch (AssertionError e) { assertEquals("expected:<0x0[0]> but was:<0x0[2]>", e.getMessage()); } @@ -54,13 +64,27 @@ public void should_fail_since_actual_is_not_zero() { @Test public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is() { - bytesWithAbsValueComparisonStrategy.assertIsZero(someInfo(), (byte) 0x00); + bytesWithAbsValueComparisonStrategy.assertIsZero(someInfo(), (byte) 0); + } + + @Test + public void should_succeed_since_actual_is_zero_whatever_custom_comparison_strategy_is_in_hex_representation() { + bytesWithAbsValueComparisonStrategy.assertIsZero(someHexInfo(), (byte) 0x00); } @Test public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is() { try { - bytesWithAbsValueComparisonStrategy.assertIsZero(someInfo(), (byte) 0x01); + bytesWithAbsValueComparisonStrategy.assertIsZero(someInfo(), (byte) 1); + } catch (AssertionError e) { + assertEquals("expected:<[0]> but was:<[1]>", e.getMessage()); + } + } + + @Test + public void should_fail_since_actual_is_not_zero_whatever_custom_comparison_strategy_is_in_hex_representation() { + try { + bytesWithAbsValueComparisonStrategy.assertIsZero(someHexInfo(), (byte) 0x01); } catch (AssertionError e) { assertEquals("expected:<0x0[0]> but was:<0x0[1]>", e.getMessage()); } diff --git a/src/test/java/org/assertj/core/internal/characters/Characters_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/characters/Characters_assertEqual_Test.java index 63223a829b..5ad7809280 100644 --- a/src/test/java/org/assertj/core/internal/characters/Characters_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/characters/Characters_assertEqual_Test.java @@ -25,6 +25,7 @@ import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.Characters; import org.assertj.core.internal.CharactersBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; @@ -53,7 +54,7 @@ public void should_fail_if_characters_are_not_equal() { try { charactersWithCaseInsensitiveComparisonStrategy.assertEqual(info, 'b', 'a'); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual('b', 'a')); + verify(failures).failure(info, shouldBeEqual('b', 'a', info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -76,7 +77,8 @@ public void should_fail_if_characters_are_not_equal_according_to_custom_comparis try { charactersWithCaseInsensitiveComparisonStrategy.assertEqual(info, 'b', 'a'); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual('b', 'a', caseInsensitiveComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual('b', 'a', caseInsensitiveComparisonStrategy, + new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/chararrays/CharArrays_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/chararrays/CharArrays_assertHasSameSizeAs_with_Array_Test.java index ead920e441..2002d21841 100644 --- a/src/test/java/org/assertj/core/internal/chararrays/CharArrays_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/chararrays/CharArrays_assertHasSameSizeAs_with_Array_Test.java @@ -51,7 +51,7 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/chararrays/CharArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/chararrays/CharArrays_assertHasSameSizeAs_with_Iterable_Test.java index 7c0c943595..03adb14fd8 100644 --- a/src/test/java/org/assertj/core/internal/chararrays/CharArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/chararrays/CharArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -21,13 +21,9 @@ import static org.assertj.core.util.FailureMessages.actualIsNull; import static org.assertj.core.util.Lists.newArrayList; - -import static org.mockito.Mockito.verify; - import java.util.List; import org.assertj.core.api.AssertionInfo; -import org.assertj.core.internal.CharArrays; import org.assertj.core.internal.CharArraysBaseTest; import org.junit.Test; @@ -49,7 +45,7 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/comparables/Comparables_assertEqualByComparison_Test.java b/src/test/java/org/assertj/core/internal/comparables/Comparables_assertEqualByComparison_Test.java index f45fcf24e5..6a797f43ab 100644 --- a/src/test/java/org/assertj/core/internal/comparables/Comparables_assertEqualByComparison_Test.java +++ b/src/test/java/org/assertj/core/internal/comparables/Comparables_assertEqualByComparison_Test.java @@ -68,7 +68,7 @@ public void should_fail_if_objects_are_not_equal() { try { comparables.assertEqualByComparison(info, "Luke", "Yoda"); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual("Luke", "Yoda")); + verify(failures).failure(info, shouldBeEqual("Luke", "Yoda", info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -100,7 +100,7 @@ public void should_fail_if_objects_are_not_equal_whatever_custom_comparison_stra try { comparablesWithCustomComparisonStrategy.assertEqualByComparison(info, "Luke", "Yoda"); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual("Luke", "Yoda")); + verify(failures).failure(info, shouldBeEqual("Luke", "Yoda", info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/doublearrays/DoubleArrays_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/doublearrays/DoubleArrays_assertHasSameSizeAs_with_Array_Test.java index 510ef8ab99..881e4d3392 100644 --- a/src/test/java/org/assertj/core/internal/doublearrays/DoubleArrays_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/doublearrays/DoubleArrays_assertHasSameSizeAs_with_Array_Test.java @@ -51,7 +51,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/doublearrays/DoubleArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/doublearrays/DoubleArrays_assertHasSameSizeAs_with_Iterable_Test.java index f7872a406e..90d56bd0e2 100644 --- a/src/test/java/org/assertj/core/internal/doublearrays/DoubleArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/doublearrays/DoubleArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -21,13 +21,9 @@ import static org.assertj.core.util.FailureMessages.actualIsNull; import static org.assertj.core.util.Lists.newArrayList; - -import static org.mockito.Mockito.verify; - import java.util.List; import org.assertj.core.api.AssertionInfo; -import org.assertj.core.internal.DoubleArrays; import org.assertj.core.internal.DoubleArraysBaseTest; import org.junit.Test; @@ -49,7 +45,7 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/doubles/Doubles_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/doubles/Doubles_assertEqual_Test.java index cf03254362..1b9ae8cd69 100644 --- a/src/test/java/org/assertj/core/internal/doubles/Doubles_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/doubles/Doubles_assertEqual_Test.java @@ -25,9 +25,9 @@ import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.Doubles; import org.assertj.core.internal.DoublesBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; - /** * Tests for {@link Doubles#assertEqual(AssertionInfo, Double, double)}. * @@ -53,7 +53,7 @@ public void should_fail_if_doubles_are_not_equal() { try { doubles.assertEqual(info, 6d, 8d); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(6d, 8d)); + verify(failures).failure(info, shouldBeEqual(6d, 8d, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -76,7 +76,8 @@ public void should_fail_if_doubles_are_not_equal_according_to_custom_comparison_ try { doublesWithAbsValueComparisonStrategy.assertEqual(info, 6d, 8d); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(6d, 8d, absValueComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual(6d, 8d, absValueComparisonStrategy, + new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/failures/Failures_failure_with_AssertionErrorFactory_Test.java b/src/test/java/org/assertj/core/internal/failures/Failures_failure_with_AssertionErrorFactory_Test.java index 58606bf9c3..ef6910825f 100644 --- a/src/test/java/org/assertj/core/internal/failures/Failures_failure_with_AssertionErrorFactory_Test.java +++ b/src/test/java/org/assertj/core/internal/failures/Failures_failure_with_AssertionErrorFactory_Test.java @@ -59,7 +59,7 @@ public void should_use_AssertionErrorFactory_when_overriding_error_message_is_no MyOwnAssertionError expectedError = new MyOwnAssertionError("[description] my message"); Description description = new TestDescription("description"); info.description(description); - when(errorFactory.newAssertionError(description)).thenReturn(expectedError); + when(errorFactory.newAssertionError(description, info.representation())).thenReturn(expectedError); AssertionError failure = failures.failure(info, errorFactory); assertSame(expectedError, failure); } diff --git a/src/test/java/org/assertj/core/internal/failures/Failures_failure_with_ErrorMessage_Test.java b/src/test/java/org/assertj/core/internal/failures/Failures_failure_with_ErrorMessage_Test.java index 9c74ff3780..64e6f81374 100644 --- a/src/test/java/org/assertj/core/internal/failures/Failures_failure_with_ErrorMessage_Test.java +++ b/src/test/java/org/assertj/core/internal/failures/Failures_failure_with_ErrorMessage_Test.java @@ -56,7 +56,7 @@ public void should_create_use_overriding_error_message_if_it_is_specified() { public void should_use_ErrorMessage_when_overriding_error_message_is_not_specified() { Description description = new TestDescription("description"); info.description(description); - when(errorMessage.create(description)).thenReturn("[description] my message"); + when(errorMessage.create(description, info.representation())).thenReturn("[description] my message"); AssertionError failure = failures.failure(info, errorMessage); assertEquals("[description] my message", failure.getMessage()); } diff --git a/src/test/java/org/assertj/core/internal/floatarrays/FloatArrays_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/floatarrays/FloatArrays_assertHasSameSizeAs_with_Array_Test.java index 509837a119..ccbfb48e68 100644 --- a/src/test/java/org/assertj/core/internal/floatarrays/FloatArrays_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/floatarrays/FloatArrays_assertHasSameSizeAs_with_Array_Test.java @@ -51,7 +51,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/floatarrays/FloatArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/floatarrays/FloatArrays_assertHasSameSizeAs_with_Iterable_Test.java index 1a3596aae9..fe98e75ded 100644 --- a/src/test/java/org/assertj/core/internal/floatarrays/FloatArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/floatarrays/FloatArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -27,7 +27,6 @@ import java.util.List; import org.assertj.core.api.AssertionInfo; -import org.assertj.core.internal.FloatArrays; import org.assertj.core.internal.FloatArraysBaseTest; import org.junit.Test; @@ -49,7 +48,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/floats/Floats_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/floats/Floats_assertEqual_Test.java index 8a5007fd0f..290f9d9948 100644 --- a/src/test/java/org/assertj/core/internal/floats/Floats_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/floats/Floats_assertEqual_Test.java @@ -19,12 +19,12 @@ import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.assertj.core.util.FailureMessages.actualIsNull; - import static org.mockito.Mockito.verify; import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.Floats; import org.assertj.core.internal.FloatsBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; @@ -53,7 +53,7 @@ public void should_fail_if_floats_are_not_equal() { try { floats.assertEqual(info, 6f, 8f); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(6f, 8f)); + verify(failures).failure(info, shouldBeEqual(6f, 8f, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -76,7 +76,8 @@ public void should_fail_if_floats_are_not_equal_according_to_custom_comparison_s try { floatsWithAbsValueComparisonStrategy.assertEqual(info, 6f, -8f); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(6f, -8f, absValueComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual(6f, -8f, absValueComparisonStrategy, + new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/intarrays/IntArrays_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/intarrays/IntArrays_assertHasSameSizeAs_with_Array_Test.java index 2c63807236..5dfb04fbb9 100644 --- a/src/test/java/org/assertj/core/internal/intarrays/IntArrays_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/intarrays/IntArrays_assertHasSameSizeAs_with_Array_Test.java @@ -21,15 +21,10 @@ import static org.assertj.core.util.Arrays.array; import static org.assertj.core.util.FailureMessages.actualIsNull; - -import static org.mockito.Mockito.verify; - import org.assertj.core.api.AssertionInfo; -import org.assertj.core.internal.IntArrays; import org.assertj.core.internal.IntArraysBaseTest; import org.junit.Test; - public class IntArrays_assertHasSameSizeAs_with_Array_Test extends IntArraysBaseTest { @Test @@ -45,7 +40,7 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/intarrays/IntArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/intarrays/IntArrays_assertHasSameSizeAs_with_Iterable_Test.java index 174beb06f1..8094f61c5b 100644 --- a/src/test/java/org/assertj/core/internal/intarrays/IntArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/intarrays/IntArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -55,7 +55,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/integers/Integers_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/integers/Integers_assertEqual_Test.java index 2407018daf..4f787f250e 100644 --- a/src/test/java/org/assertj/core/internal/integers/Integers_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/integers/Integers_assertEqual_Test.java @@ -53,7 +53,7 @@ public void should_fail_if_integers_are_not_equal() { try { integers.assertEqual(info, 6, 8); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(6, 8)); + verify(failures).failure(info, shouldBeEqual(6, 8, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -76,7 +76,7 @@ public void should_fail_if_integers_are_not_equal_according_to_custom_comparison try { integersWithAbsValueComparisonStrategy.assertEqual(info, 6, -8); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(6, -8, absValueComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual(6, -8, absValueComparisonStrategy, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/iterables/Iterables_assertContainsExactly_Test.java b/src/test/java/org/assertj/core/internal/iterables/Iterables_assertContainsExactly_Test.java index abd6fa89cf..d2c20cfc6e 100644 --- a/src/test/java/org/assertj/core/internal/iterables/Iterables_assertContainsExactly_Test.java +++ b/src/test/java/org/assertj/core/internal/iterables/Iterables_assertContainsExactly_Test.java @@ -112,7 +112,8 @@ public void should_fail_if_actual_contains_all_given_values_but_size_differ() { try { iterables.assertContainsExactly(info, actual, expected); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), expected.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), expected.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/iterables/Iterables_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/iterables/Iterables_assertHasSameSizeAs_with_Array_Test.java index ff68c910e2..20d48f8598 100644 --- a/src/test/java/org/assertj/core/internal/iterables/Iterables_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/iterables/Iterables_assertHasSameSizeAs_with_Array_Test.java @@ -65,7 +65,8 @@ public void should_fail_if_actual_size_is_not_equal_to_other_size() { try { iterables.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -97,7 +98,8 @@ public void should_fail_if_actual_size_is_not_equal_to_other_size_whatever_custo try { iterablesWithCaseInsensitiveComparisonStrategy.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/iterables/Iterables_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/iterables/Iterables_assertHasSameSizeAs_with_Iterable_Test.java index 4c657e3489..d10ed1ab1b 100644 --- a/src/test/java/org/assertj/core/internal/iterables/Iterables_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/iterables/Iterables_assertHasSameSizeAs_with_Iterable_Test.java @@ -64,7 +64,8 @@ public void should_fail_if_actual_size_is_not_equal_to_other_size() { try { iterables.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -96,7 +97,8 @@ public void should_fail_if_actual_size_is_not_equal_to_other_size_whatever_custo try { iterablesWithCaseInsensitiveComparisonStrategy.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/longarrays/LongArrays_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/longarrays/LongArrays_assertHasSameSizeAs_with_Array_Test.java index 01405ee58f..3c9c0bf9e1 100644 --- a/src/test/java/org/assertj/core/internal/longarrays/LongArrays_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/longarrays/LongArrays_assertHasSameSizeAs_with_Array_Test.java @@ -51,7 +51,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/longarrays/LongArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/longarrays/LongArrays_assertHasSameSizeAs_with_Iterable_Test.java index f99b545029..72d7393b3f 100644 --- a/src/test/java/org/assertj/core/internal/longarrays/LongArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/longarrays/LongArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -55,7 +55,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/longs/Longs_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/longs/Longs_assertEqual_Test.java index eb78020eba..b668a541bb 100644 --- a/src/test/java/org/assertj/core/internal/longs/Longs_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/longs/Longs_assertEqual_Test.java @@ -19,15 +19,14 @@ import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.assertj.core.util.FailureMessages.actualIsNull; - import static org.mockito.Mockito.verify; import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.Longs; import org.assertj.core.internal.LongsBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; - /** * Tests for {@link Longs#assertEqual(AssertionInfo, Long, long)}. * @@ -53,7 +52,7 @@ public void should_fail_if_longs_are_not_equal() { try { longs.assertEqual(info, 6L, 8L); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(6L, 8L)); + verify(failures).failure(info, shouldBeEqual(6L, 8L, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -76,7 +75,7 @@ public void should_fail_if_longs_are_not_equal_according_to_custom_comparison_st try { longsWithAbsValueComparisonStrategy.assertEqual(info, 6L, 8L); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(6L, 8L, absValueComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual(6L, 8L, absValueComparisonStrategy, new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/maps/Maps_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/maps/Maps_assertHasSameSizeAs_with_Array_Test.java index 98bad03447..9853d5ba84 100644 --- a/src/test/java/org/assertj/core/internal/maps/Maps_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/maps/Maps_assertHasSameSizeAs_with_Array_Test.java @@ -63,7 +63,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { maps.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/maps/Maps_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/maps/Maps_assertHasSameSizeAs_with_Iterable_Test.java index 5484f1ff9c..5526572389 100644 --- a/src/test/java/org/assertj/core/internal/maps/Maps_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/maps/Maps_assertHasSameSizeAs_with_Iterable_Test.java @@ -64,7 +64,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { maps.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.size(), other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/objectarrays/ObjectArrays_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/objectarrays/ObjectArrays_assertHasSameSizeAs_with_Array_Test.java index c53f29d227..4cb68a4d6a 100644 --- a/src/test/java/org/assertj/core/internal/objectarrays/ObjectArrays_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/objectarrays/ObjectArrays_assertHasSameSizeAs_with_Array_Test.java @@ -60,7 +60,8 @@ public void should_fail_if_actual_size_is_not_equal_to_other_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/objectarrays/ObjectArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/objectarrays/ObjectArrays_assertHasSameSizeAs_with_Iterable_Test.java index ea7fd5afd9..1017922ddf 100644 --- a/src/test/java/org/assertj/core/internal/objectarrays/ObjectArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/objectarrays/ObjectArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -63,7 +63,8 @@ public void should_fail_if_actual_size_is_not_equal_to_other_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/objects/Objects_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/objects/Objects_assertEqual_Test.java index da1460a21d..4f85740e6b 100644 --- a/src/test/java/org/assertj/core/internal/objects/Objects_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/objects/Objects_assertEqual_Test.java @@ -18,15 +18,14 @@ import static org.assertj.core.test.TestData.someInfo; import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; - import static org.mockito.Mockito.verify; import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.Objects; import org.assertj.core.internal.ObjectsBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; - /** * Tests for {@link Objects#assertEqual(AssertionInfo, Object, Object)}. * @@ -46,7 +45,7 @@ public void should_fail_if_objects_are_not_equal() { try { objects.assertEqual(info, "Luke", "Yoda"); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual("Luke", "Yoda")); + verify(failures).failure(info, shouldBeEqual("Luke", "Yoda", info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -63,7 +62,8 @@ public void should_fail_if_objects_are_not_equal_according_to_custom_comparison_ try { objectsWithCustomComparisonStrategy.assertEqual(info, "Luke", "Yoda"); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual("Luke", "Yoda", customComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual("Luke", "Yoda", customComparisonStrategy, + new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/objects/Objects_assertNull_Test.java b/src/test/java/org/assertj/core/internal/objects/Objects_assertNull_Test.java index db6514524b..064a686e28 100644 --- a/src/test/java/org/assertj/core/internal/objects/Objects_assertNull_Test.java +++ b/src/test/java/org/assertj/core/internal/objects/Objects_assertNull_Test.java @@ -47,7 +47,7 @@ public void should_fail_if_object_is_not_null() { try { objects.assertNull(info, actual); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(actual, null)); + verify(failures).failure(info, shouldBeEqual(actual, null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/shortarrays/ShortArrays_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/shortarrays/ShortArrays_assertHasSameSizeAs_with_Array_Test.java index 73e4414646..5bc6bd40b8 100644 --- a/src/test/java/org/assertj/core/internal/shortarrays/ShortArrays_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/shortarrays/ShortArrays_assertHasSameSizeAs_with_Array_Test.java @@ -53,7 +53,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/shortarrays/ShortArrays_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/shortarrays/ShortArrays_assertHasSameSizeAs_with_Iterable_Test.java index fc01a4b3e9..d608400110 100644 --- a/src/test/java/org/assertj/core/internal/shortarrays/ShortArrays_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/shortarrays/ShortArrays_assertHasSameSizeAs_with_Iterable_Test.java @@ -62,7 +62,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { arrays.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length, other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/shorts/Shorts_assertEqual_Test.java b/src/test/java/org/assertj/core/internal/shorts/Shorts_assertEqual_Test.java index 4935387d76..15bfa63575 100644 --- a/src/test/java/org/assertj/core/internal/shorts/Shorts_assertEqual_Test.java +++ b/src/test/java/org/assertj/core/internal/shorts/Shorts_assertEqual_Test.java @@ -19,15 +19,14 @@ import static org.assertj.core.test.TestFailures.failBecauseExpectedAssertionErrorWasNotThrown; import static org.assertj.core.util.FailureMessages.actualIsNull; - import static org.mockito.Mockito.verify; import org.assertj.core.api.AssertionInfo; import org.assertj.core.internal.Shorts; import org.assertj.core.internal.ShortsBaseTest; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; - /** * Tests for {@link Shorts#assertEqual(AssertionInfo, Short, short)}. * @@ -53,7 +52,7 @@ public void should_fail_if_shorts_are_not_equal() { try { shorts.assertEqual(info, (short) 6, (short) 8); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual((short) 6, (short) 8)); + verify(failures).failure(info, shouldBeEqual((short) 6, (short) 8, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -76,7 +75,8 @@ public void should_fail_if_shorts_are_not_equal_according_to_custom_comparison_s try { shortsWithAbsValueComparisonStrategy.assertEqual(info, (short) 6, (short) 8); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual((short) 6, (short) 8, absValueComparisonStrategy)); + verify(failures).failure(info, shouldBeEqual((short) 6, (short) 8, absValueComparisonStrategy, + new StandardRepresentation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertHasSameSizeAs_with_Array_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertHasSameSizeAs_with_Array_Test.java index 10685fa964..6d80646a8a 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertHasSameSizeAs_with_Array_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertHasSameSizeAs_with_Array_Test.java @@ -23,7 +23,6 @@ import static org.mockito.Mockito.verify; import org.assertj.core.api.AssertionInfo; -import org.assertj.core.api.Assertions; import org.assertj.core.internal.Strings; import org.assertj.core.internal.StringsBaseTest; import org.junit.Test; @@ -50,7 +49,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { strings.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length(), other.length).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length(), other.length) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertHasSameSizeAs_with_Iterable_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertHasSameSizeAs_with_Iterable_Test.java index 8bf11d2a0d..7a4944f264 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertHasSameSizeAs_with_Iterable_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertHasSameSizeAs_with_Iterable_Test.java @@ -51,7 +51,8 @@ public void should_fail_if_size_of_actual_is_not_equal_to_expected_size() { try { strings.assertHasSameSizeAs(info, actual, other); } catch (AssertionError e) { - assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length(), other.size()).create(null)); + assertThat(e).hasMessage(shouldHaveSameSizeAs(actual, actual.length(), other.size()) + .create(null, info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/internal/strings/Strings_assertIsXmlEqualCase_Test.java b/src/test/java/org/assertj/core/internal/strings/Strings_assertIsXmlEqualCase_Test.java index cbd24903a5..b4e6573e21 100644 --- a/src/test/java/org/assertj/core/internal/strings/Strings_assertIsXmlEqualCase_Test.java +++ b/src/test/java/org/assertj/core/internal/strings/Strings_assertIsXmlEqualCase_Test.java @@ -62,7 +62,7 @@ public void should_fail_if_both_Strings_are_not_XML_equals() { try { strings.assertXmlEqualsTo(info, actual, expected); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(xmlPrettyFormat(actual), xmlPrettyFormat(expected))); + verify(failures).failure(info, shouldBeEqual(xmlPrettyFormat(actual), xmlPrettyFormat(expected), info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); @@ -83,7 +83,8 @@ public void should_fail_if_both_Strings_are_not_XML_equal_regardless_of_case() { try { stringsWithCaseInsensitiveComparisonStrategy.assertXmlEqualsTo(someInfo(), actual, expected); } catch (AssertionError e) { - verify(failures).failure(info, shouldBeEqual(xmlPrettyFormat(actual), xmlPrettyFormat(expected))); + verify(failures).failure(info, shouldBeEqual(xmlPrettyFormat(actual), xmlPrettyFormat(expected), + info.representation())); return; } failBecauseExpectedAssertionErrorWasNotThrown(); diff --git a/src/test/java/org/assertj/core/presentation/NumberGrouping_Test.java b/src/test/java/org/assertj/core/presentation/NumberGrouping_Test.java new file mode 100644 index 0000000000..732b1b3020 --- /dev/null +++ b/src/test/java/org/assertj/core/presentation/NumberGrouping_Test.java @@ -0,0 +1,50 @@ +/* + * Created on Dec 28, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.presentation; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Mariusz Smykula + */ +public class NumberGrouping_Test { + + @Test + public void should_group_words_in_byte_hex_value() throws Exception { + String hexLiteral = NumberGrouping.toHexLiteral("CA"); + assertThat(hexLiteral).isEqualTo("CA"); + } + + @Test + public void should_group_words_in_hex_value() throws Exception { + String hexLiteral = NumberGrouping.toHexLiteral("01234567"); + assertThat(hexLiteral).isEqualTo("0123_4567"); + } + + @Test + public void should_group_bytes_in_integer() throws Exception { + String literals = NumberGrouping.toBinaryLiteral("00000000000000000000000000000011"); + assertThat(literals).isEqualTo("00000000_00000000_00000000_00000011"); + } + + @Test + public void should_group_bytes_in_short() throws Exception { + String literals = NumberGrouping.toBinaryLiteral("1000000000000011"); + assertThat(literals).isEqualTo("10000000_00000011"); + } + +} diff --git a/src/test/java/org/assertj/core/test/TestData.java b/src/test/java/org/assertj/core/test/TestData.java index f21cba02ed..a691071222 100644 --- a/src/test/java/org/assertj/core/test/TestData.java +++ b/src/test/java/org/assertj/core/test/TestData.java @@ -32,11 +32,16 @@ public final class TestData { private static final AssertionInfo ASSERTION_INFO = new WritableAssertionInfo(); + private static final AssertionInfo ASSERTION_INFO_AS_HEX = new WritableAssertionInfo(); private static final TextDescription DESCRIPTION = new TextDescription( "who's the more foolish: the fool, or the fool who follows him?"); private static final Index INDEX = atIndex(0); private static final Pattern MATCH_ANYTHING = Pattern.compile(".*"); + static { + ((WritableAssertionInfo) ASSERTION_INFO_AS_HEX).representationAsHexadecimal(); + } + public static Pattern matchAnything() { return MATCH_ANYTHING; } @@ -49,6 +54,10 @@ public static AssertionInfo someInfo() { return ASSERTION_INFO; } + public static AssertionInfo someHexInfo() { + return ASSERTION_INFO_AS_HEX; + } + public static Description someDescription() { return DESCRIPTION; } diff --git a/src/test/java/org/assertj/core/util/ArrayFormatter_format_Test.java b/src/test/java/org/assertj/core/util/ArrayFormatter_format_Test.java index 501359fd4c..b305b38fbf 100644 --- a/src/test/java/org/assertj/core/util/ArrayFormatter_format_Test.java +++ b/src/test/java/org/assertj/core/util/ArrayFormatter_format_Test.java @@ -17,11 +17,13 @@ import static org.assertj.core.util.Strings.quote; import static org.junit.Assert.*; +import org.assertj.core.presentation.HexadecimalRepresentation; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.BeforeClass; import org.junit.Test; /** - * Tests for {@link ArrayFormatter#format(Object)}. + * Tests for {@link ArrayFormatter#format(org.assertj.core.presentation.Representation, Object)}. * * @author Alex Ruiz */ @@ -35,74 +37,79 @@ public static void setUpOnce() { @Test public void should_return_null_if_array_is_null() { - assertNull(formatter.format(null)); + assertNull(formatter.format(new StandardRepresentation(), null)); } @Test public void should_return_null_if_parameter_is_not_array() { - assertNull(formatter.format("Hello")); + assertNull(formatter.format(new StandardRepresentation(), "Hello")); } @Test public void should_format_boolean_array() { - assertEquals("[true, false, true]", formatter.format(new boolean[] { true, false, true })); + assertEquals("[true, false, true]", formatter.format(new StandardRepresentation(), new boolean[]{true, false, true})); } @Test public void should_format_char_array() { - assertEquals("['a', 'b', 'c']", formatter.format(new char[] { 'a', 'b', 'c' })); + assertEquals("['a', 'b', 'c']", formatter.format(new StandardRepresentation(), new char[] { 'a', 'b', 'c' })); } @Test public void should_format_byte_array() { - assertEquals("[0x06, 0x08]", formatter.format(new byte[] { 6, 8 })); + assertEquals("[6, 8]", formatter.format(new StandardRepresentation(), new byte[] { 6, 8 })); + } + + @Test + public void should_format_byte_array_in_hex_representation() { + assertEquals("[0x06, 0x08]", formatter.format(new HexadecimalRepresentation(), new byte[] { 6, 8 })); } @Test public void should_format_short_array() { - assertEquals("[6, 8]", formatter.format(new short[] { 6, 8 })); + assertEquals("[6, 8]", formatter.format(new StandardRepresentation(), new short[] { 6, 8 })); } @Test public void should_format_int_array() { - assertEquals("[6, 8]", formatter.format(new int[] { 6, 8 })); + assertEquals("[6, 8]", formatter.format(new StandardRepresentation(), new int[] { 6, 8 })); } @Test public void should_format_longArray() { - assertEquals("[6L, 8L]", formatter.format(new long[] { 6l, 8l })); + assertEquals("[6L, 8L]", formatter.format(new StandardRepresentation(), new long[] { 6l, 8l })); } @Test public void should_format_float_array() { - assertEquals("[6.0f, 8.0f]", formatter.format(new float[] { 6f, 8f })); + assertEquals("[6.0f, 8.0f]", formatter.format(new StandardRepresentation(), new float[] { 6f, 8f })); } @Test public void should_format_double_array() { - assertEquals("[6.0, 8.0]", formatter.format(new double[] { 6d, 8d })); + assertEquals("[6.0, 8.0]", formatter.format(new StandardRepresentation(), new double[] { 6d, 8d })); } @Test public void should_format_String_array() { - assertEquals("[\"Hello\", \"World\"]", formatter.format(new Object[] { "Hello", "World" })); + assertEquals("[\"Hello\", \"World\"]", formatter.format(new StandardRepresentation(), new Object[] { "Hello", "World" })); } @Test public void should_format_array_with_null_element() { - assertEquals("[\"Hello\", null]", formatter.format(new Object[] { "Hello", null })); + assertEquals("[\"Hello\", null]", formatter.format(new StandardRepresentation(), new Object[] { "Hello", null })); } @Test public void should_format_Object_array() { - assertEquals("[\"Hello\", 'Anakin']", formatter.format(new Object[] { "Hello", new Person("Anakin") })); + assertEquals("[\"Hello\", 'Anakin']", formatter.format(new StandardRepresentation(), new Object[] { "Hello", new Person("Anakin") })); } @Test public void should_format_Object_array_that_has_primitive_array_as_element() { boolean booleans[] = { true, false }; Object[] array = { "Hello", booleans }; - assertEquals("[\"Hello\", [true, false]]", formatter.format(array)); + assertEquals("[\"Hello\", [true, false]]", formatter.format(new StandardRepresentation(), array)); } @Test @@ -110,7 +117,7 @@ public void should_format_Object_array_having_itself_as_element() { Object[] array1 = { "Hello", "World" }; Object[] array2 = { array1 }; array1[1] = array2; - assertEquals("[[\"Hello\", [...]]]", formatter.format(array2)); + assertEquals("[[\"Hello\", [...]]]", formatter.format(new StandardRepresentation(), array2)); } private static class Person { diff --git a/src/test/java/org/assertj/core/util/Arrays_format_Test.java b/src/test/java/org/assertj/core/util/Arrays_format_Test.java index 50a59f0f0d..e03821e667 100644 --- a/src/test/java/org/assertj/core/util/Arrays_format_Test.java +++ b/src/test/java/org/assertj/core/util/Arrays_format_Test.java @@ -16,10 +16,12 @@ import static org.junit.Assert.*; +import org.assertj.core.presentation.HexadecimalRepresentation; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link Arrays#format(Object)}. + * Tests for {@link Arrays#format(org.assertj.core.presentation.Representation, Object)}. * * @author Alex Ruiz */ @@ -27,65 +29,71 @@ public class Arrays_format_Test { @Test public void should_return_null_if_array_is_null() { - assertNull(Arrays.format(null)); + assertNull(Arrays.format(new StandardRepresentation(), null)); } @Test public void should_return_empty_brackets_if_array_is_empty() { - assertEquals("[]", Arrays.format(new Object[0])); + assertEquals("[]", Arrays.format(new StandardRepresentation(), new Object[0])); } @Test public void should_format_Object_array() { Object o = new Object[] { "First", 3 }; - assertEquals("[\"First\", 3]", Arrays.format(o)); + assertEquals("[\"First\", 3]", Arrays.format(new StandardRepresentation(), o)); } @Test public void should_format_boolean_array() { Object o = new boolean[] { true, false }; - assertEquals("[true, false]", Arrays.format(o)); + assertEquals("[true, false]", Arrays.format(new StandardRepresentation(), o)); } @Test public void should_format_byte_array() { Object o = new byte[] { (byte) 3, (byte) 8 }; - assertEquals("[0x03, 0x08]", Arrays.format(o)); + assertEquals("[3, 8]", Arrays.format(new StandardRepresentation(), o)); + } + + @Test + public void should_format_byte_array_in_hex_representation() { + Object o = new byte[] { (byte) 3, (byte) 8 }; + assertEquals("[0x03, 0x08]", Arrays.format(new HexadecimalRepresentation(), o)); } @Test public void should_format_char_array() { Object o = new char[] { 'a', 'b' }; - assertEquals("['a', 'b']", Arrays.format(o)); + assertEquals("['a', 'b']", Arrays.format(new StandardRepresentation(), o)); } @Test public void should_format_double_array() { Object o = new double[] { 6.8, 8.3 }; - assertEquals("[6.8, 8.3]", Arrays.format(o)); + assertEquals("[6.8, 8.3]", Arrays.format(new StandardRepresentation(), o)); } @Test public void should_format_float_array() { Object o = new float[] { 6.1f, 8.6f }; - assertEquals("[6.1f, 8.6f]", Arrays.format(o)); + assertEquals("[6.1f, 8.6f]", Arrays.format(new StandardRepresentation(), o)); } @Test public void should_format_int_array() { Object o = new int[] { 78, 66 }; - assertEquals("[78, 66]", Arrays.format(o)); + assertEquals("[78, 66]", Arrays.format(new StandardRepresentation(), o)); } @Test public void should_format_long_array() { Object o = new long[] { 160l, 98l }; - assertEquals("[160L, 98L]", Arrays.format(o)); + assertEquals("[160L, 98L]", Arrays.format(new StandardRepresentation(), o)); } @Test public void should_format_short_array() { Object o = new short[] { (short) 5, (short) 8 }; - assertEquals("[5, 8]", Arrays.format(o)); + assertEquals("[5, 8]", Arrays.format(new StandardRepresentation(), o)); } } diff --git a/src/test/java/org/assertj/core/util/Collections_format_Test.java b/src/test/java/org/assertj/core/util/Collections_format_Test.java index 809feef024..7df723d779 100644 --- a/src/test/java/org/assertj/core/util/Collections_format_Test.java +++ b/src/test/java/org/assertj/core/util/Collections_format_Test.java @@ -19,10 +19,11 @@ import java.util.*; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link Collections#format(Collection)}. + * Tests for {@link Collections#format(org.assertj.core.presentation.Representation, java.util.Collection)}. * * @author Yvonne Wang * @author Alex Ruiz @@ -31,18 +32,18 @@ public class Collections_format_Test { @Test public void should_return_null_if_Collection_is_null() { - assertNull(Collections.format(null)); + assertNull(Collections.format(new StandardRepresentation(), null)); } @Test public void should_return_empty_brackets_if_Collection_is_empty() { - assertEquals("[]", Collections.format(new ArrayList())); + assertEquals("[]", Collections.format(new StandardRepresentation(), new ArrayList())); } @Test @SuppressWarnings("unchecked") public void should_format_Collection() { List list = asList("First", 3); - assertEquals("[\"First\", 3]", Collections.format(list)); + assertEquals("[\"First\", 3]", Collections.format(new StandardRepresentation(), list)); } } diff --git a/src/test/java/org/assertj/core/util/Hexadecimals_Test.java b/src/test/java/org/assertj/core/util/Hexadecimals_Test.java new file mode 100644 index 0000000000..77c29f77ea --- /dev/null +++ b/src/test/java/org/assertj/core/util/Hexadecimals_Test.java @@ -0,0 +1,33 @@ +/* + * Created on Dec 20, 2013 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + * Copyright @2009-2013 the original author or authors. + */ +package org.assertj.core.util; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Mariusz Smykula + */ +public class Hexadecimals_Test { + + @Test + public void should_return_hexadecimal_representation_of_byte() throws Exception { + assertThat(Hexadecimals.byteToHexString((byte) 0x00)).isEqualTo("00"); + assertThat(Hexadecimals.byteToHexString((byte) 0xFF)).isEqualTo("FF"); + assertThat(Hexadecimals.byteToHexString((byte) 0xa2)).isEqualTo("A2"); + } + +} diff --git a/src/test/java/org/assertj/core/util/Maps_format_Test.java b/src/test/java/org/assertj/core/util/Maps_format_Test.java index e9f7fdb217..3315b72f40 100644 --- a/src/test/java/org/assertj/core/util/Maps_format_Test.java +++ b/src/test/java/org/assertj/core/util/Maps_format_Test.java @@ -21,6 +21,7 @@ import java.util.LinkedHashMap; import java.util.Map; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** @@ -32,12 +33,12 @@ public class Maps_format_Test { @Test public void should_return_null_if_Map_is_null() { - assertNull(Maps.format(null)); + assertNull(Maps.format(new StandardRepresentation(), null)); } @Test public void should_return_empty_braces_if_Map_is_empty() { - assertEquals(Maps.format(new HashMap()), "{}"); + assertEquals(Maps.format(new StandardRepresentation(), new HashMap()), "{}"); } @Test @@ -45,6 +46,6 @@ public void should_format_Map() { Map> map = new LinkedHashMap>(); map.put("One", String.class); map.put("Two", File.class); - assertEquals("{\"One\"=java.lang.String, \"Two\"=java.io.File}", Maps.format(map)); + assertEquals("{\"One\"=java.lang.String, \"Two\"=java.io.File}", Maps.format(new StandardRepresentation(), map)); } } diff --git a/src/test/java/org/assertj/core/util/ToString_toStringOf_Test.java b/src/test/java/org/assertj/core/util/StandardRepresentation_toStringOf_Test.java similarity index 66% rename from src/test/java/org/assertj/core/util/ToString_toStringOf_Test.java rename to src/test/java/org/assertj/core/util/StandardRepresentation_toStringOf_Test.java index 70730d4e41..2d2b88dacd 100644 --- a/src/test/java/org/assertj/core/util/ToString_toStringOf_Test.java +++ b/src/test/java/org/assertj/core/util/StandardRepresentation_toStringOf_Test.java @@ -16,9 +16,10 @@ import static junit.framework.Assert.assertFalse; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.tuple; import static org.assertj.core.util.Arrays.array; import static org.assertj.core.util.Lists.newArrayList; -import static org.assertj.core.util.ToString.toStringOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -34,27 +35,29 @@ import java.util.List; import java.util.Map; +import org.assertj.core.presentation.StandardRepresentation; import org.junit.Test; /** - * Tests for {@link ToString#toStringOf(Object)}. + * Tests for {@link org.assertj.core.presentation.StandardRepresentation#toStringOf(Object)}. * * @author Joel Costigliola */ -public class ToString_toStringOf_Test { +public class StandardRepresentation_toStringOf_Test { + @Test public void should_return_null_if_object_is_null() { - assertNull(ToString.toStringOf(null)); + assertNull(new StandardRepresentation().toStringOf(null)); } @Test public void should_quote_String() { - assertEquals("\"Hello\"", ToString.toStringOf("Hello")); + assertEquals("\"Hello\"", new StandardRepresentation().toStringOf("Hello")); } @Test public void should_quote_empty_String() { - assertEquals("\"\"", ToString.toStringOf("")); + assertEquals("\"\"", new StandardRepresentation().toStringOf("")); } @Test @@ -67,24 +70,24 @@ public String getAbsolutePath() { return path; } }; - assertEquals(path, ToString.toStringOf(o)); + assertEquals(path, new StandardRepresentation().toStringOf(o)); } @Test public void should_return_toString_of_Class_with_its_name() { - assertEquals("java.lang.Object", ToString.toStringOf(Object.class)); + assertEquals("java.lang.Object", new StandardRepresentation().toStringOf(Object.class)); } @Test public void should_return_toString_of_Collection_of_String() { Collection collection = newArrayList("s1", "s2"); - assertEquals("[\"s1\", \"s2\"]", ToString.toStringOf(collection)); + assertEquals("[\"s1\", \"s2\"]", new StandardRepresentation().toStringOf(collection)); } @Test public void should_return_toString_of_Collection_of_arrays() { List collection = newArrayList(array(true, false), array(true, false, true)); - assertEquals("[[true, false], [true, false, true]]", ToString.toStringOf(collection)); + assertEquals("[[true, false], [true, false, true]]", new StandardRepresentation().toStringOf(collection)); } @Test @@ -92,7 +95,7 @@ public void should_return_toString_of_Collection_of_Collections() { Collection> collection = new ArrayList>(); collection.add(newArrayList("s1", "s2")); collection.add(newArrayList("s3", "s4", "s5")); - assertEquals("[[\"s1\", \"s2\"], [\"s3\", \"s4\", \"s5\"]]", ToString.toStringOf(collection)); + assertEquals("[[\"s1\", \"s2\"], [\"s3\", \"s4\", \"s5\"]]", new StandardRepresentation().toStringOf(collection)); } @Test @@ -100,36 +103,36 @@ public void should_return_toString_of_Map() { Map map = new LinkedHashMap(); map.put("key1", "value1"); map.put("key2", "value2"); - assertEquals("{\"key1\"=\"value1\", \"key2\"=\"value2\"}", ToString.toStringOf(map)); + assertEquals("{\"key1\"=\"value1\", \"key2\"=\"value2\"}", new StandardRepresentation().toStringOf(map)); } @Test public void should_return_toString_of_array() { - assertEquals("[\"s1\", \"s2\"]", ToString.toStringOf(array("s1", "s2"))); + assertEquals("[\"s1\", \"s2\"]", new StandardRepresentation().toStringOf(array("s1", "s2"))); } @Test public void should_return_toString_of_array_of_arrays() { String[][] array = array(array("s1", "s2"), array("s3", "s4", "s5")); - assertEquals("[[\"s1\", \"s2\"], [\"s3\", \"s4\", \"s5\"]]", ToString.toStringOf(array)); + assertEquals("[[\"s1\", \"s2\"], [\"s3\", \"s4\", \"s5\"]]", new StandardRepresentation().toStringOf(array)); } @Test public void should_return_toString_of_array_of_Class() { Class[] array = { String.class, File.class }; - assertEquals("[java.lang.String, java.io.File]", ToString.toStringOf(array)); + assertEquals("[java.lang.String, java.io.File]", new StandardRepresentation().toStringOf(array)); } @Test public void should_return_toString_of_calendar() { GregorianCalendar calendar = new GregorianCalendar(2011, Calendar.JANUARY, 18, 23, 53, 17); - assertEquals("2011-01-18T23:53:17", ToString.toStringOf(calendar)); + assertEquals("2011-01-18T23:53:17", new StandardRepresentation().toStringOf(calendar)); } @Test public void should_return_toString_of_date() { Date date = new GregorianCalendar(2011, Calendar.JUNE, 18, 23, 53, 17).getTime(); - assertEquals("2011-06-18T23:53:17", ToString.toStringOf(date)); + assertEquals("2011-06-18T23:53:17", new StandardRepresentation().toStringOf(date)); } @Test @@ -140,12 +143,12 @@ public int compare(String s1, String s2) { return s1.length() - s2.length(); } }; - assertEquals("'Anonymous Comparator class'", ToString.toStringOf(anonymousComparator)); + assertEquals("'Anonymous Comparator class'", new StandardRepresentation().toStringOf(anonymousComparator)); } @Test public void should_format_longs_and_integers() { - assertFalse(toStringOf(20L).equals(toStringOf(20))); + assertFalse(new StandardRepresentation().toStringOf(20L).equals(toStringOf(20))); assertEquals("20", toStringOf(20)); assertEquals("20L", toStringOf(20L)); } @@ -153,8 +156,8 @@ public void should_format_longs_and_integers() { @Test public void should_format_bytes_as_hex() { assertFalse(toStringOf((byte) 20).equals(toStringOf((char) 20))); - assertFalse(toStringOf((byte) 20).equals(toStringOf((short) 20))); - assertEquals("0x20", toStringOf((byte) 32)); + assertEquals(toStringOf((byte) 20), (toStringOf((short) 20))); + assertEquals("32", toStringOf((byte) 32)); } @Test @@ -163,4 +166,13 @@ public void should_format_doubles_and_floats() { assertEquals("20.0", toStringOf(20.0)); assertEquals("20.0f", toStringOf(20.0f)); } + + @Test + public void should_format_tuples() { + assertThat(toStringOf(tuple(1, 2, 3))).isEqualTo("(1, 2, 3)"); + } + + private String toStringOf(Object o) { + return new StandardRepresentation().toStringOf(o); + } }