You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.6 KiB
81 lines
2.6 KiB
package com.jayway.jsonpath.matchers; |
|
|
|
import org.junit.jupiter.api.Disabled; |
|
import org.junit.jupiter.api.Test; |
|
|
|
import java.io.File; |
|
|
|
import static com.jayway.jsonpath.matchers.JsonPathMatchers.*; |
|
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resource; |
|
import static com.jayway.jsonpath.matchers.helpers.ResourceHelpers.resourceAsFile; |
|
import static org.hamcrest.MatcherAssert.assertThat; |
|
import static org.hamcrest.Matchers.equalTo; |
|
|
|
@Disabled |
|
public class DemoTest { |
|
@Test |
|
public void shouldFailOnJsonString() { |
|
String json = resource("books.json"); |
|
assertThat(json, isJson(withJsonPath("$.store.name", equalTo("The Shop")))); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnJsonFile() { |
|
File json = resourceAsFile("books.json"); |
|
assertThat(json, isJson(withJsonPath("$.store.name", equalTo("The Shop")))); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnInvalidJsonString() { |
|
String json = resource("invalid.json"); |
|
assertThat(json, isJson(withJsonPath("$.store.name", equalTo("The Shop")))); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnInvalidJsonFile() { |
|
File json = resourceAsFile("invalid.json"); |
|
assertThat(json, isJson(withJsonPath("$.store.name", equalTo("The Shop")))); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnTypedJsonString() { |
|
String json = resource("books.json"); |
|
assertThat(json, isJsonString(withJsonPath("$.store.name", equalTo("The Shop")))); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnTypedJsonFile() { |
|
File json = resourceAsFile("books.json"); |
|
assertThat(json, isJsonFile(withJsonPath("$.store.name", equalTo("The Shop")))); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnTypedInvalidJsonString() { |
|
String json = resource("invalid.json"); |
|
assertThat(json, isJsonString(withJsonPath("$.store.name", equalTo("The Shop")))); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnTypedInvalidJsonFile() { |
|
File json = resourceAsFile("invalid.json"); |
|
assertThat(json, isJsonFile(withJsonPath("$.store.name", equalTo("The Shop")))); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnNonExistingJsonPath() { |
|
String json = resource("books.json"); |
|
assertThat(json, hasJsonPath("$.not-here")); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnExistingJsonPath() { |
|
String json = resource("books.json"); |
|
assertThat(json, hasNoJsonPath("$.store.name")); |
|
} |
|
|
|
@Test |
|
public void shouldFailOnExistingJsonPathAlternative() { |
|
String json = resource("books.json"); |
|
assertThat(json, isJson(withoutJsonPath("$.store.name"))); |
|
} |
|
}
|
|
|