本文整理了Java中org.assertj.core.internal.Objects.assertNotNull()
方法的一些代码示例,展示了Objects.assertNotNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Objects.assertNotNull()
方法的具体详情如下:
包路径:org.assertj.core.internal.Objects
类名称:Objects
方法名:assertNotNull
[英]Asserts that the given object is not null.
[中]断言给定的对象不是null。
代码示例来源:origin: org.assertj/assertj-core
private void assertNotNull(AssertionInfo info, CharSequence actual) {
Objects.instance().assertNotNull(info, actual);
}
代码示例来源:origin: org.assertj/assertj-core
public <E> void assertHasOnlyElementsOfType(AssertionInfo info, E[] actual, Class<?> type) {
Objects.instance().assertNotNull(info, actual);
for (Object o : actual) {
if (!type.isInstance(o)) throw failures.failure(info, shouldHaveOnlyElementsOfType(actual, type, o.getClass()));
}
}
代码示例来源:origin: org.assertj/assertj-core
public void assertHasToString(AssertionInfo info, Object actual, String expectedToString) {
assertNotNull(info, actual);
if (!actual.toString().equals(expectedToString))
throw failures.failure(info, shouldHaveToString(actual, expectedToString));
}
代码示例来源:origin: org.assertj/assertj-core
public <E> void assertHasAtLeastOneElementOfType(AssertionInfo info, E[] actual, Class<?> type) {
Objects.instance().assertNotNull(info, actual);
boolean found = false;
for (Object o : actual) {
if (!type.isInstance(o)) continue;
found = true;
break;
}
if (!found) throw failures.failure(info, shouldHaveAtLeastOneElementOfType(actual, type));
}
代码示例来源:origin: org.assertj/assertj-core
private static void assertNotNull(AssertionInfo info, Class<?> actual) {
Objects.instance().assertNotNull(info, actual);
}
代码示例来源:origin: joel-costigliola/assertj-core
public void assertHasToString(AssertionInfo info, Object actual, String expectedToString) {
assertNotNull(info, actual);
if (!actual.toString().equals(expectedToString))
throw failures.failure(info, shouldHaveToString(actual, expectedToString));
}
代码示例来源:origin: org.assertj/assertj-core
public <E> void assertDoesNotHaveAnyElementsOfTypes(AssertionInfo info, E[] actual, Class<?>... unexpectedTypes) {
Objects.instance().assertNotNull(info, actual);
Map<Class<?>, List<Object>> nonMatchingElementsByType = new LinkedHashMap<>();
for (E element : actual) {
for (Class<?> type : unexpectedTypes) {
if (type.isInstance(element)) {
if (!nonMatchingElementsByType.containsKey(type)) {
nonMatchingElementsByType.put(type, new ArrayList<>());
}
nonMatchingElementsByType.get(type).add(element);
}
}
}
if (!nonMatchingElementsByType.isEmpty()) {
throw failures.failure(info, shouldNotHaveAnyElementsOfTypes(actual, unexpectedTypes, nonMatchingElementsByType));
}
}
代码示例来源:origin: org.assertj/assertj-core
private static void assertNotNull(AssertionInfo info, Instant actual) {
Objects.instance().assertNotNull(info, actual);
}
代码示例来源:origin: org.assertj/assertj-core
public <A> void assertHasFieldOrProperty(AssertionInfo info, A actual, String name) {
assertNotNull(info, actual);
try {
extractPropertyOrField(actual, name);
} catch (IntrospectionError error) {
throw failures.failure(info, shouldHavePropertyOrField(actual, name));
}
}
代码示例来源:origin: joel-costigliola/assertj-core
public <E> void assertHasOnlyElementsOfType(AssertionInfo info, E[] actual, Class<?> type) {
Objects.instance().assertNotNull(info, actual);
for (Object element : actual) {
if (!type.isInstance(element)) {
throw failures.failure(info, shouldHaveOnlyElementsOfType(actual, type, element == null ? null : element.getClass()));
}
}
}
代码示例来源:origin: org.assertj/assertj-core
private void assertNotNull(AssertionInfo info, List<?> actual) {
Objects.instance().assertNotNull(info, actual);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Asserts that the actual object has the same hashCode as the given object.
*
* @param <A> the actual type
* @param info contains information about the assertion.
* @param actual the given object.
* @param other the object to check hashCode against.
*
* @throws AssertionError if the actual object is null.
* @throws AssertionError if the given object is null.
* @throws AssertionError if the actual object has not the same hashCode as the given object.
*/
public <A> void assertHasSameHashCodeAs(AssertionInfo info, A actual, Object other) {
assertNotNull(info, actual);
checkNotNull(other, "The object used to compare actual's hash code with should not be null");
if (actual.hashCode() != other.hashCode()) throw failures.failure(info, shouldHaveSameHashCode(actual, other));
}
代码示例来源:origin: joel-costigliola/assertj-core
public <E> void assertHasAtLeastOneElementOfType(AssertionInfo info, E[] actual, Class<?> type) {
Objects.instance().assertNotNull(info, actual);
boolean found = false;
for (Object o : actual) {
if (!type.isInstance(o)) continue;
found = true;
break;
}
if (!found) throw failures.failure(info, shouldHaveAtLeastOneElementOfType(actual, type));
}
代码示例来源:origin: org.assertj/assertj-core
private static void assertNotNull(AssertionInfo info, Boolean actual) {
Objects.instance().assertNotNull(info, actual);
}
}
代码示例来源:origin: joel-costigliola/assertj-core
public <A> void assertHasFieldOrProperty(AssertionInfo info, A actual, String name) {
assertNotNull(info, actual);
try {
extractPropertyOrField(actual, name);
} catch (IntrospectionError error) {
throw failures.failure(info, shouldHavePropertyOrField(actual, name));
}
}
代码示例来源:origin: joel-costigliola/assertj-core
public <E> void assertDoesNotHaveAnyElementsOfTypes(AssertionInfo info, E[] actual, Class<?>... unexpectedTypes) {
Objects.instance().assertNotNull(info, actual);
Map<Class<?>, List<Object>> nonMatchingElementsByType = new LinkedHashMap<>();
for (E element : actual) {
for (Class<?> type : unexpectedTypes) {
if (type.isInstance(element)) {
if (!nonMatchingElementsByType.containsKey(type)) {
nonMatchingElementsByType.put(type, new ArrayList<>());
}
nonMatchingElementsByType.get(type).add(element);
}
}
}
if (!nonMatchingElementsByType.isEmpty()) {
throw failures.failure(info, shouldNotHaveAnyElementsOfTypes(actual, unexpectedTypes, nonMatchingElementsByType));
}
}
代码示例来源:origin: org.assertj/assertj-core
private void assertNotNull(AssertionInfo info, Future<?> actual) {
Objects.instance().assertNotNull(info, actual);
}
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Asserts that the actual object has the same hashCode as the given object.
*
* @param <A> the actual type
* @param info contains information about the assertion.
* @param actual the given object.
* @param other the object to check hashCode against.
*
* @throws AssertionError if the actual object is null.
* @throws AssertionError if the given object is null.
* @throws AssertionError if the actual object has not the same hashCode as the given object.
*/
public <A> void assertHasSameHashCodeAs(AssertionInfo info, A actual, Object other) {
assertNotNull(info, actual);
checkNotNull(other, "The object used to compare actual's hash code with should not be null");
if (actual.hashCode() != other.hashCode()) throw failures.failure(info, shouldHaveSameHashCode(actual, other));
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Verifies that the actual {@code LocalDate} is today, that is matching current year, month and day.
* <p>
* Example:
* <pre><code class='java'> // assertion will pass
* assertThat(LocalDate.now()).isToday();
*
* // assertion will fail
* assertThat(theFellowshipOfTheRing.getReleaseDate()).isToday();</code></pre>
*
* @return this assertion object.
* @throws AssertionError if the actual {@code LocalDate} is {@code null}.
* @throws AssertionError if the actual {@code LocalDate} is not today.
*/
public SELF isToday() {
Objects.instance().assertNotNull(info, actual);
if (!actual.isEqual(LocalDate.now())) throw Failures.instance().failure(info, shouldBeToday(actual));
return myself;
}
代码示例来源:origin: org.assertj/assertj-core
private static void assertNotNull(AssertionInfo info, File actual) {
Objects.instance().assertNotNull(info, actual);
}
内容来源于网络,如有侵权,请联系作者删除!