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

ru.yandex.qatools.allure.storages.StepStorage Maven / Gradle / Ivy

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

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

import java.util.Deque;
import java.util.LinkedList;

/**
 * @author Dmitry Baev [email protected]
 *         Date: 13.12.13
 */
public class StepStorage extends ThreadLocal> {
    @Override
    protected Deque initialValue() {
        Deque queue = new LinkedList<>();
        queue.add(createRootStep());
        return queue;
    }

    public Step getLast() {
        return get().getLast();
    }

    public void put(Step step) {
        get().add(step);
    }

    public Step pollLast() {
        Deque queue = get();
        Step last = queue.pollLast();
        if (queue.isEmpty()) {
            queue.add(createRootStep());
        }
        return last;
    }

    public Step createRootStep() {
        return new Step()
                .withName("Root step")
                .withTitle("Allure step processing error: if you see this step something went wrong.")
                .withStart(System.currentTimeMillis())
                .withStatus(Status.BROKEN);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy