Merge pull request #5815 from izeye/polish-20160428

* pr/5815:
  Polish
This commit is contained in:
Stephane Nicoll 2016-04-30 10:24:48 +02:00
commit cfbe28fc8f
21 changed files with 148 additions and 150 deletions

View File

@ -27,7 +27,7 @@ import java.util.regex.Pattern;
* must provide implementations of {@link #getValue(Object, String)} and * must provide implementations of {@link #getValue(Object, String)} and
* {@link #getNames(Object, NameCallback)}. * {@link #getNames(Object, NameCallback)}.
* *
* @param <T> The source data type * @param <T> the source data type
* @author Phillip Webb * @author Phillip Webb
* @author Sergei Egorov * @author Sergei Egorov
* @author Andy Wilkinson * @author Andy Wilkinson

View File

@ -19,7 +19,7 @@ package org.springframework.boot.actuate.metrics.buffer;
/** /**
* Base class for a mutable buffer containing a timestamp and a value. * Base class for a mutable buffer containing a timestamp and a value.
* *
* @param <T> The value type * @param <T> the value type
* @author Dave Syer * @author Dave Syer
* @author Phillip Webb * @author Phillip Webb
*/ */

View File

@ -22,7 +22,7 @@ import org.springframework.cache.CacheManager;
* Callback interface that can be implemented by beans wishing to customize the cache * Callback interface that can be implemented by beans wishing to customize the cache
* manager before it is fully initialized, in particular to tune its configuration. * manager before it is fully initialized, in particular to tune its configuration.
* *
* @param <T> The type of the {@link CacheManager} * @param <T> the type of the {@link CacheManager}
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 1.3.3 * @since 1.3.3
*/ */

View File

@ -21,7 +21,7 @@ import javax.sql.DataSource;
/** /**
* A base {@link DataSourcePoolMetadata} implementation. * A base {@link DataSourcePoolMetadata} implementation.
* *
* @param <T> The datasource type * @param <T> the data source type
* @author Stephane Nicoll * @author Stephane Nicoll
* @since 1.2.0 * @since 1.2.0
*/ */

View File

@ -53,7 +53,7 @@ import org.springframework.util.ReflectionUtils.FieldCallback;
* public void testWriteJson() { * public void testWriteJson() {
* ExampleObject object = //... * ExampleObject object = //...
* assertThat(json.write(object)).isEqualToJson("expected.json"); * assertThat(json.write(object)).isEqualToJson("expected.json");
* assertThat(json.read("expected.json)).isEqualTo(object); * assertThat(json.read("expected.json")).isEqualTo(object);
* } * }
* *
* } * }
@ -62,7 +62,7 @@ import org.springframework.util.ReflectionUtils.FieldCallback;
* <p> * <p>
* To use this library JSONAssert must be on the test classpath. * To use this library JSONAssert must be on the test classpath.
* *
* @param <T> The type under test * @param <T> the type under test
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 1.4.0
* @see JsonContentAssert * @see JsonContentAssert
@ -271,8 +271,8 @@ public abstract class AbstractJsonMarshalTester<T> {
/** /**
* Write the specified object to a JSON string. * Write the specified object to a JSON string.
* @param value the source value ({@code never null}) * @param value the source value (never {@code null})
* @param type the resulting type ({@code never null}) * @param type the resulting type (never {@code null})
* @return the JSON string * @return the JSON string
* @throws IOException on write error * @throws IOException on write error
*/ */
@ -281,9 +281,9 @@ public abstract class AbstractJsonMarshalTester<T> {
/** /**
* Read from the specified input stream to create an object of the specified type. The * Read from the specified input stream to create an object of the specified type. The
* default implementation delegates to {@link #readObject(Reader, ResolvableType)} * default implementation delegates to {@link #readObject(Reader, ResolvableType)}.
* @param inputStream the source input stream ({@code never null}) * @param inputStream the source input stream (never {@code null})
* @param type the resulting type ({@code never null}) * @param type the resulting type (never {@code null})
* @return the resulting object * @return the resulting object
* @throws IOException on read error * @throws IOException on read error
*/ */
@ -295,8 +295,8 @@ public abstract class AbstractJsonMarshalTester<T> {
/** /**
* Read from the specified reader to create an object of the specified type. * Read from the specified reader to create an object of the specified type.
* @param reader the source reader ({@code never null}) * @param reader the source reader (never {@code null})
* @param type the resulting type ({@code never null}) * @param type the resulting type (never {@code null})
* @return the resulting object * @return the resulting object
* @throws IOException on read error * @throws IOException on read error
*/ */
@ -304,7 +304,7 @@ public abstract class AbstractJsonMarshalTester<T> {
throws IOException; throws IOException;
/** /**
* Utility class used to support field initialization. Uses by subclasses to support * Utility class used to support field initialization. Used by subclasses to support
* {@code initFields}. * {@code initFields}.
* @param <M> The marshaller type * @param <M> The marshaller type
*/ */

View File

@ -24,13 +24,13 @@ import org.springframework.util.Assert;
/** /**
* AssertJ based JSON tester that works with basic JSON strings. Allows testing of JSON * AssertJ based JSON tester that works with basic JSON strings. Allows testing of JSON
* payloads created from some any source, for example:<pre class="code"> * payloads created from any source, for example:<pre class="code">
* public class ExampleObjectJsonTests { * public class ExampleObjectJsonTests {
* *
* private BasicJsonTester = new BasicJsonTester(getClass()); * private BasicJsonTester json = new BasicJsonTester(getClass());
* *
* &#064;Test * &#064;Test
* public void testWriteJson() { * public void testWriteJson() throws IOException {
* assertThat(json.from("example.json")).extractingJsonPathStringValue("@.name") * assertThat(json.from("example.json")).extractingJsonPathStringValue("@.name")
.isEqualTo("Spring"); .isEqualTo("Spring");
* } * }
@ -70,7 +70,7 @@ public class BasicJsonTester {
/** /**
* Create JSON content from the specified resource path. * Create JSON content from the specified resource path.
* @param path the path of the resource to load * @param path the path of the resource to load
* @param resourceLoadClass the classloader used load the resource * @param resourceLoadClass the source class used to load the resource
* @return the JSON content * @return the JSON content
*/ */
public JsonContent<Object> from(String path, Class<?> resourceLoadClass) { public JsonContent<Object> from(String path, Class<?> resourceLoadClass) {

View File

@ -39,7 +39,7 @@ import org.springframework.util.Assert;
* } * }
* *
* &#064;Test * &#064;Test
* public void testWriteJson() { * public void testWriteJson() throws IOException {
* ExampleObject object = //... * ExampleObject object = //...
* assertThat(json.write(object)).isEqualToJson("expected.json"); * assertThat(json.write(object)).isEqualToJson("expected.json");
* } * }
@ -49,7 +49,7 @@ import org.springframework.util.Assert;
* *
* See {@link AbstractJsonMarshalTester} for more details. * See {@link AbstractJsonMarshalTester} for more details.
* *
* @param <T> The type under test * @param <T> the type under test
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 1.4.0
*/ */
@ -81,7 +81,7 @@ public class GsonTester<T> extends AbstractJsonMarshalTester<T> {
} }
/** /**
* Utility method to initialize {@link JacksonTester} fields. See {@link JacksonTester * Utility method to initialize {@link GsonTester} fields. See {@link GsonTester
* class-level documentation} for example usage. * class-level documentation} for example usage.
* @param testInstance the test instance * @param testInstance the test instance
* @param gson the Gson instance * @param gson the Gson instance
@ -91,7 +91,7 @@ public class GsonTester<T> extends AbstractJsonMarshalTester<T> {
} }
/** /**
* Utility method to initialize {@link JacksonTester} fields. See {@link JacksonTester * Utility method to initialize {@link GsonTester} fields. See {@link GsonTester
* class-level documentation} for example usage. * class-level documentation} for example usage.
* @param testInstance the test instance * @param testInstance the test instance
* @param gson an object factory to create the Gson instance * @param gson an object factory to create the Gson instance
@ -101,7 +101,7 @@ public class GsonTester<T> extends AbstractJsonMarshalTester<T> {
} }
/** /**
* {@link JsonTesterFieldInitializer} for Gson. * {@link FieldInitializer} for Gson.
*/ */
private static class GsonFieldInitializer extends FieldInitializer<Gson> { private static class GsonFieldInitializer extends FieldInitializer<Gson> {

View File

@ -41,7 +41,7 @@ import org.springframework.util.Assert;
* } * }
* *
* &#064;Test * &#064;Test
* public void testWriteJson() { * public void testWriteJson() throws IOException {
* ExampleObject object = //... * ExampleObject object = //...
* assertThat(json.write(object)).isEqualToJson("expected.json"); * assertThat(json.write(object)).isEqualToJson("expected.json");
* } * }
@ -51,7 +51,7 @@ import org.springframework.util.Assert;
* *
* See {@link AbstractJsonMarshalTester} for more details. * See {@link AbstractJsonMarshalTester} for more details.
* *
* @param <T> The type under test * @param <T> the type under test
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 1.4.0
*/ */
@ -116,7 +116,7 @@ public class JacksonTester<T> extends AbstractJsonMarshalTester<T> {
} }
/** /**
* {@link JsonTesterFieldInitializer} for Jackson. * {@link FieldInitializer} for Jackson.
*/ */
private static class JacksonFieldInitializer extends FieldInitializer<ObjectMapper> { private static class JacksonFieldInitializer extends FieldInitializer<ObjectMapper> {

View File

@ -26,7 +26,7 @@ import org.springframework.util.Assert;
* {@link AssertProvider provide} {@link JsonContentAssert} to AssertJ {@code assertThat} * {@link AssertProvider provide} {@link JsonContentAssert} to AssertJ {@code assertThat}
* calls. * calls.
* *
* @param <T> The source type that created the content * @param <T> the source type that created the content
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 1.4.0
*/ */

View File

@ -843,7 +843,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
/** /**
* Verify that the actual value at the given JSON path produces no result. If the JSON * Verify that the actual value at the given JSON path produces no result. If the JSON
* path expression is not {@linkplain JsonPath#isDefinite() definite}, this method * path expression is not {@linkplain JsonPath#isDefinite() definite}, this method
* verifies that the value at the given path is not <em>empty</em>. * verifies that the value at the given path is <em>empty</em>.
* @param expression the {@link JsonPath} expression * @param expression the {@link JsonPath} expression
* @param args arguments to parameterize the {@code JsonPath} expression with, using * @param args arguments to parameterize the {@code JsonPath} expression with, using
* formatting specifiers defined in {@link String#format(String, Object...)} * formatting specifiers defined in {@link String#format(String, Object...)}
@ -990,7 +990,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
JSONCompareResult result = new JSONCompareResult(); JSONCompareResult result = new JSONCompareResult();
result.passed(); result.passed();
if (expectedJson != null) { if (expectedJson != null) {
result.fail("Expected non-null JSON"); result.fail("Expected null JSON");
} }
return result; return result;
} }
@ -1079,7 +1079,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
if (!required) { if (!required) {
return null; return null;
} }
throw new AssertionError(getNoValueMessage() + ex.getMessage()); throw new AssertionError(getNoValueMessage() + ". " + ex.getMessage());
} }
} }

View File

@ -26,7 +26,7 @@ import org.springframework.util.Assert;
* only to {@link AssertProvider provide} {@link ObjectContentAssert} to AssertJ * only to {@link AssertProvider provide} {@link ObjectContentAssert} to AssertJ
* {@code assertThat} calls. * {@code assertThat} calls.
* *
* @param <T> The content type * @param <T> the content type
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 1.4.0
*/ */

View File

@ -26,7 +26,7 @@ import org.assertj.core.api.Assertions;
import org.assertj.core.internal.Objects; import org.assertj.core.internal.Objects;
/** /**
* AssertJ {@link Assert} for {@link JsonContent}. * AssertJ {@link Assert} for {@link ObjectContent}.
* *
* @param <A> The actual type * @param <A> The actual type
* @author Phillip Webb * @author Phillip Webb
@ -42,7 +42,7 @@ public class ObjectContentAssert<A>
/** /**
* Verifies that the actual value is an array, and returns an array assertion, to * Verifies that the actual value is an array, and returns an array assertion, to
* allow chaining of array-specific assertions from this call. * allow chaining of array-specific assertions from this call.
* @return a list assertion object * @return an array assertion object
*/ */
public AbstractObjectArrayAssert<?, Object> asArray() { public AbstractObjectArrayAssert<?, Object> asArray() {
Objects.instance().assertIsInstanceOf(this.info, this.actual, Object[].class); Objects.instance().assertIsInstanceOf(this.info, this.actual, Object[].class);
@ -51,8 +51,8 @@ public class ObjectContentAssert<A>
/** /**
* Verifies that the actual value is a map, and returns a map assertion, to allow * Verifies that the actual value is a map, and returns a map assertion, to allow
* chaining of list-specific assertions from this call. * chaining of map-specific assertions from this call.
* @return a list assertion object * @return a map assertion object
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public AbstractMapAssert<?, ?, Object, Object> asMap() { public AbstractMapAssert<?, ?, Object, Object> asMap() {

View File

@ -192,7 +192,7 @@ public abstract class AbstractJsonMarshalTesterTests {
Class<?> resourceLoadClass, ResolvableType type); Class<?> resourceLoadClass, ResolvableType type);
/** /**
* Access to field backed {@link ResolvableType}. * Access to field backed by {@link ResolvableType}.
*/ */
public static class ResolvableTypes { public static class ResolvableTypes {

View File

@ -41,7 +41,7 @@ public class GsonTesterTests extends AbstractJsonMarshalTesterTests {
} }
@Test @Test
public void initFieldsWhenObjectMapperIsNullShouldThrowException() { public void initFieldsWhenMarshallerIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Marshaller must not be null"); this.thrown.expectMessage("Marshaller must not be null");
GsonTester.initFields(new InitFieldsTestClass(), (Gson) null); GsonTester.initFields(new InitFieldsTestClass(), (Gson) null);

View File

@ -40,7 +40,7 @@ public class JacksonTesterTests extends AbstractJsonMarshalTesterTests {
} }
@Test @Test
public void initFieldsWhenObjectMapperIsNullShouldThrowException() { public void initFieldsWhenMarshallerIsNullShouldThrowException() {
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("Marshaller must not be null"); this.thrown.expectMessage("Marshaller must not be null");
JacksonTester.initFields(new InitFieldsTestClass(), (ObjectMapper) null); JacksonTester.initFields(new InitFieldsTestClass(), (ObjectMapper) null);

View File

@ -385,102 +385,102 @@ public class JsonContentAssertTests {
public void isEqualToJsonWhenStringIsMatchingAndComparatorShouldPass() public void isEqualToJsonWhenStringIsMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME, assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME,
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail() public void isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT, assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT,
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldPass() public void isEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json",
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail() public void isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", assertThat(forJson(SOURCE)).isEqualToJson("different.json",
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isEqualToJsonWhenResourcePathAndClassIsMatchingAndComparatorShouldPass() public void isEqualToJsonWhenResourcePathAndClassAreMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", getClass(), assertThat(forJson(SOURCE)).isEqualToJson("lenient-same.json", getClass(),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourcePathAndClassIsNotMatchingAndComparatorShouldFail() public void isEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(), assertThat(forJson(SOURCE)).isEqualToJson("different.json", getClass(),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isEqualToJsonWhenBytesAreMatchingAndComparatorShouldPass() public void isEqualToJsonWhenBytesAreMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME.getBytes(), assertThat(forJson(SOURCE)).isEqualToJson(LENIENT_SAME.getBytes(),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail() public void isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(), assertThat(forJson(SOURCE)).isEqualToJson(DIFFERENT.getBytes(),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isEqualToJsonWhenFileIsMatchingAndComparatorShouldPass() public void isEqualToJsonWhenFileIsMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createFile(LENIENT_SAME), assertThat(forJson(SOURCE)).isEqualToJson(createFile(LENIENT_SAME),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail() public void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isEqualToJsonWhenInputStreamIsMatchingAndComparatorShouldPass() public void isEqualToJsonWhenInputStreamIsMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(LENIENT_SAME), assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(LENIENT_SAME),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isEqualToJsonWhenInputStreamIsNotMatchingAndComparatorShouldFail() public void isEqualToJsonWhenInputStreamIsNotMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT), assertThat(forJson(SOURCE)).isEqualToJson(createInputStream(DIFFERENT),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isEqualToJsonWhenResourceIsMatchingAndComparatorShouldPass() public void isEqualToJsonWhenResourceIsMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createResource(LENIENT_SAME), assertThat(forJson(SOURCE)).isEqualToJson(createResource(LENIENT_SAME),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldFail() public void isEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT), assertThat(forJson(SOURCE)).isEqualToJson(createResource(DIFFERENT),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToWhenStringIsMatchingShouldPass() throws Exception { public void isNotEqualToWhenStringIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME); assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME);
} }
@ -490,62 +490,62 @@ public class JsonContentAssertTests {
} }
@Test @Test
public void isNotEqualToWhenStringIsNotMatchingShouldFail() throws Exception { public void isNotEqualToWhenStringIsNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(DIFFERENT); assertThat(forJson(SOURCE)).isNotEqualTo(DIFFERENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToWhenResourcePathIsMatchingShouldPass() throws Exception { public void isNotEqualToWhenResourcePathIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json"); assertThat(forJson(SOURCE)).isNotEqualTo("lenient-same.json");
} }
@Test @Test
public void isNotEqualToWhenResourcePathIsNotMatchingShouldFail() throws Exception { public void isNotEqualToWhenResourcePathIsNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo("different.json"); assertThat(forJson(SOURCE)).isNotEqualTo("different.json");
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToWhenBytesAreMatchingShouldPass() throws Exception { public void isNotEqualToWhenBytesAreMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes()); assertThat(forJson(SOURCE)).isNotEqualTo(LENIENT_SAME.getBytes());
} }
@Test @Test
public void isNotEqualToWhenBytesAreNotMatchingShouldFail() throws Exception { public void isNotEqualToWhenBytesAreNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(DIFFERENT.getBytes()); assertThat(forJson(SOURCE)).isNotEqualTo(DIFFERENT.getBytes());
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToWhenFileIsMatchingShouldPass() throws Exception { public void isNotEqualToWhenFileIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME)); assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME));
} }
@Test @Test
public void isNotEqualToWhenFileIsNotMatchingShouldFail() throws Exception { public void isNotEqualToWhenFileIsNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(createFile(DIFFERENT)); assertThat(forJson(SOURCE)).isNotEqualTo(createFile(DIFFERENT));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToWhenInputStreamIsMatchingShouldPass() throws Exception { public void isNotEqualToWhenInputStreamIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(LENIENT_SAME)); assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(LENIENT_SAME));
} }
@Test @Test
public void isNotEqualToWhenInputStreamIsNotMatchingShouldFail() throws Exception { public void isNotEqualToWhenInputStreamIsNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(DIFFERENT)); assertThat(forJson(SOURCE)).isNotEqualTo(createInputStream(DIFFERENT));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToWhenResourceIsMatchingShouldPass() throws Exception { public void isNotEqualToWhenResourceIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(createResource(LENIENT_SAME)); assertThat(forJson(SOURCE)).isNotEqualTo(createResource(LENIENT_SAME));
} }
@Test @Test
public void isNotEqualToWhenResourceIsNotMatchingShouldFail() throws Exception { public void isNotEqualToWhenResourceIsNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualTo(createResource(DIFFERENT)); assertThat(forJson(SOURCE)).isNotEqualTo(createResource(DIFFERENT));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenStringIsMatchingShouldPass() throws Exception { public void isNotEqualToJsonWhenStringIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME); assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME);
} }
@ -555,359 +555,357 @@ public class JsonContentAssertTests {
} }
@Test @Test
public void isNotEqualToJsonWhenStringIsNotMatchingShouldFail() throws Exception { public void isNotEqualToJsonWhenStringIsNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT); assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathIsMatchingShouldPass() throws Exception { public void isNotEqualToJsonWhenResourcePathIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json"); assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json");
} }
@Test @Test
public void isNotEqualToJsonWhenResourcePathIsNotMatchingShouldFail() public void isNotEqualToJsonWhenResourcePathIsNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json"); assertThat(forJson(SOURCE)).isNotEqualToJson("different.json");
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathAndClassIsMatchingShouldPass() public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass()); assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass());
} }
@Test @Test
public void isNotEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass()); assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass());
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenBytesAreMatchingShouldPass() throws Exception { public void isNotEqualToJsonWhenBytesAreMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes()); assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes());
} }
@Test @Test
public void isNotEqualToJsonWhenBytesAreNotMatchingShouldFail() throws Exception { public void isNotEqualToJsonWhenBytesAreNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes()); assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes());
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenFileIsMatchingShouldPass() throws Exception { public void isNotEqualToJsonWhenFileIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME)); assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME));
} }
@Test @Test
public void isNotEqualToJsonWhenFileIsNotMatchingShouldFail() throws Exception { public void isNotEqualToJsonWhenFileIsNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(DIFFERENT)); assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(DIFFERENT));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenInputStreamIsMatchingShouldPass() throws Exception { public void isNotEqualToJsonWhenInputStreamIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME)); assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME));
} }
@Test @Test
public void isNotEqualToJsonWhenInputStreamIsNotMatchingShouldFail() public void isNotEqualToJsonWhenInputStreamIsNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(DIFFERENT)); assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(DIFFERENT));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourceIsMatchingShouldPass() throws Exception { public void isNotEqualToJsonWhenResourceIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME)); assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME));
} }
@Test @Test
public void isNotEqualToJsonWhenResourceIsNotMatchingShouldFail() throws Exception { public void isNotEqualToJsonWhenResourceIsNotMatchingShouldPass() throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(DIFFERENT)); assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(DIFFERENT));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenStringIsMatchingShouldPass() public void isNotStrictlyEqualToJsonWhenStringIsMatchingShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE);
} }
@Test @Test
public void isNotStrictlyEqualToJsonWhenStringIsNotMatchingShouldFail() public void isNotStrictlyEqualToJsonWhenStringIsNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(LENIENT_SAME); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(LENIENT_SAME);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenResourcePathIsMatchingShouldPass() public void isNotStrictlyEqualToJsonWhenResourcePathIsMatchingShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json"); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json");
} }
@Test @Test
public void isNotStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldFail() public void isNotStrictlyEqualToJsonWhenResourcePathIsNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("lenient-same.json"); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("lenient-same.json");
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenResourcePathAndClassIsMatchingShouldPass() public void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreMatchingShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json", getClass()); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("source.json", getClass());
} }
@Test @Test
public void isNotStrictlyEqualToJsonWhenResourcePathAndClassIsNotMatchingShouldFail() public void isNotStrictlyEqualToJsonWhenResourcePathAndClassAreNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("lenient-same.json", assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson("lenient-same.json",
getClass()); getClass());
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenBytesAreMatchingShouldPass() public void isNotStrictlyEqualToJsonWhenBytesAreMatchingShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE.getBytes()); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(SOURCE.getBytes());
} }
@Test @Test
public void isNotStrictlyEqualToJsonWhenBytesAreNotMatchingShouldFail() public void isNotStrictlyEqualToJsonWhenBytesAreNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(LENIENT_SAME.getBytes()); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(LENIENT_SAME.getBytes());
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldPass() throws Exception { public void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldFail() throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE)); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE));
} }
@Test @Test
public void isNotStrictlyEqualToJsonWhenFileIsNotMatchingShouldFail() public void isNotStrictlyEqualToJsonWhenFileIsNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(LENIENT_SAME)); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(LENIENT_SAME));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenInputStreamIsMatchingShouldPass() public void isNotStrictlyEqualToJsonWhenInputStreamIsMatchingShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createInputStream(SOURCE)); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createInputStream(SOURCE));
} }
@Test @Test
public void isNotStrictlyEqualToJsonWhenInputStreamIsNotMatchingShouldFail() public void isNotStrictlyEqualToJsonWhenInputStreamIsNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)) assertThat(forJson(SOURCE))
.isNotStrictlyEqualToJson(createInputStream(LENIENT_SAME)); .isNotStrictlyEqualToJson(createInputStream(LENIENT_SAME));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotStrictlyEqualToJsonWhenResourceIsMatchingShouldPass() public void isNotStrictlyEqualToJsonWhenResourceIsMatchingShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createResource(SOURCE)); assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createResource(SOURCE));
} }
@Test @Test
public void isNotStrictlyEqualToJsonWhenResourceIsNotMatchingShouldFail() public void isNotStrictlyEqualToJsonWhenResourceIsNotMatchingShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)) assertThat(forJson(SOURCE))
.isNotStrictlyEqualToJson(createResource(LENIENT_SAME)); .isNotStrictlyEqualToJson(createResource(LENIENT_SAME));
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenStringIsMatchingAndLenientShouldPass() public void isNotEqualToJsonWhenStringIsMatchingAndLenientShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME,
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test @Test
public void isNotEqualToJsonWhenStringIsNotMatchingAndLenientShouldFail() public void isNotEqualToJsonWhenStringIsNotMatchingAndLenientShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT, JSONCompareMode.LENIENT); assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT, JSONCompareMode.LENIENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathIsMatchingAndLenientShouldPass() public void isNotEqualToJsonWhenResourcePathIsMatchingAndLenientShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json",
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test @Test
public void isNotEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldFail() public void isNotEqualToJsonWhenResourcePathIsNotMatchingAndLenientShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", assertThat(forJson(SOURCE)).isNotEqualToJson("different.json",
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathAndClassIsMatchingAndLenientShouldPass() public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndLenientShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass(), assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass(),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test @Test
public void isNotEqualToJsonWhenResourcePathAndClassIsNotMatchingAndLenientShouldFail() public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingAndLenientShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass(), assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass(),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenBytesAreMatchingAndLenientShouldPass() public void isNotEqualToJsonWhenBytesAreMatchingAndLenientShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(), assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test @Test
public void isNotEqualToJsonWhenBytesAreNotMatchingAndLenientShouldFail() public void isNotEqualToJsonWhenBytesAreNotMatchingAndLenientShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes(), assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes(),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenFileIsMatchingAndLenientShouldPass() public void isNotEqualToJsonWhenFileIsMatchingAndLenientShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test @Test
public void isNotEqualToJsonWhenFileIsNotMatchingAndLenientShouldFail() public void isNotEqualToJsonWhenFileIsNotMatchingAndLenientShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(DIFFERENT), assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(DIFFERENT),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenInputStreamIsMatchingAndLenientShouldPass() public void isNotEqualToJsonWhenInputStreamIsMatchingAndLenientShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME), assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test @Test
public void isNotEqualToJsonWhenInputStreamIsNotMatchingAndLenientShouldFail() public void isNotEqualToJsonWhenInputStreamIsNotMatchingAndLenientShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(DIFFERENT), assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(DIFFERENT),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourceIsMatchingAndLenientShouldPass() public void isNotEqualToJsonWhenResourceIsMatchingAndLenientShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME), assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test @Test
public void isNotEqualToJsonWhenResourceIsNotMatchingAndLenientShouldFail() public void isNotEqualToJsonWhenResourceIsNotMatchingAndLenientShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(DIFFERENT), assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(DIFFERENT),
JSONCompareMode.LENIENT); JSONCompareMode.LENIENT);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldPass() public void isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME, assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME,
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isNotEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail() public void isNotEqualToJsonWhenStringIsNotMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT, assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT,
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldPass() public void isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json",
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isNotEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail() public void isNotEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", assertThat(forJson(SOURCE)).isNotEqualToJson("different.json",
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourcePathIsMatchingAndClassAndComparatorShouldPass() public void isNotEqualToJsonWhenResourcePathAndClassAreMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass(), assertThat(forJson(SOURCE)).isNotEqualToJson("lenient-same.json", getClass(),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isNotEqualToJsonWhenResourcePathAndClassAndComparatorIsNotMatchingShouldFail() public void isNotEqualToJsonWhenResourcePathAndClassAreNotMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass(), assertThat(forJson(SOURCE)).isNotEqualToJson("different.json", getClass(),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldPass() public void isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(), assertThat(forJson(SOURCE)).isNotEqualToJson(LENIENT_SAME.getBytes(),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isNotEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail() public void isNotEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes(), assertThat(forJson(SOURCE)).isNotEqualToJson(DIFFERENT.getBytes(),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldPass() public void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isNotEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail() public void isNotEqualToJsonWhenFileIsNotMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(DIFFERENT), assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(DIFFERENT),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenInputStreamIsMatchingAndComparatorShouldPass() public void isNotEqualToJsonWhenInputStreamIsMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME), assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(LENIENT_SAME),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isNotEqualToJsonWhenInputStreamIsNotMatchingAndComparatorShouldFail() public void isNotEqualToJsonWhenInputStreamIsNotMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(DIFFERENT), assertThat(forJson(SOURCE)).isNotEqualToJson(createInputStream(DIFFERENT),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test(expected = AssertionError.class) @Test(expected = AssertionError.class)
public void isNotEqualToJsonWhenResourceIsMatchingAndComparatorShouldPass() public void isNotEqualToJsonWhenResourceIsMatchingAndComparatorShouldFail()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME), assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(LENIENT_SAME),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void isNotEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldFail() public void isNotEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldPass()
throws Exception { throws Exception {
assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(DIFFERENT), assertThat(forJson(SOURCE)).isNotEqualToJson(createResource(DIFFERENT),
JsonContentAssertTests.COMPARATOR); COMPARATOR);
} }
@Test @Test
public void hasJsonPathValue() throws Exception { public void hasJsonPathValue() throws Exception {
System.out.println(TYPES.replace("'", "\""));
System.out.println(SIMPSONS.replace("'", "\""));
assertThat(forJson(TYPES)).hasJsonPathValue("$.str"); assertThat(forJson(TYPES)).hasJsonPathValue("$.str");
} }
@ -1094,7 +1092,7 @@ public class JsonContentAssertTests {
} }
@Test @Test
public void hasJsonPathStringValueForAnEmptyStringForNonString() throws Exception { public void hasJsonPathStringValueForNonString() throws Exception {
String expression = "$.bool"; String expression = "$.bool";
this.thrown.expect(AssertionError.class); this.thrown.expect(AssertionError.class);
this.thrown.expectMessage( this.thrown.expectMessage(
@ -1150,17 +1148,17 @@ public class JsonContentAssertTests {
} }
@Test @Test
public void assertValueIsMap() throws Exception { public void hasJsonPathMapValue() throws Exception {
assertThat(forJson(TYPES)).hasJsonPathMapValue("$.colorMap"); assertThat(forJson(TYPES)).hasJsonPathMapValue("$.colorMap");
} }
@Test @Test
public void assertValueIsMapForAnEmptyMap() throws Exception { public void hasJsonPathMapValueForAnEmptyMap() throws Exception {
assertThat(forJson(TYPES)).hasJsonPathMapValue("$.emptyMap"); assertThat(forJson(TYPES)).hasJsonPathMapValue("$.emptyMap");
} }
@Test @Test
public void assertValueIsMapForNonMap() throws Exception { public void hasJsonPathMapValueForNonMap() throws Exception {
String expression = "$.str"; String expression = "$.str";
this.thrown.expect(AssertionError.class); this.thrown.expect(AssertionError.class);
this.thrown.expectMessage( this.thrown.expectMessage(
@ -1314,7 +1312,7 @@ public class JsonContentAssertTests {
private static String loadJson(String path) { private static String loadJson(String path) {
try { try {
ClassPathResource resource = new ClassPathResource(path, ClassPathResource resource = new ClassPathResource(path,
JsonContentAssert.class); JsonContentAssertTests.class);
return new String(FileCopyUtils.copyToByteArray(resource.getInputStream())); return new String(FileCopyUtils.copyToByteArray(resource.getInputStream()));
} }
catch (Exception ex) { catch (Exception ex) {

View File

@ -47,7 +47,7 @@ public class JsonContentTests {
} }
@Test @Test
public void createThenJsonIsNullShouldThrowException() throws Exception { public void createWhenJsonIsNullShouldThrowException() throws Exception {
this.thrown.expect(IllegalArgumentException.class); this.thrown.expect(IllegalArgumentException.class);
this.thrown.expectMessage("JSON must not be null"); this.thrown.expectMessage("JSON must not be null");
new JsonContent<ExampleObject>(getClass(), TYPE, null); new JsonContent<ExampleObject>(getClass(), TYPE, null);
@ -84,7 +84,7 @@ public class JsonContentTests {
} }
@Test @Test
public void toStringWhenNoTypeShouldReturnString() throws Exception { public void toStringWhenHasNoTypeShouldReturnString() throws Exception {
JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(), JsonContent<ExampleObject> content = new JsonContent<ExampleObject>(getClass(),
null, JSON); null, JSON);
assertThat(content.toString()).isEqualTo("JsonContent " + JSON); assertThat(content.toString()).isEqualTo("JsonContent " + JSON);

View File

@ -49,7 +49,7 @@ import org.springframework.validation.Validator;
* them to an object of a specified type and then optionally running a {@link Validator} * them to an object of a specified type and then optionally running a {@link Validator}
* over it. * over it.
* *
* @param <T> The target type * @param <T> the target type
* @author Dave Syer * @author Dave Syer
*/ */
public class PropertiesConfigurationFactory<T> public class PropertiesConfigurationFactory<T>

View File

@ -21,7 +21,7 @@ import org.springframework.core.ResolvableType;
/** /**
* Abstract base class for most {@code FailureAnalyzer} implementations. * Abstract base class for most {@code FailureAnalyzer} implementations.
* *
* @param <T> The type of exception to analyze * @param <T> the type of exception to analyze
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 1.4.0

View File

@ -35,7 +35,7 @@ import org.springframework.util.Assert;
* Helper base class for {@link JsonDeserializer} implementations that deserialize * Helper base class for {@link JsonDeserializer} implementations that deserialize
* objects. * objects.
* *
* @param <T> The supported object type * @param <T> the supported object type
* @author Phillip Webb * @author Phillip Webb
* @since 1.4.0 * @since 1.4.0
* @see JsonObjectSerializer * @see JsonObjectSerializer

View File

@ -26,7 +26,7 @@ import org.springframework.util.Assert;
* Adapter class allowing a Hamcrest {@link Matcher} to be used as an AssertJ * Adapter class allowing a Hamcrest {@link Matcher} to be used as an AssertJ
* {@link Condition}. * {@link Condition}.
* *
* @param <T> The type of object that the condition accepts * @param <T> the type of object that the condition accepts
* @author Phillip Webb * @author Phillip Webb
*/ */
public final class Matched<T> extends Condition<T> { public final class Matched<T> extends Condition<T> {