private Attachment convert(final Path source, final ResultsVisitor visitor, final io.qameta.allure.model.Attachment attachment) { final Path attachmentFile = source.resolve(attachment.getSource()); if (Files.isRegularFile(attachmentFile)) { final Attachment found = visitor.visitAttachmentFile(attachmentFile); if (nonNull(attachment.getType())) { found.setType(attachment.getType()); } if (nonNull(attachment.getName())) { found.setName(attachment.getName()); } return found; } else { visitor.error("Could not find attachment " + attachment.getSource() + " in directory " + source); return new Attachment() .setType(attachment.getType()) .setName(attachment.getName()) .setSize(0L); } }
final Attachment attachment = new Attachment() .setName(isEmpty(name) ? null : name) .setType(isEmpty(type) ? null : type) .setSource(source); return attachment.getSource();
public static Attachment writeAttachment(byte[] data, String name, String passedType, Path outputDirectory) { String fileName = generateAttachmentFileName(); boolean isTypeProvided = passedType == null || passedType.isEmpty(); String type = isTypeProvided ? getAttachmentType(data) : passedType; String extension = getExtensionByMimeType(type); String source = fileName + extension; write(data, source, outputDirectory); return new Attachment().withName(name).withType(type).withSource(source); }
public Attachment withSource(String value) { setSource(value); return this; }
public Attachment withType(String value) { setType(value); return this; }
public Attachment withName(String value) { setName(value); return this; }
/** * Create an instance of {@link Attachment } * */ public Attachment createAttachment() { return new Attachment(); }
public Attachment withSource(String value) { setSource(value); return this; }
public Attachment withType(String value) { setType(value); return this; }
public Attachment withName(String value) { setName(value); return this; }
/** * Create an instance of {@link Attachment } * */ public Attachment createAttachment() { return new Attachment(); }
private Attachment convert(final Path source, final ResultsVisitor visitor, final io.qameta.allure.model.Attachment attachment) { final Path attachmentFile = source.resolve(attachment.getSource()); if (Files.isRegularFile(attachmentFile)) { final Attachment found = visitor.visitAttachmentFile(attachmentFile); if (nonNull(attachment.getType())) { found.setType(attachment.getType()); } if (nonNull(attachment.getName())) { found.setName(attachment.getName()); } return found; } else { visitor.error("Could not find attachment " + attachment.getSource() + " in directory " + source); return new Attachment() .setType(attachment.getType()) .setName(attachment.getName()) .setSize(0L); } }
/** * @deprecated use set method */ @Deprecated public Attachment withSource(final String value) { return setSource(value); }
/** * @deprecated use set method */ @Deprecated public Attachment withType(final String value) { return setType(value); } }
/** * @deprecated use set method */ @Deprecated public Attachment withName(final String value) { return setName(value); }