Interface CodeUnitsShould<CONJUNCTION extends CodeUnitsShouldConjunction<?>>
- All Superinterfaces:
MembersShould<CONJUNCTION>
- All Known Subinterfaces:
MethodsShould<CONJUNCTION>
@PublicAPI(usage=ACCESS)
public interface CodeUnitsShould<CONJUNCTION extends CodeUnitsShouldConjunction<?>>
extends MembersShould<CONJUNCTION>
-
Method Summary
Modifier and TypeMethodDescriptiondeclareThrowableOfType(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnitsdeclare aThrowablewhich matches the given predicate.declareThrowableOfType(Class<? extends Throwable> type) Asserts thatJavaCodeUnitsdeclare aThrowableof the specified type in their throws clause.declareThrowableOfType(String typeName) Asserts thatJavaCodeUnitsdeclare aThrowableof the specified fully qualified type name in their throws clause.haveRawParameterTypes(DescribedPredicate<? super List<JavaClass>> predicate) Asserts thatJavaCodeUnitshave raw parameter types matching the given predicate.haveRawParameterTypes(Class<?>... parameterTypes) Asserts thatJavaCodeUnitshave the specified raw parameter types.haveRawParameterTypes(String... parameterTypeNames) Asserts thatJavaCodeUnitshave the specified fully qualified raw parameter type names.haveRawReturnType(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnitshave raw return types matching the given predicate.haveRawReturnType(Class<?> type) Asserts thatJavaCodeUnitshave the specified raw return type.haveRawReturnType(String typeName) Asserts thatJavaCodeUnitshave the specified fully qualified raw return type name.notDeclareThrowableOfType(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnitsdo not declare aThrowablewhich matches the given predicate.notDeclareThrowableOfType(Class<? extends Throwable> type) Asserts thatJavaCodeUnitsdo not declare aThrowableof the specified type in their throws clause.notDeclareThrowableOfType(String typeName) Asserts thatJavaCodeUnitsdo not declare aThrowableof the specified fully qualified type name in their throws clause.notHaveRawParameterTypes(DescribedPredicate<? super List<JavaClass>> predicate) Asserts thatJavaCodeUnitsdo not have raw parameter types matching the given predicate.notHaveRawParameterTypes(Class<?>... parameterTypes) Asserts thatJavaCodeUnitsdo not have the specified raw parameter types.notHaveRawParameterTypes(String... parameterTypeNames) Asserts thatJavaCodeUnitsdo not have the specified fully qualified raw parameter type names.notHaveRawReturnType(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnitsdo not have raw return types matching the given predicate.notHaveRawReturnType(Class<?> type) Asserts thatJavaCodeUnitsdo not have the specified raw return type.notHaveRawReturnType(String typeName) Asserts thatJavaCodeUnitsdo not have the specified fully qualified raw return type name.Asserts that only certain objects call the code units selected by this rule.Methods inherited from interface com.tngtech.archunit.lang.syntax.elements.MembersShould
beAnnotatedWith, beAnnotatedWith, beAnnotatedWith, beDeclaredIn, beDeclaredIn, beDeclaredInClassesThat, beDeclaredInClassesThat, beMetaAnnotatedWith, beMetaAnnotatedWith, beMetaAnnotatedWith, bePackagePrivate, bePrivate, beProtected, bePublic, containNumberOfElements, haveFullName, haveFullNameMatching, haveFullNameNotMatching, haveModifier, haveName, haveNameContaining, haveNameEndingWith, haveNameMatching, haveNameNotContaining, haveNameNotEndingWith, haveNameNotMatching, haveNameNotStartingWith, haveNameStartingWith, notBeAnnotatedWith, notBeAnnotatedWith, notBeAnnotatedWith, notBeDeclaredIn, notBeDeclaredIn, notBeMetaAnnotatedWith, notBeMetaAnnotatedWith, notBeMetaAnnotatedWith, notBePackagePrivate, notBePrivate, notBeProtected, notBePublic, notHaveFullName, notHaveModifier, notHaveName
-
Method Details
-
haveRawParameterTypes
Asserts thatJavaCodeUnitshave the specified raw parameter types.
E.g.
would be violated bycodeUnits().should().haveRawParameterTypes(String.class, int.class)someMethodinclass Example { void someMethod(Object wrongParam, int intParam) {...} }- Parameters:
parameterTypes- Parameter typesJavaCodeUnitsshould have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawParameterTypes
Asserts thatJavaCodeUnitsdo not have the specified raw parameter types.
E.g.
would be violated bycodeUnits().should().notHaveRawParameterTypes(String.class, int.class)someMethodinclass Example { void someMethod(String stringParam, int intParam) {...} }- Parameters:
parameterTypes- Parameter typesJavaCodeUnitsshould not have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
onlyBeCalled
Asserts that only certain objects call the code units selected by this rule.
E.g.codeUnits().should().onlyBeCalled().byClassesThat().belongToAnyOf(SomeClass.class)- Returns:
- A syntax element that allows restricting how code units can be called
-
haveRawParameterTypes
Asserts thatJavaCodeUnitshave the specified fully qualified raw parameter type names.
E.g.
would be violated bycodeUnits().should().haveRawParameterTypes(String.class.getName(), int.class.getName())someMethodinclass Example { void someMethod(Object wrongParam, int intParam) {...} }- Parameters:
parameterTypeNames- Fully qualified names of parameter typesJavaCodeUnitsshould have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawParameterTypes
Asserts thatJavaCodeUnitsdo not have the specified fully qualified raw parameter type names.
E.g.
would be violated bycodeUnits().should().notHaveRawParameterTypes(String.class.getName(), int.class.getName())someMethodinclass Example { void someMethod(String stringParam, int intParam) {...} }- Parameters:
parameterTypeNames- Fully qualified names of parameter typesJavaCodeUnitsshould not have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
haveRawParameterTypes
@PublicAPI(usage=ACCESS) CONJUNCTION haveRawParameterTypes(DescribedPredicate<? super List<JavaClass>> predicate) Asserts thatJavaCodeUnitshave raw parameter types matching the given predicate.
E.g.
would be violated bycodeUnits().should().haveRawParameterTypes(whereFirstTypeIs(String.class))someMethodinclass Example { void someMethod(Object wrongParam, int intParam) {...} }
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates.- Parameters:
predicate- ADescribedPredicatethat determines, whichJavaCodeUnitsmatch by their raw parameter types- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawParameterTypes
@PublicAPI(usage=ACCESS) CONJUNCTION notHaveRawParameterTypes(DescribedPredicate<? super List<JavaClass>> predicate) Asserts thatJavaCodeUnitsdo not have raw parameter types matching the given predicate.
E.g.
would be violated bycodeUnits().should().notHaveRawParameterTypes(whereFirstTypeIs(String.class))someMethodinclass Example { void someMethod(String stringParam, int intParam) {...} }
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates.- Parameters:
predicate- ADescribedPredicatethat determines, whichJavaCodeUnitsdo not match by their raw parameter types- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
haveRawReturnType
Asserts thatJavaCodeUnitshave the specified raw return type.
E.g.
would be violated bycodeUnits().should().haveRawReturnType(String.class)someMethodinclass Example { Object someMethod() {...} }- Parameters:
type- Return typeJavaCodeUnitsshould have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawReturnType
Asserts thatJavaCodeUnitsdo not have the specified raw return type.
E.g.
would be violated bycodeUnits().should().notHaveRawReturnType(String.class)someMethodinclass Example { String someMethod() {...} }- Parameters:
type- Return typeJavaCodeUnitsshould not have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
haveRawReturnType
Asserts thatJavaCodeUnitshave the specified fully qualified raw return type name.
E.g.
would be violated bycodeUnits().should().haveRawReturnType(String.class.getName())someMethodinclass Example { Object someMethod() {...} }- Parameters:
typeName- Fully qualified name of a return typeJavaCodeUnitsshould have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawReturnType
Asserts thatJavaCodeUnitsdo not have the specified fully qualified raw return type name.
E.g.
would be violated bycodeUnits().should().notHaveRawReturnType(String.class.getName())someMethodinclass Example { String someMethod() {...} }- Parameters:
typeName- Fully qualified name of a return typeJavaCodeUnitsshould not have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
haveRawReturnType
@PublicAPI(usage=ACCESS) CONJUNCTION haveRawReturnType(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnitshave raw return types matching the given predicate.
E.g.
would be violated bycodeUnits().should().haveRawReturnType(assignableTo(Serializable.class))someMethodinclass Example { Object someMethod() {...} }
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates.- Parameters:
predicate- ADescribedPredicatethat determines, whichJavaCodeUnitsmatch by their raw return types- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawReturnType
@PublicAPI(usage=ACCESS) CONJUNCTION notHaveRawReturnType(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnitsdo not have raw return types matching the given predicate.
E.g.
would be violated bycodeUnits().should().notHaveRawReturnType(assignableTo(Serializable.class))someMethodinclass Example { String someMethod() {...} }
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates.- Parameters:
predicate- ADescribedPredicatethat determines, whichJavaCodeUnitsdo not match by their raw return types- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
declareThrowableOfType
Asserts thatJavaCodeUnitsdeclare aThrowableof the specified type in their throws clause.
E.g.
would be violated bycodeUnits().should().declareThrowableOfType(SomeException.class)someMethodinclass Example { void someMethod() throws WrongException {...} }- Parameters:
type- Type of a declaredThrowableJavaCodeUnitsshould have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notDeclareThrowableOfType
Asserts thatJavaCodeUnitsdo not declare aThrowableof the specified type in their throws clause.
E.g.
would be violated bycodeUnits().should().notDeclareThrowableOfType(SomeException.class)someMethodinclass Example { void someMethod() throws SomeException {...} }- Parameters:
type- Type of a declaredThrowableJavaCodeUnitsshould not have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
declareThrowableOfType
Asserts thatJavaCodeUnitsdeclare aThrowableof the specified fully qualified type name in their throws clause.
E.g.
would be violated bycodeUnits().should().declareThrowableOfType(SomeException.class.getName())someMethodinclass Example { void someMethod() throws WrongException {...} }- Parameters:
typeName- Fully qualified name of a type of a declaredThrowableJavaCodeUnitsshould have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notDeclareThrowableOfType
Asserts thatJavaCodeUnitsdo not declare aThrowableof the specified fully qualified type name in their throws clause.
E.g.
would be violated bycodeUnits().should().notDeclareThrowableOfType(SomeException.class.getName())someMethodinclass Example { void someMethod() throws SomeException {...} }- Parameters:
typeName- Fully qualified name of a type of a declaredThrowableJavaCodeUnitsshould not have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
declareThrowableOfType
@PublicAPI(usage=ACCESS) CONJUNCTION declareThrowableOfType(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnitsdeclare aThrowablewhich matches the given predicate.
E.g.
would be violated bycodeUnits().should().declareThrowableOfType(nameStartingWith("Some"))someMethodinclass Example { void someMethod() throws WrongException {...} }
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates.- Parameters:
predicate- ADescribedPredicatethat determines, whichJavaCodeUnitsmatch by their declaredThrowable- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notDeclareThrowableOfType
@PublicAPI(usage=ACCESS) CONJUNCTION notDeclareThrowableOfType(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnitsdo not declare aThrowablewhich matches the given predicate.
E.g.
would be violated bycodeUnits().should().notDeclareThrowableOfType(nameStartingWith("Some"))someMethodinclass Example { void someMethod() throws SomeException {...} }
Note that many predefinedpredicatescan be found within a subclassPredicatesof the respective domain object or a common ancestor. For example,predicatestargetingJavaClasscan be found withinJavaClass.Predicatesor one of the respective ancestors likeHasName.Predicates.- Parameters:
predicate- ADescribedPredicatethat determines, whichJavaCodeUnitsdo not match by their declaredThrowable- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-