Merge pull request #5815 from izeye/polish-20160428

* pr/5815:
  Polish
pull/5815/merge
Stephane Nicoll 9 years ago
commit cfbe28fc8f

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

@ -19,7 +19,7 @@ package org.springframework.boot.actuate.metrics.buffer;
/**
* 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 Phillip Webb
*/

@ -22,7 +22,7 @@ import org.springframework.cache.CacheManager;
* 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.
*
* @param <T> The type of the {@link CacheManager}
* @param <T> the type of the {@link CacheManager}
* @author Stephane Nicoll
* @since 1.3.3
*/

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

@ -53,7 +53,7 @@ import org.springframework.util.ReflectionUtils.FieldCallback;
* public void testWriteJson() {
* ExampleObject object = //...
* 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>
* 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
* @since 1.4.0
* @see JsonContentAssert
@ -271,8 +271,8 @@ public abstract class AbstractJsonMarshalTester<T> {
/**
* Write the specified object to a JSON string.
* @param value the source value ({@code never null})
* @param type the resulting type ({@code never null})
* @param value the source value (never {@code null})
* @param type the resulting type (never {@code null})
* @return the JSON string
* @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
* default implementation delegates to {@link #readObject(Reader, ResolvableType)}
* @param inputStream the source input stream ({@code never null})
* @param type the resulting type ({@code never null})
* default implementation delegates to {@link #readObject(Reader, ResolvableType)}.
* @param inputStream the source input stream (never {@code null})
* @param type the resulting type (never {@code null})
* @return the resulting object
* @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.
* @param reader the source reader ({@code never null})
* @param type the resulting type ({@code never null})
* @param reader the source reader (never {@code null})
* @param type the resulting type (never {@code null})
* @return the resulting object
* @throws IOException on read error
*/
@ -304,7 +304,7 @@ public abstract class AbstractJsonMarshalTester<T> {
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}.
* @param <M> The marshaller type
*/

@ -24,13 +24,13 @@ import org.springframework.util.Assert;
/**
* 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 {
*
* private BasicJsonTester = new BasicJsonTester(getClass());
* private BasicJsonTester json = new BasicJsonTester(getClass());
*
* &#064;Test
* public void testWriteJson() {
* public void testWriteJson() throws IOException {
* assertThat(json.from("example.json")).extractingJsonPathStringValue("@.name")
.isEqualTo("Spring");
* }
@ -70,7 +70,7 @@ public class BasicJsonTester {
/**
* Create JSON content from the specified resource path.
* @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
*/
public JsonContent<Object> from(String path, Class<?> resourceLoadClass) {

@ -39,7 +39,7 @@ import org.springframework.util.Assert;
* }
*
* &#064;Test
* public void testWriteJson() {
* public void testWriteJson() throws IOException {
* ExampleObject object = //...
* assertThat(json.write(object)).isEqualToJson("expected.json");
* }
@ -49,7 +49,7 @@ import org.springframework.util.Assert;
*
* See {@link AbstractJsonMarshalTester} for more details.
*
* @param <T> The type under test
* @param <T> the type under test
* @author Phillip Webb
* @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.
* @param testInstance the test 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.
* @param testInstance the test 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> {

@ -41,7 +41,7 @@ import org.springframework.util.Assert;
* }
*
* &#064;Test
* public void testWriteJson() {
* public void testWriteJson() throws IOException {
* ExampleObject object = //...
* assertThat(json.write(object)).isEqualToJson("expected.json");
* }
@ -51,7 +51,7 @@ import org.springframework.util.Assert;
*
* See {@link AbstractJsonMarshalTester} for more details.
*
* @param <T> The type under test
* @param <T> the type under test
* @author Phillip Webb
* @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> {

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

@ -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
* 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 args arguments to parameterize the {@code JsonPath} expression with, using
* formatting specifiers defined in {@link String#format(String, Object...)}
@ -990,7 +990,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
JSONCompareResult result = new JSONCompareResult();
result.passed();
if (expectedJson != null) {
result.fail("Expected non-null JSON");
result.fail("Expected null JSON");
}
return result;
}
@ -1079,7 +1079,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
if (!required) {
return null;
}
throw new AssertionError(getNoValueMessage() + ex.getMessage());
throw new AssertionError(getNoValueMessage() + ". " + ex.getMessage());
}
}

@ -22,11 +22,11 @@ import org.springframework.core.ResolvableType;
import org.springframework.util.Assert;
/**
* Object content usually created from {@link AbstractJsonMarshalTester}.Generally used
* Object content usually created from {@link AbstractJsonMarshalTester}. Generally used
* only to {@link AssertProvider provide} {@link ObjectContentAssert} to AssertJ
* {@code assertThat} calls.
*
* @param <T> The content type
* @param <T> the content type
* @author Phillip Webb
* @since 1.4.0
*/

@ -26,7 +26,7 @@ import org.assertj.core.api.Assertions;
import org.assertj.core.internal.Objects;
/**
* AssertJ {@link Assert} for {@link JsonContent}.
* AssertJ {@link Assert} for {@link ObjectContent}.
*
* @param <A> The actual type
* @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
* allow chaining of array-specific assertions from this call.
* @return a list assertion object
* @return an array assertion object
*/
public AbstractObjectArrayAssert<?, Object> asArray() {
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
* chaining of list-specific assertions from this call.
* @return a list assertion object
* chaining of map-specific assertions from this call.
* @return a map assertion object
*/
@SuppressWarnings("unchecked")
public AbstractMapAssert<?, ?, Object, Object> asMap() {

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

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

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

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

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

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

@ -21,7 +21,7 @@ import org.springframework.core.ResolvableType;
/**
* 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 Phillip Webb
* @since 1.4.0

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

@ -26,7 +26,7 @@ import org.springframework.util.Assert;
* Adapter class allowing a Hamcrest {@link Matcher} to be used as an AssertJ
* {@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
*/
public final class Matched<T> extends Condition<T> {

Loading…
Cancel
Save