本文整理了Java中org.assertj.core.api.WritableAssertionInfo.representation()
方法的一些代码示例,展示了WritableAssertionInfo.representation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WritableAssertionInfo.representation()
方法的具体详情如下:
包路径:org.assertj.core.api.WritableAssertionInfo
类名称:WritableAssertionInfo
方法名:representation
暂无
代码示例来源:origin: org.assertj/assertj-core
private void assertIsPrimitiveZero() {
if (actual.doubleValue() == 0.0) return;
throw Failures.instance().failure(info, shouldBeEqual(actual, 0.0, info.representation()));
}
代码示例来源:origin: org.assertj/assertj-core
private void assertIsPrimitiveZero() {
if (actual.floatValue() == 0.0f) return;
throw Failures.instance().failure(info, shouldBeEqual(actual, 0.0f, info.representation()));
}
代码示例来源:origin: org.assertj/assertj-core
/**
* {@inheritDoc}
*/
@Override
public String toString() {
String format = "%s[overridingErrorMessage=%s, description=%s, representation=%s]";
return format(format, getClass().getSimpleName(), quote(overridingErrorMessage()), quote(descriptionText()),
quote(representation()));
}
代码示例来源:origin: gocd/gocd
public SELF hasCookie(String path, String name, String value, int maxAge, boolean secured, boolean httpOnly) {
Cookie actualCookie = actual.getCookie(name);
Cookie expectedCookie = new Cookie(name, value);
expectedCookie.setDomain("");
expectedCookie.setPath(path);
expectedCookie.setMaxAge(maxAge);
expectedCookie.setSecure(secured);
expectedCookie.setHttpOnly(httpOnly);
if (!EqualsBuilder.reflectionEquals(expectedCookie, actualCookie)) {
this.as("cookie");
throw Failures.instance().failure(info, shouldBeEqual(ReflectionToStringBuilder.toString(actualCookie, ToStringStyle.MULTI_LINE_STYLE), ReflectionToStringBuilder.toString(expectedCookie, ToStringStyle.MULTI_LINE_STYLE), info.representation()));
}
return myself;
}
代码示例来源:origin: joel-costigliola/assertj-core
private void assertIsPrimitiveZero() {
if (actual.floatValue() == 0.0f) return;
throw Failures.instance().failure(info, shouldBeEqual(actual, 0.0f, info.representation()));
}
代码示例来源:origin: joel-costigliola/assertj-core
private void assertIsPrimitiveZero() {
if (actual.doubleValue() == 0.0) return;
throw Failures.instance().failure(info, shouldBeEqual(actual, 0.0, info.representation()));
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* {@inheritDoc}
*/
@Override
public String toString() {
String format = "%s[overridingErrorMessage=%s, description=%s, representation=%s]";
return format(format, getClass().getSimpleName(), quote(overridingErrorMessage()), quote(descriptionText()),
quote(representation()));
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Verifies that the {@link CompletableFuture} is completed normally with the {@code expected} result.
* <p>
* Assertion will pass :
* <pre><code class='java'> assertThat(CompletableFuture.completedFuture("something"))
* .isCompletedWithValue("something");</code></pre>
*
* Assertion will fail :
* <pre><code class='java'> assertThat(CompletableFuture.completedFuture("something"))
* .isCompletedWithValue("something else");</code></pre>
*
* @param expected the expected result value of the {@link CompletableFuture}.
* @return this assertion object.
*/
public SELF isCompletedWithValue(RESULT expected) {
isCompleted();
RESULT actualResult = actual.join();
if (!Objects.equals(actualResult, expected))
throw Failures.instance().failure(info, shouldBeEqual(actualResult, expected, info.representation()));
return myself;
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Thread safe utility method to parse a Date with {@link #userDateFormats} first, then {@link #DEFAULT_DATE_FORMATS}.
* <p>
* Returns <code>null</code> if dateAsString parameter is <code>null</code>.
*
* @param dateAsString the string to parse as a Date with {@link #userDateFormats}
* @return the corresponding Date, null if dateAsString parameter is null.
* @throws AssertionError if the string can't be parsed as a Date
*/
@VisibleForTesting
Date parse(String dateAsString) {
if (dateAsString == null) return null;
// parse with date format specified by user if any, otherwise use default formats
// no synchronization needed as userCustomDateFormat is thread local
Date date = parseDateWith(dateAsString, userDateFormats.get());
if (date != null) return date;
// no matching user date format, let's try default format
date = parseDateWithDefaultDateFormats(dateAsString);
if (date != null) return date;
// no matching date format, throw an error
throw new AssertionError(String.format("Failed to parse %s with any of these date formats:%n %s", dateAsString,
info.representation().toStringOf(dateFormatsInOrderOfUsage())));
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Verifies that the {@link CompletableFuture} is completed normally with the {@code expected} result.
* <p>
* Assertion will pass :
* <pre><code class='java'> assertThat(CompletableFuture.completedFuture("something"))
* .isCompletedWithValue("something");</code></pre>
*
* Assertion will fail :
* <pre><code class='java'> assertThat(CompletableFuture.completedFuture("something"))
* .isCompletedWithValue("something else");</code></pre>
*
* @param expected the expected result value of the {@link CompletableFuture}.
* @return this assertion object.
*/
public SELF isCompletedWithValue(RESULT expected) {
isCompleted();
RESULT actualResult = actual.join();
if (!Objects.equals(actualResult, expected))
throw Failures.instance().failure(info, shouldBeEqual(actualResult, expected, info.representation()));
return myself;
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Thread safe utility method to parse a Date with {@link #userDateFormats} first, then {@link #DEFAULT_DATE_FORMATS}.
* <p>
* Returns <code>null</code> if dateAsString parameter is <code>null</code>.
*
* @param dateAsString the string to parse as a Date with {@link #userDateFormats}
* @return the corresponding Date, null if dateAsString parameter is null.
* @throws AssertionError if the string can't be parsed as a Date
*/
@VisibleForTesting
Date parse(String dateAsString) {
if (dateAsString == null) return null;
// parse with date format specified by user if any, otherwise use default formats
// no synchronization needed as userCustomDateFormat is thread local
Date date = parseDateWith(dateAsString, userDateFormats.get());
if (date != null) return date;
// no matching user date format, let's try default format
date = parseDateWithDefaultDateFormats(dateAsString);
if (date != null) return date;
// no matching date format, throw an error
throw new AssertionError(String.format("Failed to parse %s with any of these date formats:%n %s", dateAsString,
info.representation().toStringOf(dateFormatsInOrderOfUsage())));
}
代码示例来源:origin: org.assertj/assertj-core
private void propagateAssertionInfoFrom(AbstractAssert<?, ?> assertInstance) {
this.info.useRepresentation(assertInstance.info.representation());
this.info.description(assertInstance.info.description());
this.info.overridingErrorMessage(assertInstance.info.overridingErrorMessage());
}
代码示例来源:origin: joel-costigliola/assertj-core
private void propagateAssertionInfoFrom(AbstractAssert<?, ?> assertInstance) {
this.info.useRepresentation(assertInstance.info.representation());
this.info.description(assertInstance.info.description());
this.info.overridingErrorMessage(assertInstance.info.overridingErrorMessage());
}
代码示例来源:origin: gocd/gocd
public SELF hasBody(String expected) throws UnsupportedEncodingException {
if (!Objects.areEqual(actual.getContentAsString(), expected)) {
this.as("body");
throw Failures.instance().failure(info, shouldBeEqual(actual.getContentAsString(), expected, info.representation()));
}
return myself;
}
代码示例来源:origin: gocd/gocd
public SELF hasBody(byte[] expected) {
if (!Objects.areEqual(actual.getContentAsByteArray(), expected)) {
this.as("body");
throw Failures.instance().failure(info, shouldBeEqual(actual.getContentAsByteArray(), expected, info.representation()));
}
return myself;
}
代码示例来源:origin: org.assertj/assertj-core
if (assertionError == null) {
String description = MessageFormatter.instance().format(info.description(), info.representation(), "");
assertionError = new AssertionError(description + String.format(errorMessage, arguments));
代码示例来源:origin: joel-costigliola/assertj-core
if (assertionError == null) {
String description = MessageFormatter.instance().format(info.description(), info.representation(), "");
assertionError = new AssertionError(description + String.format(errorMessage, arguments));
代码示例来源:origin: org.assertj/assertj-core-java8
/**
* Thread safe utility method to parse a Date with {@link #userDateFormats} first, then {@link #DEFAULT_DATE_FORMATS}.
* <p>
* Returns <code>null</code> if dateAsString parameter is <code>null</code>.
*
* @param dateAsString the string to parse as a Date with {@link #userDateFormats}
* @return the corresponding Date, null if dateAsString parameter is null.
* @throws AssertionError if the string can't be parsed as a Date
*/
@VisibleForTesting
Date parse(String dateAsString) {
if (dateAsString == null) return null;
// parse with date format specified by user if any, otherwise use default formats
// no synchronization needed as userCustomDateFormat is thread local
Date date = parseDateWith(dateAsString, userDateFormats.get());
if (date != null) return date;
// no matching user date format, let's try default format
date = parseDateWithDefaultDateFormats(dateAsString);
if (date != null) return date;
// no matching date format, throw an error
throw new AssertionError("Failed to parse " + dateAsString + " with any of these date formats: "
+ info.representation().toStringOf(dateFormatsInOrderOfUsage()));
}
代码示例来源:origin: lukas-krecan/JsonUnit
/**
* Copy from AssertJ to prevent errors with percents in error message
*/
private void failWithMessage(String errorMessage) {
AssertionError assertionError = Failures.instance().failureIfErrorMessageIsOverridden(info);
if (assertionError == null) {
// error message was not overridden, build it.
String description = MessageFormatter.instance().format(info.description(), info.representation(), "");
assertionError = new AssertionError(description + errorMessage);
}
Failures.instance().removeAssertJRelatedElementsFromStackTraceIfNeeded(assertionError);
throw assertionError;
}
代码示例来源:origin: lukas-krecan/JsonUnit
/**
* Compares JSONs.
*/
@Override
public JsonAssert isEqualTo(Object expected) {
Diff diff = Diff.create(expected, actual, "fullJson", path.asPrefix(), configuration);
diff.failIfDifferent(MessageFormatter.instance().format(info.description(), info.representation(), ""));
return this;
}
内容来源于网络,如有侵权,请联系作者删除!