-
-
Save andres-sacco/595679052e67230484566aca2a714ca1 to your computer and use it in GitHub Desktop.
Return type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.methods; | |
import org.springframework.http.ResponseEntity; | |
import com.tngtech.archunit.core.importer.ImportOption; | |
import com.tngtech.archunit.junit.AnalyzeClasses; | |
import com.tngtech.archunit.junit.ArchTest; | |
import com.tngtech.archunit.lang.ArchRule; | |
@AnalyzeClasses(packages = "com.example.archunit", importOptions = ImportOption.DoNotIncludeTests.class) | |
class ReturnTypeRulesTest { | |
@ArchTest | |
static final ArchRule methods_should_return_response_entity = | |
methods().that().arePublic() | |
.and().areDeclaredInClassesThat() | |
.resideInAPackage("com.example.controller") | |
.should().haveRawReturnType(ResponseEntity.class) | |
.because("Controller endpoints should return a ResponseEntity object"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment