Refine search
private void assertNotNull(AssertionInfo info, CharSequence actual) { Objects.instance().assertNotNull(info, actual); }
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())); } }
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)); }
private static void assertNotNull(AssertionInfo info, Class<?> actual) { Objects.instance().assertNotNull(info, actual); }
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)); } }
private static void assertNotNull(AssertionInfo info, Instant actual) { Objects.instance().assertNotNull(info, actual); }
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())); } } }
private void assertNotNull(AssertionInfo info, List<?> actual) { Objects.instance().assertNotNull(info, actual); }
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)); }
private static void assertNotNull(AssertionInfo info, Boolean actual) { Objects.instance().assertNotNull(info, actual); } }
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)); } }
private void assertNotNull(AssertionInfo info, Future<?> actual) { Objects.instance().assertNotNull(info, actual); } }
/** * 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; }
private static void assertNotNull(AssertionInfo info, File actual) { Objects.instance().assertNotNull(info, actual); }
/** * 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; }
protected static <T> void assertNotNull(AssertionInfo info, T actual) { Objects.instance().assertNotNull(info, actual); }
/** * 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; }
private static void assertNotNull(AssertionInfo info, Throwable actual) { Objects.instance().assertNotNull(info, actual); }
/** * 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)); }
void assertNotNull(AssertionInfo info, Iterable<?> actual) { Objects.instance().assertNotNull(info, actual); }