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

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

Go to download

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

The newest version!
package com.smartbear.readyapi.client.assertions;

import com.smartbear.readyapi.client.model.JsonPathCountAssertion;

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

public class JsonPathCountAssertionBuilder extends AbstractAssertionBuilder implements JsonPathAssertionBuilder {
    private JsonPathCountAssertion jsonPathCountAssertion = new JsonPathCountAssertion();

    JsonPathCountAssertionBuilder(String jsonPath, int expectedCount) {
        jsonPathCountAssertion.setJsonPath(jsonPath);
        jsonPathCountAssertion.setExpectedCount(expectedCount);
    }

    @Override
    public JsonPathCountAssertionBuilder named(String name) {
        jsonPathCountAssertion.setName(name);
        return this;
    }

    @Override
    public JsonPathCountAssertionBuilder allowWildcards() {
        jsonPathCountAssertion.setAllowWildcards(true);
        return this;
    }

    @Override
    public JsonPathCountAssertion build() {
        validateNotEmpty(jsonPathCountAssertion.getJsonPath(), "Missing JSON path, it's a mandatory parameter for JsonPathCountAssertion");
        validateNotEmpty(jsonPathCountAssertion.getExpectedCount(), "Missing expected count, it's a mandatory parameter for JsonPathCountAssertion");
        jsonPathCountAssertion.setType(Assertions.JSON_PATH_COUNT_TYPE);
        return jsonPathCountAssertion;
    }

    public final static JsonPathCountAssertion create(){
        JsonPathCountAssertion assertion = new JsonPathCountAssertion();
        assertion.setType(Assertions.JSON_PATH_COUNT_TYPE);
        return assertion;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy