}
@AfterReturning(pointcut = "anyMethod() && withAttachmentAnnotation()", returning = "result")
public void attachment(JoinPoint joinPoint, Object result) {
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Attachment attachment = methodSignature.getMethod().getAnnotation(Attachment.class);
String attachTitle = AllureAspectUtils.getTitle(
attachment.value(),
methodSignature.getName(),
joinPoint.getThis(),
joinPoint.getArgs()
);
Charset charset = AllureConfig.newInstance().getAttachmentsEncoding();
byte[] bytes = (result instanceof byte[]) ? (byte[]) result : result.toString().getBytes(charset);
Allure.LIFECYCLE.fire(new MakeAttachmentEvent(bytes, attachTitle, attachment.type()));
}