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

ru.yandex.qatools.allure.data.io.TestSuiteReader Maven / Gradle / Ivy

There is a newer version: 1.5.4
Show newest version
package ru.yandex.qatools.allure.data.io;

import ru.yandex.qatools.allure.commons.AllureFileUtils;
import ru.yandex.qatools.allure.model.TestSuiteResult;

import javax.inject.Inject;
import javax.xml.bind.JAXB;
import java.io.File;
import java.util.Iterator;

/**
 * eroshenkoam
 * 02/02/15
 */
public class TestSuiteReader implements Reader {

    private final Iterator testSuiteResultFiles;

    @Inject
    public TestSuiteReader(@ResultDirectories File... resultDirectories) {
        testSuiteResultFiles = AllureFileUtils.listTestSuiteFiles(resultDirectories).iterator();
    }

    @Override
    public Iterator iterator() {
        return new Iterator() {
            @Override
            public boolean hasNext() {
                return testSuiteResultFiles.hasNext();
            }

            @Override
            public TestSuiteResult next() {
                if (!hasNext()) {
                    return null;
                }
                return JAXB.unmarshal(testSuiteResultFiles.next(), TestSuiteResult.class);
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy