/** * Delegates to {@link ComparisonStrategy#iterableContains(Iterable, Object)} */ private boolean iterableContains(Iterable<?> actual, Object value) { return comparisonStrategy.iterableContains(actual, value); }
/** * Delegates to {@link ComparisonStrategy#iterableContains(Iterable, Object)} */ private boolean iterableContains(Iterable<?> actual, Object value) { return comparisonStrategy.iterableContains(actual, value); }
private boolean iterableContains(Iterable<?> actual, Object value) { return comparisonStrategy.iterableContains(actual, value); }
/** * Delegates to {@link ComparisonStrategy#iterableContains(Iterable, Object)} */ private boolean iterableContains(Iterable<?> actual, Object value) { return comparisonStrategy.iterableContains(actual, value); }
/** * Delegates to {@link ComparisonStrategy#iterableContains(Iterable, Object)} */ private boolean iterableContains(Iterable<?> actual, Object value) { return comparisonStrategy.iterableContains(actual, value); }
private boolean iterableContains(Iterable<?> actual, Object value) { return comparisonStrategy.iterableContains(actual, value); }
/** * Verifies that the actual {@code Class} has only the {@code fields} and nothing more. <b>in any order</b>. * * @param info contains information about the assertion. * @param actual the "actual" {@code Class}. * @param expectedFields all the fields that are expected to be in the class. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if fields are not all the fields of the actual {@code Class}. */ public void assertHasOnlyPublicFields(AssertionInfo info, Class<?> actual, String... expectedFields) { assertNotNull(info, actual); Set<String> actualFieldNames = fieldsToName(filterSyntheticMembers(actual.getFields())); List<String> notExpected = newArrayList(actualFieldNames); List<String> notFound = newArrayList(expectedFields); if (expectedFields.length == 0) { if (actualFieldNames.isEmpty()) return; throw failures.failure(info, shouldHaveNoPublicFields(actual, actualFieldNames)); } for (String field : expectedFields) { if (comparisonStrategy.iterableContains(notExpected, field)) { comparisonStrategy.iterablesRemoveFirst(notExpected, field); comparisonStrategy.iterablesRemoveFirst(notFound, field); } } if (notExpected.isEmpty() && notFound.isEmpty()) return; throw failures.failure(info, shouldOnlyHaveFields(actual, newArrayList(expectedFields), notFound, notExpected)); }
/** * Verifies that the actual {@code Class} has the exactly the {@code fields} and nothing more. <b>in any order</b>. * * @param info contains information about the assertion. * @param actual the "actual" {@code Class}. * @param expectedFields all the fields that are expected to be in the class. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if fields are not all the fields of the actual {@code Class}. */ public void assertHasOnlyDeclaredFields(AssertionInfo info, Class<?> actual, String... expectedFields) { assertNotNull(info, actual); Set<String> actualFieldNames = fieldsToName(filterSyntheticMembers(actual.getDeclaredFields())); List<String> notExpected = newArrayList(actualFieldNames); List<String> notFound = newArrayList(expectedFields); if (expectedFields.length == 0) { if (actualFieldNames.isEmpty()) return; throw failures.failure(info, shouldHaveNoDeclaredFields(actual, actualFieldNames)); } for (String field : expectedFields) { if (comparisonStrategy.iterableContains(notExpected, field)) { comparisonStrategy.iterablesRemoveFirst(notExpected, field); comparisonStrategy.iterablesRemoveFirst(notFound, field); } } if (notExpected.isEmpty() && notFound.isEmpty()) return; throw failures.failure(info, shouldOnlyHaveDeclaredFields(actual, newArrayList(expectedFields), notFound, notExpected)); }
/** * Verifies that the actual {@code Class} has only the {@code fields} and nothing more. <b>in any order</b>. * * @param info contains information about the assertion. * @param actual the "actual" {@code Class}. * @param expectedFields all the fields that are expected to be in the class. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if fields are not all the fields of the actual {@code Class}. */ public void assertHasOnlyPublicFields(AssertionInfo info, Class<?> actual, String... expectedFields) { assertNotNull(info, actual); Set<String> actualFieldNames = fieldsToName(filterSyntheticMembers(actual.getFields())); List<String> notExpected = newArrayList(actualFieldNames); List<String> notFound = newArrayList(expectedFields); if (expectedFields.length == 0) { if (actualFieldNames.isEmpty()) return; throw failures.failure(info, shouldHaveNoPublicFields(actual, actualFieldNames)); } for (String field : expectedFields) { if (comparisonStrategy.iterableContains(notExpected, field)) { comparisonStrategy.iterablesRemoveFirst(notExpected, field); comparisonStrategy.iterablesRemoveFirst(notFound, field); } } if (notExpected.isEmpty() && notFound.isEmpty()) return; throw failures.failure(info, shouldOnlyHaveFields(actual, newArrayList(expectedFields), notFound, notExpected)); }
/** * Verifies that the actual {@code Class} has the exactly the {@code fields} and nothing more. <b>in any order</b>. * * @param info contains information about the assertion. * @param actual the "actual" {@code Class}. * @param expectedFields all the fields that are expected to be in the class. * @throws AssertionError if {@code actual} is {@code null}. * @throws AssertionError if fields are not all the fields of the actual {@code Class}. */ public void assertHasOnlyDeclaredFields(AssertionInfo info, Class<?> actual, String... expectedFields) { assertNotNull(info, actual); Set<String> actualFieldNames = fieldsToName(filterSyntheticMembers(actual.getDeclaredFields())); List<String> notExpected = newArrayList(actualFieldNames); List<String> notFound = newArrayList(expectedFields); if (expectedFields.length == 0) { if (actualFieldNames.isEmpty()) return; throw failures.failure(info, shouldHaveNoDeclaredFields(actual, actualFieldNames)); } for (String field : expectedFields) { if (comparisonStrategy.iterableContains(notExpected, field)) { comparisonStrategy.iterablesRemoveFirst(notExpected, field); comparisonStrategy.iterablesRemoveFirst(notFound, field); } } if (notExpected.isEmpty() && notFound.isEmpty()) return; throw failures.failure(info, shouldOnlyHaveDeclaredFields(actual, newArrayList(expectedFields), notFound, notExpected)); }
/** * Delegates to {@link ComparisonStrategy#iterableContains(Iterable, Object)} */ private boolean iterableContains(Iterable<?> actual, Object value) { return comparisonStrategy.iterableContains(actual, value); }
/** * Delegates to {@link ComparisonStrategy#iterableContains(Iterable, Object)} */ private boolean iterableContains(Iterable<?> actual, Object value) { return comparisonStrategy.iterableContains(actual, value); }