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

com.smartbear.readyapi.client.assertions.ValidHttpStatusCodesAssertionBuilder Maven / Gradle / Ivy

Go to download

Java client library for creating and executing test recipes against Ready!API TestServer

There is a newer version: 1.2.1
Show newest version
package com.smartbear.readyapi.client.assertions;

import com.smartbear.readyapi.client.model.Assertion;
import com.smartbear.readyapi.client.model.ValidHttpStatusCodesAssertion;

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

import static com.smartbear.readyapi.client.Validator.validateNotEmpty;

public class ValidHttpStatusCodesAssertionBuilder extends AbstractAssertionBuilder implements HttpStatusCodeAssertionBuilder {
    protected List statusCodes = new ArrayList<>();

    @Override
    public ValidHttpStatusCodesAssertionBuilder addStatusCode(int statusCode) {
        statusCodes.add(statusCode);
        return this;
    }

    @Override
    public ValidHttpStatusCodesAssertionBuilder addStatusCodes(List statusCodes) {
        this.statusCodes.addAll(statusCodes);
        return this;
    }

    @Override
    public T build() {
        validateNotEmpty(statusCodes, "Missing status codes. Status codes are mandatory for ValidHttpStatusCodesAssertion");
        ValidHttpStatusCodesAssertion statusCodesAssertion = new ValidHttpStatusCodesAssertion();
        statusCodesAssertion.setType(Assertions.VALID_HTTP_STATUS_CODES_TYPE);
        statusCodesAssertion.setValidStatusCodes(statusCodes);
        return (T) statusCodesAssertion;
    }

    public static  T create(){
        ValidHttpStatusCodesAssertion assertion = new ValidHttpStatusCodesAssertion();
        assertion.setType(Assertions.VALID_HTTP_STATUS_CODES_TYPE);
        return (T) assertion;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy