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

com.github.matheusesoft.alm.api.model.Run Maven / Gradle / Ivy

The newest version!
package com.github.matheusesoft.alm.api.model;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "Entity")
@XmlAccessorType(XmlAccessType.FIELD)
public class Run
{
    public static final String STATUS_BLOCKED = "Blocked";
    public static final String STATUS_FAILED = "Failed";
    public static final String STATUS_NA = "N/A";
    public static final String STATUS_NO_RUN = "No Run";
    public static final String STATUS_NOT_COMPLETED = "Not Completed";
    public static final String STATUS_PASSED = "Passed";
    public static final String TEST_TYPE_LEANFT = "custom.run.LEANFT-TEST";
    public static final String TEST_TYPE_MANUAL = "hp.qc.run.MANUAL";
    @XmlElement(name = "Field", required = true)
    @XmlElementWrapper(name = "Fields")
    private List fields;

    @XmlAttribute(name = "Type", required = true)
    private String type;
    
    public Run(Entity entity)
    {
    	this.fields = entity.fields();
        this.type = entity.type();
    }

    public Run()
    {
        type("run");
    }

    public String testInstanceId()
    {
        return fieldValue("testcycl-id");
    }

    public void testInstanceId(String value)
    {
        fieldValue("testcycl-id", value);
    }

    public String testSetId()
    {
        return fieldValue("cycle-id");
    }

    public void testSetId(String value)
    {
        fieldValue("cycle-id", value);
    }

    public String testId()
    {
        return fieldValue("test-id");
    }

    public void testId(String value)
    {
        fieldValue("test-id", value);
    }
    
    public String userTemplate01()
    {
        return fieldValue("user-template-01");
    }

    public void userTemplate01(String value)
    {
        fieldValue("user-template-01", value);
    }

    public String testConfigId()
    {
        return fieldValue("test-config-id");
    }

    public void testConfigId(String value)
    {
        fieldValue("test-config-id", value);
    }

    public String status()
    {
        return fieldValue("status");
    }

    public void status(String value)
    {
        fieldValue("status", value);
    }

    public String owner()
    {
        return fieldValue("owner");
    }

    public void owner(String value)
    {
        fieldValue("owner", value);
    }

    public String testType()
    {
        return fieldValue("subtype-id");
    }

    public void testType(String value)
    {
        fieldValue("subtype-id", value);
    }

    public String host()
    {
        return fieldValue("host");
    }

    public void host(String value)
    {
        fieldValue("host", value);
    }

    public String comments()
    {
        return fieldValue("comments");
    }

    public void comments(String value)
    {
        fieldValue("comments", value);
    }

    public String duration()
    {
        return fieldValue("duration");
    }
    
    public List fields()
    {
        if (fields == null)
        {
            fields = new ArrayList();
        }

        return fields;
    }

    public String type()
    {
        return type;
    }

    public void type(String value)
    {
        type = value;
    }

    public Field field(String name)
    {
        for (Field field: fields())
        {
            if (name.equals(field.name()))
            {
                return field;
            }
        }

        return null;
    }

    public void removeField(String name)
    {
        Iterator it = fields().iterator();

        while (it.hasNext())
        {
            Field field = it.next();

            if (name.equals(field.name()))
            {
                it.remove();
            }
        }
    }

    public void clearBeforeUpdate()
    {
        removeField("id");
        removeField("test-description");
        removeField("comments");
    }

    public String fieldValue(String name)
    {
        Field field = field(name);

        return field != null ? field.value() : null;
    }

    public void fieldValue(String name, String value)
    {
        Field field = field(name);

        if (field == null)
        {
            field = new Field(name);
            fields().add(field);
        }

        field.value(value);
    }

    public String id()
    {
        return fieldValue("id");
    }

    public void id(String value)
    {
        fieldValue("id", value);
    }

    public String parentId()
    {
        return fieldValue("parent-id");
    }

    public void parentId(String value){
        fieldValue("parent-id", value);
    }

    public String name(){
        return fieldValue("name");
    }

    public void name(String value){
        fieldValue("name", value);
    }

    public void duration(String value)
    {
        fieldValue("duration", value);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy