public void assertHasSameSizeAs(AssertionInfo info, Object array, Object other) { assertNotNull(info, array); assertIsArray(info, array); assertIsArray(info, other); hasSameSizeAsCheck(info, array, other, sizeOf(array)); }
/** * Asserts that the given array contains the given values, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values. */ public void assertContains(AssertionInfo info, byte[] actual, int[] values) { arrays.assertContains(info, failures, actual, toByteArray(values)); }
/** * Verifies that the given array contains the given sequence of values, without any other values between them. * @param info contains information about the assertion. * @param actual the given array. * @param sequence the sequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSequence(AssertionInfo info, byte[] actual, int[] sequence) { arrays.assertContainsSequence(info, failures, actual, toByteArray(sequence)); }
public void assertHasDigest(AssertionInfo info, InputStream actual, MessageDigest digest, byte[] expected) { checkNotNull(digest, "The message digest algorithm should not be null"); checkNotNull(expected, "The binary representation of digest to compare to should not be null"); assertNotNull(info, actual); try { DigestDiff diff = digestDiff(actual, digest, expected); if (diff.digestsDiffer()) throw failures.failure(info, shouldHaveDigest(actual, diff)); } catch (IOException e) { String msg = format("Unable to calculate digest of InputStream:%n <%s>", actual); throw new InputStreamsException(msg, e); } }
public void assertExists(final AssertionInfo info, final Path actual) { assertNotNull(info, actual); if (!nioFilesWrapper.exists(actual)) throw failures.failure(info, shouldExist(actual)); }
public void assertIsExecutable(final AssertionInfo info, final Path actual) { assertNotNull(info, actual); assertExists(info, actual); if (!nioFilesWrapper.isExecutable(actual)) throw failures.failure(info, shouldBeExecutable(actual)); }
public void assertDoesNotExist(final AssertionInfo info, final Path actual) { assertNotNull(info, actual); if (!nioFilesWrapper.notExists(actual, LinkOption.NOFOLLOW_LINKS)) throw failures.failure(info, shouldNotExist(actual)); }
public void assertIsRegularFile(final AssertionInfo info, final Path actual) { assertExists(info, actual); if (!nioFilesWrapper.isRegularFile(actual)) throw failures.failure(info, shouldBeRegularFile(actual)); }
/** * {@inheritDoc} */ @Override @CheckReturnValue public SELF usingElementComparator(Comparator<? super ELEMENT> elementComparator) { this.iterables = new Iterables(new ComparatorBasedComparisonStrategy(elementComparator)); // to have the same semantics on base assertions like isEqualTo, we need to use an iterable comparator comparing // elements with elementComparator parameter objects = new Objects(new IterableElementComparisonStrategy<>(elementComparator)); return myself; }
void assertHasSameSizeAs(AssertionInfo info, Object array, Iterable<?> other) { assertNotNull(info, array); hasSameSizeAsCheck(info, array, other, sizeOf(array)); }
private static void checkIsNotNullAndNotEmpty(Object values) { checkIsNotNull(values); if (isArrayEmpty(values)) throw arrayOfValuesToLookForIsEmpty(); }
public boolean areEqualToIgnoringGivenFields(Object actual, Object other, Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators comparatorByType, String... fields) { return isEqualToIgnoringGivenFields(actual, other, comparatorByPropertyOrField, comparatorByType, fields).isFieldsNamesEmpty(); }
public boolean areEqualToComparingOnlyGivenFields(Object actual, Object other, Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators comparatorByType, String... fields) { return isEqualToComparingOnlyGivenFields(actual, other, comparatorByPropertyOrField, comparatorByType, fields).isFieldsNamesEmpty(); }
/** * Asserts that the given array does not contain the given values. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected not to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array contains any of given values. */ public void assertDoesNotContain(AssertionInfo info, byte[] actual, int[] values) { arrays.assertDoesNotContain(info, failures, actual, toByteArray(values)); }
/** * Asserts that the given array contains only the given values and nothing else, in any order. * @param info contains information about the assertion. * @param actual the given array. * @param values the values that are expected to be in the given array. * @throws NullPointerException if the array of values is {@code null}. * @throws IllegalArgumentException if the array of values is empty. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the given array does not contain the given values or if the given array contains values that are * not in the given array. */ public void assertContainsOnly(AssertionInfo info, byte[] actual, int[] values) { arrays.assertContainsOnly(info, failures, actual, toByteArray(values)); }
/** * Verifies that the given array contains the given sequence of values (possibly with other values between them). * * @param info contains information about the assertion. * @param actual the given array. * @param subsequence the subsequence of values to look for. * @throws AssertionError if the given array is {@code null}. * @throws NullPointerException if the given sequence is {@code null}. * @throws IllegalArgumentException if the given sequence is empty. * @throws AssertionError if the given array does not contain the given sequence of values. */ public void assertContainsSubsequence(AssertionInfo info, byte[] actual, int[] subsequence) { arrays.assertContainsSubsequence(info, failures, actual, toByteArray(subsequence)); }
public void assertExistsNoFollowLinks(final AssertionInfo info, final Path actual) { assertNotNull(info, actual); if (!nioFilesWrapper.exists(actual, LinkOption.NOFOLLOW_LINKS)) throw failures.failure(info, shouldExistNoFollowLinks(actual)); }