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

com.testfabrik.webmate.javasdk.testmgmt.TestExecutionSpecBuilder Maven / Gradle / Ivy

There is a newer version: 0.56
Show newest version
package com.testfabrik.webmate.javasdk.testmgmt;

import com.testfabrik.webmate.javasdk.Tag;
import com.testfabrik.webmate.javasdk.WebmateAPISession;
import com.testfabrik.webmate.javasdk.testmgmt.spec.TestExecutionSpec;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

public abstract class TestExecutionSpecBuilder> {

    protected List tags;
    protected List models;
    protected List testSessionIds;
    protected Optional optSession = Optional.empty();

    protected TestExecutionSpecBuilder() {
        this.tags = new ArrayList<>();
        this.models = new ArrayList<>();
        this.testSessionIds = new ArrayList<>();
    }

    /**
     * Add a Tag corresponding to the current date, e.g. "2020-11-10".
     */
    public TestExecutionSpecBuilder withCurrentDateAsTag() {
        DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd");
        this.tags.add(new Tag(DateTime.now().toString(dtf)));
        return this;
    }

    public TestExecutionSpecBuilder withTag(Tag tag) {
        this.tags.add(tag);
        return this;
    }

    /**
     * Add a Tag corresponding to the given string.
     */
    public TestExecutionSpecBuilder withTag(String tagName) {
        this.tags.add(new Tag(tagName));
        return this;
    }

    public TestExecutionSpecBuilder withTag(String tagName, String value) {
        this.tags.add(new Tag(tagName, value));
        return this;
    }

   public TestExecutionSpecBuilder withModel(ApplicationModelId model) {
        this.models.add(model);
        return this;
    }

    public TestExecutionSpecBuilder withModel(String modelId) {
        this.models.add(new ApplicationModelId(modelId));
        return this;
    }

    public TestExecutionSpecBuilder inTestSession(TestSessionId sessionId) {
        this.testSessionIds.add(sessionId);
        return this;
    }

    public TestExecutionSpecBuilder setApiSession(WebmateAPISession session) {
       this.optSession = Optional.ofNullable(session);
       return this;
    }

    public abstract TestExecutionSpec build();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy