com.smartbear.readyapi.client.assertions.ValidHttpStatusCodesAssertionBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ready-api-testserver-client Show documentation
Show all versions of ready-api-testserver-client Show documentation
Java client library for creating and executing test recipes against Ready!API TestServer
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