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 thatJavaCodeUnits
declare aThrowable
which matches the given predicate.declareThrowableOfType
(Class<? extends Throwable> type) Asserts thatJavaCodeUnits
declare aThrowable
of the specified type in their throws clause.declareThrowableOfType
(String typeName) Asserts thatJavaCodeUnits
declare aThrowable
of the specified fully qualified type name in their throws clause.haveRawParameterTypes
(DescribedPredicate<? super List<JavaClass>> predicate) Asserts thatJavaCodeUnits
have raw parameter types matching the given predicate.haveRawParameterTypes
(Class<?>... parameterTypes) Asserts thatJavaCodeUnits
have the specified raw parameter types.haveRawParameterTypes
(String... parameterTypeNames) Asserts thatJavaCodeUnits
have the specified fully qualified raw parameter type names.haveRawReturnType
(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnits
have raw return types matching the given predicate.haveRawReturnType
(Class<?> type) Asserts thatJavaCodeUnits
have the specified raw return type.haveRawReturnType
(String typeName) Asserts thatJavaCodeUnits
have the specified fully qualified raw return type name.notDeclareThrowableOfType
(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnits
do not declare aThrowable
which matches the given predicate.notDeclareThrowableOfType
(Class<? extends Throwable> type) Asserts thatJavaCodeUnits
do not declare aThrowable
of the specified type in their throws clause.notDeclareThrowableOfType
(String typeName) Asserts thatJavaCodeUnits
do not declare aThrowable
of the specified fully qualified type name in their throws clause.notHaveRawParameterTypes
(DescribedPredicate<? super List<JavaClass>> predicate) Asserts thatJavaCodeUnits
do not have raw parameter types matching the given predicate.notHaveRawParameterTypes
(Class<?>... parameterTypes) Asserts thatJavaCodeUnits
do not have the specified raw parameter types.notHaveRawParameterTypes
(String... parameterTypeNames) Asserts thatJavaCodeUnits
do not have the specified fully qualified raw parameter type names.notHaveRawReturnType
(DescribedPredicate<? super JavaClass> predicate) Asserts thatJavaCodeUnits
do not have raw return types matching the given predicate.notHaveRawReturnType
(Class<?> type) Asserts thatJavaCodeUnits
do not have the specified raw return type.notHaveRawReturnType
(String typeName) Asserts thatJavaCodeUnits
do 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 thatJavaCodeUnits
have the specified raw parameter types.
E.g.
would be violated bycodeUnits()
.should()
.haveRawParameterTypes(String.class, int.class)
someMethod
inclass Example { void someMethod(Object wrongParam, int intParam) {...} }
- Parameters:
parameterTypes
- Parameter typesJavaCodeUnits
should have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawParameterTypes
Asserts thatJavaCodeUnits
do not have the specified raw parameter types.
E.g.
would be violated bycodeUnits()
.should()
.notHaveRawParameterTypes(String.class, int.class)
someMethod
inclass Example { void someMethod(String stringParam, int intParam) {...} }
- Parameters:
parameterTypes
- Parameter typesJavaCodeUnits
should 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 thatJavaCodeUnits
have the specified fully qualified raw parameter type names.
E.g.
would be violated bycodeUnits()
.should()
.haveRawParameterTypes(String.class.getName(), int.class.getName())
someMethod
inclass Example { void someMethod(Object wrongParam, int intParam) {...} }
- Parameters:
parameterTypeNames
- Fully qualified names of parameter typesJavaCodeUnits
should have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawParameterTypes
Asserts thatJavaCodeUnits
do not have the specified fully qualified raw parameter type names.
E.g.
would be violated bycodeUnits()
.should()
.notHaveRawParameterTypes(String.class.getName(), int.class.getName())
someMethod
inclass Example { void someMethod(String stringParam, int intParam) {...} }
- Parameters:
parameterTypeNames
- Fully qualified names of parameter typesJavaCodeUnits
should 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 thatJavaCodeUnits
have raw parameter types matching the given predicate.
E.g.
would be violated bycodeUnits()
.should()
.haveRawParameterTypes(whereFirstTypeIs(String.class))
someMethod
inclass Example { void someMethod(Object wrongParam, int intParam) {...} }
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaClass
can be found withinJavaClass.Predicates
or one of the respective ancestors likeHasName.Predicates
.- Parameters:
predicate
- ADescribedPredicate
that determines, whichJavaCodeUnits
match 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 thatJavaCodeUnits
do not have raw parameter types matching the given predicate.
E.g.
would be violated bycodeUnits()
.should()
.notHaveRawParameterTypes(whereFirstTypeIs(String.class))
someMethod
inclass Example { void someMethod(String stringParam, int intParam) {...} }
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaClass
can be found withinJavaClass.Predicates
or one of the respective ancestors likeHasName.Predicates
.- Parameters:
predicate
- ADescribedPredicate
that determines, whichJavaCodeUnits
do not match by their raw parameter types- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
haveRawReturnType
Asserts thatJavaCodeUnits
have the specified raw return type.
E.g.
would be violated bycodeUnits()
.should()
.haveRawReturnType(String.class)
someMethod
inclass Example { Object someMethod() {...} }
- Parameters:
type
- Return typeJavaCodeUnits
should have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawReturnType
Asserts thatJavaCodeUnits
do not have the specified raw return type.
E.g.
would be violated bycodeUnits()
.should()
.notHaveRawReturnType(String.class)
someMethod
inclass Example { String someMethod() {...} }
- Parameters:
type
- Return typeJavaCodeUnits
should not have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
haveRawReturnType
Asserts thatJavaCodeUnits
have the specified fully qualified raw return type name.
E.g.
would be violated bycodeUnits()
.should()
.haveRawReturnType(String.class.getName())
someMethod
inclass Example { Object someMethod() {...} }
- Parameters:
typeName
- Fully qualified name of a return typeJavaCodeUnits
should have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notHaveRawReturnType
Asserts thatJavaCodeUnits
do not have the specified fully qualified raw return type name.
E.g.
would be violated bycodeUnits()
.should()
.notHaveRawReturnType(String.class.getName())
someMethod
inclass Example { String someMethod() {...} }
- Parameters:
typeName
- Fully qualified name of a return typeJavaCodeUnits
should 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 thatJavaCodeUnits
have raw return types matching the given predicate.
E.g.
would be violated bycodeUnits()
.should()
.haveRawReturnType(assignableTo(Serializable.class))
someMethod
inclass Example { Object someMethod() {...} }
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaClass
can be found withinJavaClass.Predicates
or one of the respective ancestors likeHasName.Predicates
.- Parameters:
predicate
- ADescribedPredicate
that determines, whichJavaCodeUnits
match 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 thatJavaCodeUnits
do not have raw return types matching the given predicate.
E.g.
would be violated bycodeUnits()
.should()
.notHaveRawReturnType(assignableTo(Serializable.class))
someMethod
inclass Example { String someMethod() {...} }
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaClass
can be found withinJavaClass.Predicates
or one of the respective ancestors likeHasName.Predicates
.- Parameters:
predicate
- ADescribedPredicate
that determines, whichJavaCodeUnits
do not match by their raw return types- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
declareThrowableOfType
Asserts thatJavaCodeUnits
declare aThrowable
of the specified type in their throws clause.
E.g.
would be violated bycodeUnits()
.should()
.declareThrowableOfType(SomeException.class)
someMethod
inclass Example { void someMethod() throws WrongException {...} }
- Parameters:
type
- Type of a declaredThrowable
JavaCodeUnits
should have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notDeclareThrowableOfType
Asserts thatJavaCodeUnits
do not declare aThrowable
of the specified type in their throws clause.
E.g.
would be violated bycodeUnits()
.should()
.notDeclareThrowableOfType(SomeException.class)
someMethod
inclass Example { void someMethod() throws SomeException {...} }
- Parameters:
type
- Type of a declaredThrowable
JavaCodeUnits
should not have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
declareThrowableOfType
Asserts thatJavaCodeUnits
declare aThrowable
of the specified fully qualified type name in their throws clause.
E.g.
would be violated bycodeUnits()
.should()
.declareThrowableOfType(SomeException.class.getName())
someMethod
inclass Example { void someMethod() throws WrongException {...} }
- Parameters:
typeName
- Fully qualified name of a type of a declaredThrowable
JavaCodeUnits
should have- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-
notDeclareThrowableOfType
Asserts thatJavaCodeUnits
do not declare aThrowable
of the specified fully qualified type name in their throws clause.
E.g.
would be violated bycodeUnits()
.should()
.notDeclareThrowableOfType(SomeException.class.getName())
someMethod
inclass Example { void someMethod() throws SomeException {...} }
- Parameters:
typeName
- Fully qualified name of a type of a declaredThrowable
JavaCodeUnits
should 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 thatJavaCodeUnits
declare aThrowable
which matches the given predicate.
E.g.
would be violated bycodeUnits()
.should()
.declareThrowableOfType(nameStartingWith("Some"))
someMethod
inclass Example { void someMethod() throws WrongException {...} }
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaClass
can be found withinJavaClass.Predicates
or one of the respective ancestors likeHasName.Predicates
.- Parameters:
predicate
- ADescribedPredicate
that determines, whichJavaCodeUnits
match 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 thatJavaCodeUnits
do not declare aThrowable
which matches the given predicate.
E.g.
would be violated bycodeUnits()
.should()
.notDeclareThrowableOfType(nameStartingWith("Some"))
someMethod
inclass Example { void someMethod() throws SomeException {...} }
Note that many predefinedpredicates
can be found within a subclassPredicates
of the respective domain object or a common ancestor. For example,predicates
targetingJavaClass
can be found withinJavaClass.Predicates
or one of the respective ancestors likeHasName.Predicates
.- Parameters:
predicate
- ADescribedPredicate
that determines, whichJavaCodeUnits
do not match by their declaredThrowable
- Returns:
- A syntax conjunction element, which can be completed to form a full rule
-