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 void assertHasToString(AssertionInfo info, Object actual, String expectedToString) { assertNotNull(info, actual); if (!actual.toString().equals(expectedToString)) throw failures.failure(info, shouldHaveToString(actual, expectedToString)); }
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 void assertHasToString(AssertionInfo info, Object actual, String expectedToString) { assertNotNull(info, actual); if (!actual.toString().equals(expectedToString)) throw failures.failure(info, shouldHaveToString(actual, expectedToString)); }
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 <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)); } }
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); }
/** * 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)); }
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 <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)); } }
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); } }
/** * 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)); }
/** * 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); }