How can I write Junit test for the following code
@Aspect
@Component
@Slf4j
public class SampleAspect {
@Value("${timeout:10}")
private long timeout;
@Around("@annotation(com.packagename.TrackExecutionTime)")
public Object intercept( ProceedingJoinPoint point) throws Throwable {
long startTime = System.currentTimeMillis();
Object obj = point.proceed();
long endTime = System.currentTimeMillis();
long timeOut = endTime-startTime;
if(timeOut > timeout)
{
log.error("Error occured");
}
return obj;
}
}
So the above aspect need to be tested and covered the if condition as well