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

com.jayway.jsonassert.JsonAsserter Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
package com.jayway.jsonassert;

import org.hamcrest.Matcher;

public interface JsonAsserter {

    /**
     * Asserts that object specified by path satisfies the condition specified by matcher.
     * If not, an AssertionError is thrown with information about the matcher
     * and failing value. Example:
     * 

* * with(json).assertThat("items[0].name", equalTo("Bobby")) * .assertThat("items[0].age" , equalTo(24L)) * * * @param path the json path specifying the value being compared * @param matcher an expression, built of Matchers, specifying allowed values * @param the static type accepted by the matcher * @return this to allow fluent assertion chains */ JsonAsserter assertThat(String path, Matcher matcher); /** * @param path * @param matcher * @param message * @param * @return */ JsonAsserter assertThat(String path, Matcher matcher, String message); /** * Asserts that object specified by path is equal to the expected value. * If they are not, an AssertionError is thrown with the given message. * * @param path the json path specifying the value being compared * @param expected the expected value * @param the static type that should be returned by the path * @return this to allow fluent assertion chains */ JsonAsserter assertEquals(String path, T expected); JsonAsserter assertEquals(String path, T expected, String message); /** * Checks that a path is not defined within a document. If the document contains the * given path, an AssertionError is thrown * * @param path the path to make sure not exists * @return this */ JsonAsserter assertNotDefined(String path); JsonAsserter assertNotDefined(String path, String message); /** * Asserts that object specified by path is null. If it is not, an AssertionError * is thrown with the given message. * * @param path the json path specifying the value that should be null * @return this to allow fluent assertion chains */ JsonAsserter assertNull(String path); JsonAsserter assertNull(String path, String message); /** * Asserts that object specified by path is NOT null. If it is, an AssertionError * is thrown with the given message. * * @param path the json path specifying the value that should be NOT null * @return this to allow fluent assertion chains */ JsonAsserter assertNotNull(String path); JsonAsserter assertNotNull(String path, String message); /** * Syntactic sugar to allow chaining assertions with a separating and() statement *

*

* * with(json).assertThat("firstName", is(equalTo("Bobby"))).and().assertThat("lastName", is(equalTo("Ewing"))) * * * @return this to allow fluent assertion chains */ JsonAsserter and(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy