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

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

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

Objects.instance介绍

[英]Returns the singleton instance of this class based on StandardComparisonStrategy.
[中]基于StandardComparisonStrategy返回此类的单例实例。

代码示例

代码示例来源: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 <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: 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: 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: 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 <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: 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. }

代码示例来源:origin: joel-costigliola/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. protected static <T> void assertNotNull(AssertionInfo info, T actual) {
  2. Objects.instance().assertNotNull(info, actual);
  3. }

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

  1. /**
  2. * Verifies that the actual {@code LocalDate} is <b>strictly</b> before the given one.
  3. * <p>
  4. * Example :
  5. * <pre><code class='java'> assertThat(parse("2000-01-01")).isBefore(parse("2000-01-02"));</code></pre>
  6. *
  7. * @param other the given {@link LocalDate}.
  8. * @return this assertion object.
  9. * @throws AssertionError if the actual {@code LocalDate} is {@code null}.
  10. * @throws IllegalArgumentException if other {@code LocalDate} is {@code null}.
  11. * @throws AssertionError if the actual {@code LocalDate} is not strictly before the given one.
  12. */
  13. public SELF isBefore(LocalDate other) {
  14. Objects.instance().assertNotNull(info, actual);
  15. assertLocalDateParameterIsNotNull(other);
  16. if (!actual.isBefore(other)) throw Failures.instance().failure(info, shouldBeBefore(actual, other));
  17. return myself;
  18. }

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

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

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

  1. /**
  2. * Asserts that a sequence of the message of the actual {@code Throwable} matches with the given regular expression (see {@link java.util.regex.Matcher#find()}).
  3. * The Pattern used under the hood enables the {@link Pattern#DOTALL} mode.
  4. *
  5. * @param info contains information about the assertion.
  6. * @param actual the given {@code Throwable}.
  7. * @param regex the regular expression expected to be found in the actual {@code Throwable}'s message.
  8. * @throws AssertionError if the actual {@code Throwable} is {@code null}.
  9. * @throws AssertionError if the message of the actual {@code Throwable} doesn't contain any sequence matching with the given regular expression
  10. * @throws NullPointerException if the regex is null
  11. */
  12. public void assertHasMessageFindingMatch(AssertionInfo info, Throwable actual, String regex) {
  13. checkNotNull(regex, "regex must not be null");
  14. assertNotNull(info, actual);
  15. Objects.instance().assertNotNull(info, actual.getMessage(), "exception message of actual");
  16. if (Pattern.compile(regex, Pattern.DOTALL).asPredicate().test(actual.getMessage())) return;
  17. throw failures.failure(info, shouldHaveMessageFindingMatchRegex(actual, regex));
  18. }

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

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

相关文章