Skip to content

Instantly share code, notes, and snippets.

@andres-sacco
Last active January 16, 2021 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andres-sacco/595679052e67230484566aca2a714ca1 to your computer and use it in GitHub Desktop.
Save andres-sacco/595679052e67230484566aca2a714ca1 to your computer and use it in GitHub Desktop.
Return type
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