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

website.automate.shell.factories.JobFactory Maven / Gradle / Ivy

package website.automate.shell.factories;

import static java.util.Arrays.asList;
import static java.util.Collections.singleton;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
import website.automate.manager.api.client.model.Job;
import website.automate.manager.api.client.model.Job.TakeScreenshots;

@Service
public class JobFactory {

    public List createInstances(Collection scenarioIds, boolean parallel) {
        if (parallel) {
            return asList(createInstance(scenarioIds));
        }
        return scenarioIds.stream().map(scenarioId -> createInstance(scenarioId))
                .collect(Collectors.toList());
    }

    private Job createInstance(String scenarioId) {
        Job job = new Job();
        job.setScenarioIds(singleton(scenarioId));
        job.setTakeScreenshots(TakeScreenshots.ON_FAILURE);
        return job;
    }

    private Job createInstance(Collection scenarioIds) {
        Job job = new Job();
        job.setScenarioIds(new HashSet<>(scenarioIds));
        return job;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy