org.assertj.core.internal.Objects.assertNotNull()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(233)

本文整理了Java中org.assertj.core.internal.Objects.assertNotNull()方法的一些代码示例,展示了Objects.assertNotNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Objects.assertNotNull()方法的具体详情如下:
包路径:org.assertj.core.internal.Objects
类名称:Objects
方法名:assertNotNull

Objects.assertNotNull介绍

[英]Asserts that the given object is not null.
[中]断言给定的对象不是null。

代码示例

代码示例来源:origin: org.assertj/assertj-core

  1. private void assertNotNull(AssertionInfo info, CharSequence actual) {
  2. Objects.instance().assertNotNull(info, actual);
  3. }

代码示例来源:origin: org.assertj/assertj-core

  1. public <E> void assertHasOnlyElementsOfType(AssertionInfo info, E[] actual, Class<?> type) {
  2. Objects.instance().assertNotNull(info, actual);
  3. for (Object o : actual) {
  4. if (!type.isInstance(o)) throw failures.failure(info, shouldHaveOnlyElementsOfType(actual, type, o.getClass()));
  5. }
  6. }

代码示例来源:origin: org.assertj/assertj-core

  1. public void assertHasToString(AssertionInfo info, Object actual, String expectedToString) {
  2. assertNotNull(info, actual);
  3. if (!actual.toString().equals(expectedToString))
  4. throw failures.failure(info, shouldHaveToString(actual, expectedToString));
  5. }

代码示例来源:origin: org.assertj/assertj-core

  1. public <E> void assertHasAtLeastOneElementOfType(AssertionInfo info, E[] actual, Class<?> type) {
  2. Objects.instance().assertNotNull(info, actual);
  3. boolean found = false;
  4. for (Object o : actual) {
  5. if (!type.isInstance(o)) continue;
  6. found = true;
  7. break;
  8. }
  9. if (!found) throw failures.failure(info, shouldHaveAtLeastOneElementOfType(actual, type));
  10. }

代码示例来源:origin: org.assertj/assertj-core

  1. private static void assertNotNull(AssertionInfo info, Class<?> actual) {
  2. Objects.instance().assertNotNull(info, actual);
  3. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. public void assertHasToString(AssertionInfo info, Object actual, String expectedToString) {
  2. assertNotNull(info, actual);
  3. if (!actual.toString().equals(expectedToString))
  4. throw failures.failure(info, shouldHaveToString(actual, expectedToString));
  5. }

代码示例来源:origin: org.assertj/assertj-core

  1. public <E> void assertDoesNotHaveAnyElementsOfTypes(AssertionInfo info, E[] actual, Class<?>... unexpectedTypes) {
  2. Objects.instance().assertNotNull(info, actual);
  3. Map<Class<?>, List<Object>> nonMatchingElementsByType = new LinkedHashMap<>();
  4. for (E element : actual) {
  5. for (Class<?> type : unexpectedTypes) {
  6. if (type.isInstance(element)) {
  7. if (!nonMatchingElementsByType.containsKey(type)) {
  8. nonMatchingElementsByType.put(type, new ArrayList<>());
  9. }
  10. nonMatchingElementsByType.get(type).add(element);
  11. }
  12. }
  13. }
  14. if (!nonMatchingElementsByType.isEmpty()) {
  15. throw failures.failure(info, shouldNotHaveAnyElementsOfTypes(actual, unexpectedTypes, nonMatchingElementsByType));
  16. }
  17. }

代码示例来源:origin: org.assertj/assertj-core

  1. private static void assertNotNull(AssertionInfo info, Instant actual) {
  2. Objects.instance().assertNotNull(info, actual);
  3. }

代码示例来源:origin: org.assertj/assertj-core

  1. public <A> void assertHasFieldOrProperty(AssertionInfo info, A actual, String name) {
  2. assertNotNull(info, actual);
  3. try {
  4. extractPropertyOrField(actual, name);
  5. } catch (IntrospectionError error) {
  6. throw failures.failure(info, shouldHavePropertyOrField(actual, name));
  7. }
  8. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. public <E> void assertHasOnlyElementsOfType(AssertionInfo info, E[] actual, Class<?> type) {
  2. Objects.instance().assertNotNull(info, actual);
  3. for (Object element : actual) {
  4. if (!type.isInstance(element)) {
  5. throw failures.failure(info, shouldHaveOnlyElementsOfType(actual, type, element == null ? null : element.getClass()));
  6. }
  7. }
  8. }

代码示例来源:origin: org.assertj/assertj-core

  1. private void assertNotNull(AssertionInfo info, List<?> actual) {
  2. Objects.instance().assertNotNull(info, actual);
  3. }

代码示例来源:origin: org.assertj/assertj-core

  1. /**
  2. * Asserts that the actual object has the same hashCode as the given object.
  3. *
  4. * @param <A> the actual type
  5. * @param info contains information about the assertion.
  6. * @param actual the given object.
  7. * @param other the object to check hashCode against.
  8. *
  9. * @throws AssertionError if the actual object is null.
  10. * @throws AssertionError if the given object is null.
  11. * @throws AssertionError if the actual object has not the same hashCode as the given object.
  12. */
  13. public <A> void assertHasSameHashCodeAs(AssertionInfo info, A actual, Object other) {
  14. assertNotNull(info, actual);
  15. checkNotNull(other, "The object used to compare actual's hash code with should not be null");
  16. if (actual.hashCode() != other.hashCode()) throw failures.failure(info, shouldHaveSameHashCode(actual, other));
  17. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. public <E> void assertHasAtLeastOneElementOfType(AssertionInfo info, E[] actual, Class<?> type) {
  2. Objects.instance().assertNotNull(info, actual);
  3. boolean found = false;
  4. for (Object o : actual) {
  5. if (!type.isInstance(o)) continue;
  6. found = true;
  7. break;
  8. }
  9. if (!found) throw failures.failure(info, shouldHaveAtLeastOneElementOfType(actual, type));
  10. }

代码示例来源:origin: org.assertj/assertj-core

  1. private static void assertNotNull(AssertionInfo info, Boolean actual) {
  2. Objects.instance().assertNotNull(info, actual);
  3. }
  4. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. public <A> void assertHasFieldOrProperty(AssertionInfo info, A actual, String name) {
  2. assertNotNull(info, actual);
  3. try {
  4. extractPropertyOrField(actual, name);
  5. } catch (IntrospectionError error) {
  6. throw failures.failure(info, shouldHavePropertyOrField(actual, name));
  7. }
  8. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. public <E> void assertDoesNotHaveAnyElementsOfTypes(AssertionInfo info, E[] actual, Class<?>... unexpectedTypes) {
  2. Objects.instance().assertNotNull(info, actual);
  3. Map<Class<?>, List<Object>> nonMatchingElementsByType = new LinkedHashMap<>();
  4. for (E element : actual) {
  5. for (Class<?> type : unexpectedTypes) {
  6. if (type.isInstance(element)) {
  7. if (!nonMatchingElementsByType.containsKey(type)) {
  8. nonMatchingElementsByType.put(type, new ArrayList<>());
  9. }
  10. nonMatchingElementsByType.get(type).add(element);
  11. }
  12. }
  13. }
  14. if (!nonMatchingElementsByType.isEmpty()) {
  15. throw failures.failure(info, shouldNotHaveAnyElementsOfTypes(actual, unexpectedTypes, nonMatchingElementsByType));
  16. }
  17. }

代码示例来源:origin: org.assertj/assertj-core

  1. private void assertNotNull(AssertionInfo info, Future<?> actual) {
  2. Objects.instance().assertNotNull(info, actual);
  3. }
  4. }

代码示例来源:origin: joel-costigliola/assertj-core

  1. /**
  2. * Asserts that the actual object has the same hashCode as the given object.
  3. *
  4. * @param <A> the actual type
  5. * @param info contains information about the assertion.
  6. * @param actual the given object.
  7. * @param other the object to check hashCode against.
  8. *
  9. * @throws AssertionError if the actual object is null.
  10. * @throws AssertionError if the given object is null.
  11. * @throws AssertionError if the actual object has not the same hashCode as the given object.
  12. */
  13. public <A> void assertHasSameHashCodeAs(AssertionInfo info, A actual, Object other) {
  14. assertNotNull(info, actual);
  15. checkNotNull(other, "The object used to compare actual's hash code with should not be null");
  16. if (actual.hashCode() != other.hashCode()) throw failures.failure(info, shouldHaveSameHashCode(actual, other));
  17. }

代码示例来源:origin: org.assertj/assertj-core

  1. /**
  2. * Verifies that the actual {@code LocalDate} is today, that is matching current year, month and day.
  3. * <p>
  4. * Example:
  5. * <pre><code class='java'> // assertion will pass
  6. * assertThat(LocalDate.now()).isToday();
  7. *
  8. * // assertion will fail
  9. * assertThat(theFellowshipOfTheRing.getReleaseDate()).isToday();</code></pre>
  10. *
  11. * @return this assertion object.
  12. * @throws AssertionError if the actual {@code LocalDate} is {@code null}.
  13. * @throws AssertionError if the actual {@code LocalDate} is not today.
  14. */
  15. public SELF isToday() {
  16. Objects.instance().assertNotNull(info, actual);
  17. if (!actual.isEqual(LocalDate.now())) throw Failures.instance().failure(info, shouldBeToday(actual));
  18. return myself;
  19. }

代码示例来源:origin: org.assertj/assertj-core

  1. private static void assertNotNull(AssertionInfo info, File actual) {
  2. Objects.instance().assertNotNull(info, actual);
  3. }

相关文章