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

uk.co.automatictester.lightning.tests.ClientSideTest Maven / Gradle / Ivy

package uk.co.automatictester.lightning.tests;

import org.apache.commons.lang3.NotImplementedException;
import uk.co.automatictester.lightning.data.JMeterTransactions;

import java.util.List;

public abstract class ClientSideTest extends LightningTest {

    protected final String transactionName;
    protected int transactionCount;

    protected ClientSideTest(String name, String type, String description, String transactionName) {
        super(name, type, description);
        this.transactionName = transactionName;
    }

    public JMeterTransactions filterTransactions(JMeterTransactions originalJMeterTransactions) {
        if (getTransactionName() != null) {
            return originalJMeterTransactions.excludeLabelsOtherThan(getTransactionName());
        } else {
            return originalJMeterTransactions;
        }
    }

    public int getTransactionCount() {
        return transactionCount;
    }

    public String getTransactionName() {
        return transactionName;
    }

    public String getTestExecutionReport() {
        String executionReport = String.format("Test name:            %s%n" +
                        "Test type:            %s%n" +
                        "%s" +
                        "%s" +
                        "Expected result:      %s%n" +
                        "Actual result:        %s%n" +
                        "Transaction count:    %s%n" +
                        "Test result:          %s%n",
                getName(),
                getType(),
                getDescriptionForReport(),
                getTransactionNameForReport(),
                getExpectedResultDescription(),
                getActualResultDescription(),
                getTransactionCount(),
                getResultForReport());

        return executionReport;
    }

    public void printTestExecutionReport() {
        System.out.println(getTestExecutionReport());
    }

    protected String getTransactionNameForReport() {
        return (getTransactionName() != null) ? (String.format("Transaction name:     %s%n", getTransactionName())) : "";
    }

    public List getLongestTransactions() {
        throw new NotImplementedException("Method not implemented for LightningTest which is not RespTimeBasedTest");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy