-
Notifications
You must be signed in to change notification settings - Fork 322
Open
Description
I want to create a ArchUnit test to ensure no unnecessary public methods are created in my handlers.
A code violation is as follows:
public class GetAuditLogQueryHandler implements IQueryHandler<GetAuditLogQuery, List<GetAuditLogQueryResponse>> {
@Override
public List<GetAuditLogQueryResponse> query(GetAuditLogQuery query) {
}
public List<GetAuditLogQueryResponse> query(Long periodId) {
}
}
I tried writing an assertion as follows:
ArchRule rule = methods().that().arePublic()
.and().areDeclaredInClassesThat().implement(IQueryHandler.class)
.should().containNumberOfElements(DescribedPredicate.equalTo(1));
But instead of ensuring there is only one public method in each class, it counts all public methods in the scanned JavaClasses.
Metadata
Metadata
Assignees
Labels
No labels