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

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

本文整理了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

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 <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: 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: 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: 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 <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: 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);
}

代码示例来源:origin: joel-costigliola/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

protected static <T> void assertNotNull(AssertionInfo info, T actual) {
 Objects.instance().assertNotNull(info, actual);
}

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

/**
 * Verifies that the actual {@code LocalDate} is <b>strictly</b> before the given one.
 * <p>
 * Example :
 * <pre><code class='java'> assertThat(parse("2000-01-01")).isBefore(parse("2000-01-02"));</code></pre>
 *
 * @param other the given {@link LocalDate}.
 * @return this assertion object.
 * @throws AssertionError if the actual {@code LocalDate} is {@code null}.
 * @throws IllegalArgumentException if other {@code LocalDate} is {@code null}.
 * @throws AssertionError if the actual {@code LocalDate} is not strictly before the given one.
 */
public SELF isBefore(LocalDate other) {
 Objects.instance().assertNotNull(info, actual);
 assertLocalDateParameterIsNotNull(other);
 if (!actual.isBefore(other)) throw Failures.instance().failure(info, shouldBeBefore(actual, other));
 return myself;
}

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

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

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

/**
 * 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()}).
 * The Pattern used under the hood enables the {@link Pattern#DOTALL} mode.
 *
 * @param info contains information about the assertion.
 * @param actual the given {@code Throwable}.
 * @param regex the regular expression expected to be found in the actual {@code Throwable}'s message.
 * @throws AssertionError if the actual {@code Throwable} is {@code null}.
 * @throws AssertionError if the message of the actual {@code Throwable} doesn't contain any sequence matching with the given regular expression
 * @throws NullPointerException if the regex is null
 */
public void assertHasMessageFindingMatch(AssertionInfo info, Throwable actual, String regex) {
 checkNotNull(regex, "regex must not be null");
 assertNotNull(info, actual);
 Objects.instance().assertNotNull(info, actual.getMessage(), "exception message of actual");
 if (Pattern.compile(regex, Pattern.DOTALL).asPredicate().test(actual.getMessage())) return;
 throw failures.failure(info, shouldHaveMessageFindingMatchRegex(actual, regex));
}

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

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

相关文章

微信公众号

最新文章

更多