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

ru.yandex.qatools.allure.events.RemoveAttachmentsEvent Maven / Gradle / Ivy

There is a newer version: 1.4.0.RC9
Show newest version
package ru.yandex.qatools.allure.events;

import ru.yandex.qatools.allure.model.Attachment;
import ru.yandex.qatools.allure.model.Step;

import java.util.Iterator;
import java.util.regex.Pattern;

import static ru.yandex.qatools.allure.utils.AllureResultsUtils.deleteAttachment;

/**
 * @author Dmitry Baev [email protected]
 *         Date: 30.04.14
 */
public class RemoveAttachmentsEvent implements StepEvent {

    public final Pattern pattern;

    public RemoveAttachmentsEvent(String regex) {
        pattern = Pattern.compile(regex);
    }

    @Override
    public void process(Step context) {
        Iterator iterator = context.getAttachments().listIterator();
        while (iterator.hasNext()) {
            Attachment attachment = iterator.next();
            if (pattern.matcher(attachment.getSource()).matches()) {
                deleteAttachment(attachment);
                iterator.remove();
            }
        }

        for (Step step : context.getSteps()) {
            process(step);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy