BeanShell Assertion in Jmeter

We can add beanshell assertion as a post processor to any of our request and paste the below commands there , that is if reponse code is not 200 then throw a error that we type in Failure message

if(ctx.getPreviousResult().getResponseCode().equals("200")){
Failure=false;
}
else{
Failure=true;}
FailureMessage = "Response code is not 200";

We can then go to view result tree and check if assertion passed or failed.