All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.qase.commons.Methods Maven / Gradle / Ivy

The newest version!
package io.qase.commons;

import io.qase.commons.models.domain.Attachment;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class Methods {
    public static void addComment(String message) {
        if (!CasesStorage.isCaseInProgress()) {
            return;
        }

        CasesStorage.getCurrentCase().message = message;
    }

    public static void addAttachments(String... attachments) {
        List attachmentList = Arrays.stream(attachments)
                .map(path -> {
                    Attachment attachment = new Attachment();
                    attachment.filePath = path;
                    return attachment;
                })
                .collect(Collectors.toList());

        if (StepStorage.isStepInProgress()) {
            StepStorage.getCurrentStep().attachments.addAll(attachmentList);
        } else {
            CasesStorage.getCurrentCase().attachments.addAll(attachmentList);
        }
    }

    public static void addAttachment(String fileName, String content, String contentType) {
        Attachment attachment = new Attachment();
        attachment.fileName = fileName;
        attachment.content = content;
        attachment.mimeType = contentType;

        if (StepStorage.isStepInProgress()) {
            StepStorage.getCurrentStep().attachments.add(attachment);
        } else {
            CasesStorage.getCurrentCase().attachments.add(attachment);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy