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

io.cloudslang.lang.tools.build.tester.parse.SlangTestCase Maven / Gradle / Ivy

There is a newer version: 2.0.94
Show newest version
/*******************************************************************************
 * (c) Copyright 2016 Hewlett-Packard Development Company, L.P.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License v2.0 which accompany this distribution.
 *
 * The Apache License is available at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 *******************************************************************************/
package io.cloudslang.lang.tools.build.tester.parse;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.cloudslang.lang.tools.build.SlangBuildMain;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import static com.google.common.collect.Lists.newArrayList;
import static org.apache.commons.collections4.CollectionUtils.isEmpty;

/**
 * Created by stoneo on 3/15/2015.
 **/
public class SlangTestCase implements Serializable {
    private static final String UNKNOWN_FILE_PATH = "";

    private String name;

    private String testFlowPath;

    private String description;

    private List testSuites;

    private String systemPropertiesFile;

    @JsonIgnore
    private List inputs;

    private List outputs;

    private Boolean throwsException;

    private String result;

    @JsonIgnore
    private String filePath;

    //for jackson
    private SlangTestCase() {
    }

    public SlangTestCase(String name, String testFlowPath, String description, List testSuites,
                         String systemPropertiesFile, List inputs, List outputs,
                         Boolean throwsException, String result) {
        this.name = name;
        this.testFlowPath = testFlowPath;
        this.description = description;
        this.systemPropertiesFile = systemPropertiesFile;
        this.testSuites = testSuites;
        this.inputs = inputs;
        this.outputs = outputs;
        this.throwsException = throwsException;
        this.result = result;
        this.filePath = null;
    }

    public SlangTestCase(String name, String testFlowPath, String description, List testSuites,
                         String systemPropertiesFile, List inputs, List outputs,
                         Boolean throwsException, String result, String filePath) {
        this.name = name;
        this.testFlowPath = testFlowPath;
        this.description = description;
        this.systemPropertiesFile = systemPropertiesFile;
        this.testSuites = testSuites;
        this.inputs = inputs;
        this.outputs = outputs;
        this.throwsException = throwsException;
        this.result = result;
        this.filePath = filePath;
    }

    public static String generateTestCaseReference(SlangTestCase slangTestCase) {
        return slangTestCase.getName() + " [" + (StringUtils.isEmpty(slangTestCase.getFilePath()) ?
                UNKNOWN_FILE_PATH : slangTestCase.getFilePath()) + "]";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTestFlowPath() {
        return testFlowPath;
    }

    public String getDescription() {
        return description;
    }

    public List getTestSuites() {
        List localTestSuites = this.testSuites;
        return isEmpty(localTestSuites) ? newArrayList(SlangBuildMain.DEFAULT_TESTS) : newArrayList(localTestSuites);
    }


    public String getSystemPropertiesFile() {
        return systemPropertiesFile;
    }

    public void setInputs(List inputs) {
        this.inputs = inputs;
    }

    public List getInputs() {
        return inputs;
    }

    public List getOutputs() {
        return outputs;
    }

    public Boolean getThrowsException() {
        return throwsException;
    }

    public void setThrowsException(boolean throwsException) {
        this.throwsException = throwsException;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    @Override
    public boolean equals(Object o) {
        return EqualsBuilder.reflectionEquals(this, o);
    }


    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy