Package org.assertj.core.internal
Class Classes
java.lang.Object
org.assertj.core.internal.Classes
Reusable assertions for
Classs.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ComparisonStrategyprivate Failuresprivate static final Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidassertContainsAnnotations(AssertionInfo info, Class<?> actual, Class<? extends Annotation>[] annotations) Verifies that the actualClasscontains the givenAnnotations.voidassertHasDeclaredFields(AssertionInfo info, Class<?> actual, String... fields) Verifies that the actualClasshas the declaredfields.voidassertHasDeclaredMethods(AssertionInfo info, Class<?> actual, String... methods) Verifies that the actualClasshas the declaredmethods.voidassertHasMethods(AssertionInfo info, Class<?> actual, String... methods) Verifies that the actualClasshas themethods.voidassertHasNoSuperclass(AssertionInfo info, Class<?> actual) Verifies that the actualClasshas no superclass.voidassertHasOnlyDeclaredFields(AssertionInfo info, Class<?> actual, String... expectedFields) Verifies that the actualClasshas the exactly thefieldsand nothing more.voidassertHasOnlyPublicFields(AssertionInfo info, Class<?> actual, String... expectedFields) Verifies that the actualClasshas only thefieldsand nothing more.voidassertHasPackage(AssertionInfo info, Class<?> actual, Package aPackage) Verifies that the actualClasshas the givenPackage.voidassertHasPackage(AssertionInfo info, Class<?> actual, String packageName) Verifies that the actualClasshas the givenpackageName.voidassertHasPublicFields(AssertionInfo info, Class<?> actual, String... fields) Verifies that the actualClasshas thefields.voidassertHasPublicMethods(AssertionInfo info, Class<?> actual, String... methods) Verifies that the actualClasshas the publicmethods.voidassertHasSuperclass(AssertionInfo info, Class<?> actual, Class<?> superclass) Verifies that the actualClasshas the given class as directsuperclass.voidassertIsAbstract(AssertionInfo info, Class<?> actual) Verifies that the actualClassis abstract.voidassertIsAnnotation(AssertionInfo info, Class<?> actual) Verifies that the actualClassis an annotation.voidassertIsAssignableFrom(AssertionInfo info, Class<?> actual, Class<?>... others) Verifies that the actualClassis assignable from all theothersclasses.voidassertIsFinal(AssertionInfo info, Class<?> actual) Verifies that the actualClassis final.voidassertIsInterface(AssertionInfo info, Class<?> actual) Verifies that the actualClassis an interface.voidassertIsNotAnnotation(AssertionInfo info, Class<?> actual) Verifies that the actualClassis not an annotation.voidassertIsNotFinal(AssertionInfo info, Class<?> actual) Verifies that the actualClassis not final.voidassertIsNotInterface(AssertionInfo info, Class<?> actual) Verifies that the actualClassis not an interface.voidassertIsNotStatic(AssertionInfo info, Class<?> actual) Verifies that the actualClassis not static.voidassertIsPackagePrivate(AssertionInfo info, Class<?> actual) Verifies that the actualClassis package-private.voidassertIsProtected(AssertionInfo info, Class<?> actual) Verifies that the actualClassis protected.voidassertIsPublic(AssertionInfo info, Class<?> actual) Verifies that the actualClassis public.voidassertIsStatic(AssertionInfo info, Class<?> actual) Verifies that the actualClassis static.private static voidassertNotNull(AssertionInfo info, Class<?> actual) private static voidclassParameterIsNotNull(Class<?> clazz) used to check that the class to compare is not null, in that case throws aNullPointerExceptionwith an explicit message.private voiddoAssertHasMethods(AssertionInfo info, Class<?> actual, Set<Method> actualMethods, boolean declared, String... expectedMethods) fieldsToName(Set<Field> fields) filterSyntheticMembers(M[] members) private static Method[]getAllMethods(Class<?> actual) getMethodsWithModifier(Set<Method> methods, int modifier) private static booleanhasPublicMethods(Method[] methods) static Classesinstance()Returns the singleton instance of this class.methodsToName(Set<Method> methods) methodsToNameAndModifier(Method[] methods) private static booleanChecks that theexpectedNamesare part of theactualNames.private static booleannoNonMatchingModifier(Set<String> expectedMethodNames, Map<String, Integer> methodsModifier, Map<String, String> nonMatchingModifiers, int modifier)
-
Field Details
-
INSTANCE
-
failures
-
comparisonStrategy
-
-
Constructor Details
-
Classes
public Classes()
-
-
Method Details
-
instance
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
assertIsAssignableFrom
Verifies that the actualClassis assignable from all theothersclasses.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.others- the othersClasswho this actual class must be assignable.- Throws:
NullPointerException- if one of theothersisnull.AssertionError- ifactualisnull.AssertionError- if the actualClassis not assignable from all of theothersclasses.
-
assertIsNotInterface
Verifies that the actualClassis not an interface.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis an interface.
-
assertIsInterface
Verifies that the actualClassis an interface.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis not an interface.
-
assertIsAbstract
Verifies that the actualClassis abstract.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis not abstract.
-
assertIsNotAnnotation
Verifies that the actualClassis not an annotation.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis an annotation.
-
assertIsAnnotation
Verifies that the actualClassis an annotation.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis not an annotation.
-
assertIsFinal
Verifies that the actualClassis final.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis not final.
-
assertIsPublic
Verifies that the actualClassis public.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis not public.
-
assertIsProtected
Verifies that the actualClassis protected.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis not protected.
-
assertIsPackagePrivate
Verifies that the actualClassis package-private.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis not package-private.
-
assertIsNotFinal
Verifies that the actualClassis not final.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis final.
-
assertIsStatic
Verifies that the actualClassis static.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis not static.
-
assertIsNotStatic
Verifies that the actualClassis not static.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassis static.
-
assertContainsAnnotations
public void assertContainsAnnotations(AssertionInfo info, Class<?> actual, Class<? extends Annotation>[] annotations) Verifies that the actualClasscontains the givenAnnotations.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.annotations- annotations who must be attached to the class- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassdoesn't contains all of these annotations.
-
assertHasSuperclass
Verifies that the actualClasshas the given class as directsuperclass.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.superclass- the direct superclass, which should not be null.- Throws:
NullPointerException- ifsuperclassisnull.AssertionError- ifactualisnull.AssertionError- if the actualClassdoes not have the expected superclass.
-
assertHasNoSuperclass
Verifies that the actualClasshas no superclass.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClasshas a superclass.
-
assertHasPublicFields
Verifies that the actualClasshas thefields.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.fields- the fields who must be present in the class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassdoesn't contains all of the field.
-
assertHasOnlyPublicFields
public void assertHasOnlyPublicFields(AssertionInfo info, Class<?> actual, String... expectedFields) Verifies that the actualClasshas only thefieldsand nothing more. in any order.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.expectedFields- all the fields that are expected to be in the class.- Throws:
AssertionError- ifactualisnull.AssertionError- if fields are not all the fields of the actualClass.
-
noMissingElement
private static boolean noMissingElement(Set<String> actualNames, Set<String> expectedNames, Set<String> missingNames) Checks that theexpectedNamesare part of theactualNames. If anexpectedNameis not contained in theactualNames, the this method will returntrue. THemissingNameswill contain all theexpectedNamesthat are not part of theactualNames.- Parameters:
actualNames- the names that should be used to checkexpectedNames- the names that should be contained inactualNamesmissingNames- the names that were not part ofexpectedNames- Returns:
trueif allexpectedNamesare part of theactualNames,falseotherwise
-
assertHasDeclaredFields
Verifies that the actualClasshas the declaredfields.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.fields- the fields who must be declared in the class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassdoesn't contains all of the field.
-
assertHasOnlyDeclaredFields
public void assertHasOnlyDeclaredFields(AssertionInfo info, Class<?> actual, String... expectedFields) Verifies that the actualClasshas the exactly thefieldsand nothing more. in any order.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.expectedFields- all the fields that are expected to be in the class.- Throws:
AssertionError- ifactualisnull.AssertionError- if fields are not all the fields of the actualClass.
-
fieldsToName
-
assertHasMethods
Verifies that the actualClasshas themethods.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.methods- the methods who must be present in the class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassdoesn't contains all the methods.
-
assertHasDeclaredMethods
Verifies that the actualClasshas the declaredmethods.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.methods- the methods who must be declared in the class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassdoesn't contains all the methods.
-
doAssertHasMethods
private void doAssertHasMethods(AssertionInfo info, Class<?> actual, Set<Method> actualMethods, boolean declared, String... expectedMethods) -
assertHasPublicMethods
Verifies that the actualClasshas the publicmethods.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.methods- the public methods who must be present in the class.- Throws:
AssertionError- ifactualisnull.AssertionError- if the actualClassdoesn't contains all the public methods.
-
getMethodsWithModifier
-
noNonMatchingModifier
-
hasPublicMethods
-
methodsToName
-
methodsToNameAndModifier
-
getAllMethods
-
filterSyntheticMembers
-
assertNotNull
-
classParameterIsNotNull
used to check that the class to compare is not null, in that case throws aNullPointerExceptionwith an explicit message.- Parameters:
clazz- the date to check- Throws:
NullPointerException- with an explicit message if the given class is null
-
assertHasPackage
Verifies that the actualClasshas the givenpackageName.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.packageName- the package that must be declared in the class.- Throws:
NullPointerException- ifpackageNameisnull.AssertionError- ifactualisnull.AssertionError- ifactualdoes not have the given package name.
-
assertHasPackage
Verifies that the actualClasshas the givenPackage.- Parameters:
info- contains information about the assertion.actual- the "actual"Class.aPackage- the package that must be declared in the class.- Throws:
NullPointerException- ifaPackageisnull.AssertionError- ifactualisnull.AssertionError- ifactualdoes not have the given package.
-