mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-14 05:54:57 +00:00
Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-lang.git
This commit is contained in:
commit
ec92ddd1c6
@ -63,6 +63,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||||||
<action issue="LANG-1477" type="add" dev="jochen">Added Functions.as*, and tests thereof, as suggested by Peter Verhas</action>
|
<action issue="LANG-1477" type="add" dev="jochen">Added Functions.as*, and tests thereof, as suggested by Peter Verhas</action>
|
||||||
<action issue="LANG-1475" type="fix" dev="kinow" due-to="stzx">StringUtils.unwrap incorrect throw StringIndexOutOfBoundsException.</action>
|
<action issue="LANG-1475" type="fix" dev="kinow" due-to="stzx">StringUtils.unwrap incorrect throw StringIndexOutOfBoundsException.</action>
|
||||||
<action issue="LANG-1485" type="add" dev="ggregory" due-to="nicolasbd">Add getters for lhs and rhs objects in DiffResult #451.</action>
|
<action issue="LANG-1485" type="add" dev="ggregory" due-to="nicolasbd">Add getters for lhs and rhs objects in DiffResult #451.</action>
|
||||||
|
<action issue="LANG-1486" type="add" dev="ggregory" due-to="Gary Gregory">Generify builder classes Diffable, DiffBuilder, and DiffResult #452.</action>
|
||||||
</release>
|
</release>
|
||||||
|
|
||||||
<release version="3.9" date="2019-04-09" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11">
|
<release version="3.9" date="2019-04-09" description="New features and bug fixes. Requires Java 8, supports Java 9, 10, 11">
|
||||||
|
@ -58,18 +58,19 @@
|
|||||||
* calling {@link DiffResult#toString(ToStringStyle)}.
|
* calling {@link DiffResult#toString(ToStringStyle)}.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @since 3.3
|
* @param <T> type of the left and right object.
|
||||||
* @see Diffable
|
* @see Diffable
|
||||||
* @see Diff
|
* @see Diff
|
||||||
* @see DiffResult
|
* @see DiffResult
|
||||||
* @see ToStringStyle
|
* @see ToStringStyle
|
||||||
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
public class DiffBuilder implements Builder<DiffResult> {
|
public class DiffBuilder<T> implements Builder<DiffResult<T>> {
|
||||||
|
|
||||||
private final List<Diff<?>> diffs;
|
private final List<Diff<?>> diffs;
|
||||||
private final boolean objectsTriviallyEqual;
|
private final boolean objectsTriviallyEqual;
|
||||||
private final Object left;
|
private final T left;
|
||||||
private final Object right;
|
private final T right;
|
||||||
private final ToStringStyle style;
|
private final ToStringStyle style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +101,7 @@ public class DiffBuilder implements Builder<DiffResult> {
|
|||||||
* if {@code lhs} or {@code rhs} is {@code null}
|
* if {@code lhs} or {@code rhs} is {@code null}
|
||||||
* @since 3.4
|
* @since 3.4
|
||||||
*/
|
*/
|
||||||
public DiffBuilder(final Object lhs, final Object rhs,
|
public DiffBuilder(final T lhs, final T rhs,
|
||||||
final ToStringStyle style, final boolean testTriviallyEqual) {
|
final ToStringStyle style, final boolean testTriviallyEqual) {
|
||||||
|
|
||||||
Validate.isTrue(lhs != null, "lhs cannot be null");
|
Validate.isTrue(lhs != null, "lhs cannot be null");
|
||||||
@ -141,7 +142,7 @@ public DiffBuilder(final Object lhs, final Object rhs,
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if {@code lhs} or {@code rhs} is {@code null}
|
* if {@code lhs} or {@code rhs} is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder(final Object lhs, final Object rhs,
|
public DiffBuilder(final T lhs, final T rhs,
|
||||||
final ToStringStyle style) {
|
final ToStringStyle style) {
|
||||||
|
|
||||||
this(lhs, rhs, style, true);
|
this(lhs, rhs, style, true);
|
||||||
@ -162,7 +163,7 @@ public DiffBuilder(final Object lhs, final Object rhs,
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final boolean lhs,
|
public DiffBuilder<T> append(final String fieldName, final boolean lhs,
|
||||||
final boolean rhs) {
|
final boolean rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -202,7 +203,7 @@ public Boolean getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final boolean[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final boolean[] lhs,
|
||||||
final boolean[] rhs) {
|
final boolean[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
if (objectsTriviallyEqual) {
|
if (objectsTriviallyEqual) {
|
||||||
@ -241,7 +242,7 @@ public Boolean[] getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final byte lhs,
|
public DiffBuilder<T> append(final String fieldName, final byte lhs,
|
||||||
final byte rhs) {
|
final byte rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
if (objectsTriviallyEqual) {
|
if (objectsTriviallyEqual) {
|
||||||
@ -280,7 +281,7 @@ public Byte getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final byte[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final byte[] lhs,
|
||||||
final byte[] rhs) {
|
final byte[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -320,7 +321,7 @@ public Byte[] getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final char lhs,
|
public DiffBuilder<T> append(final String fieldName, final char lhs,
|
||||||
final char rhs) {
|
final char rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -360,7 +361,7 @@ public Character getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final char[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final char[] lhs,
|
||||||
final char[] rhs) {
|
final char[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -400,7 +401,7 @@ public Character[] getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final double lhs,
|
public DiffBuilder<T> append(final String fieldName, final double lhs,
|
||||||
final double rhs) {
|
final double rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -440,7 +441,7 @@ public Double getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final double[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final double[] lhs,
|
||||||
final double[] rhs) {
|
final double[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -480,7 +481,7 @@ public Double[] getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final float lhs,
|
public DiffBuilder<T> append(final String fieldName, final float lhs,
|
||||||
final float rhs) {
|
final float rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -520,7 +521,7 @@ public Float getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final float[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final float[] lhs,
|
||||||
final float[] rhs) {
|
final float[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -560,7 +561,7 @@ public Float[] getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final int lhs,
|
public DiffBuilder<T> append(final String fieldName, final int lhs,
|
||||||
final int rhs) {
|
final int rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -600,7 +601,7 @@ public Integer getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final int[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final int[] lhs,
|
||||||
final int[] rhs) {
|
final int[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -640,7 +641,7 @@ public Integer[] getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final long lhs,
|
public DiffBuilder<T> append(final String fieldName, final long lhs,
|
||||||
final long rhs) {
|
final long rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -680,7 +681,7 @@ public Long getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final long[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final long[] lhs,
|
||||||
final long[] rhs) {
|
final long[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -720,7 +721,7 @@ public Long[] getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final short lhs,
|
public DiffBuilder<T> append(final String fieldName, final short lhs,
|
||||||
final short rhs) {
|
final short rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -760,7 +761,7 @@ public Short getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final short[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final short[] lhs,
|
||||||
final short[] rhs) {
|
final short[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
|
|
||||||
@ -800,7 +801,7 @@ public Short[] getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final Object lhs,
|
public DiffBuilder<T> append(final String fieldName, final Object lhs,
|
||||||
final Object rhs) {
|
final Object rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
if (objectsTriviallyEqual) {
|
if (objectsTriviallyEqual) {
|
||||||
@ -884,7 +885,7 @@ public Object getRight() {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName, final Object[] lhs,
|
public DiffBuilder<T> append(final String fieldName, final Object[] lhs,
|
||||||
final Object[] rhs) {
|
final Object[] rhs) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
if (objectsTriviallyEqual) {
|
if (objectsTriviallyEqual) {
|
||||||
@ -946,8 +947,8 @@ public Object[] getRight() {
|
|||||||
* if field name is {@code null}
|
* if field name is {@code null}
|
||||||
* @since 3.5
|
* @since 3.5
|
||||||
*/
|
*/
|
||||||
public DiffBuilder append(final String fieldName,
|
public DiffBuilder<T> append(final String fieldName,
|
||||||
final DiffResult diffResult) {
|
final DiffResult<T> diffResult) {
|
||||||
validateFieldNameNotNull(fieldName);
|
validateFieldNameNotNull(fieldName);
|
||||||
Validate.isTrue(diffResult != null, "Diff result cannot be null");
|
Validate.isTrue(diffResult != null, "Diff result cannot be null");
|
||||||
if (objectsTriviallyEqual) {
|
if (objectsTriviallyEqual) {
|
||||||
@ -972,8 +973,8 @@ public DiffBuilder append(final String fieldName,
|
|||||||
* objects.
|
* objects.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DiffResult build() {
|
public DiffResult<T> build() {
|
||||||
return new DiffResult(left, right, diffs, style);
|
return new DiffResult<>(left, right, diffs, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateFieldNameNotNull(final String fieldName) {
|
private void validateFieldNameNotNull(final String fieldName) {
|
||||||
|
@ -32,10 +32,11 @@
|
|||||||
* <p>
|
* <p>
|
||||||
* Use a {@link DiffBuilder} to build a {@code DiffResult} comparing two objects.
|
* Use a {@link DiffBuilder} to build a {@code DiffResult} comparing two objects.
|
||||||
* </p>
|
* </p>
|
||||||
|
* @param <T> type of the left and right object.
|
||||||
*
|
*
|
||||||
* @since 3.3
|
* @since 3.3
|
||||||
*/
|
*/
|
||||||
public class DiffResult implements Iterable<Diff<?>> {
|
public class DiffResult<T> implements Iterable<Diff<?>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -48,8 +49,8 @@ public class DiffResult implements Iterable<Diff<?>> {
|
|||||||
private static final String DIFFERS_STRING = "differs from";
|
private static final String DIFFERS_STRING = "differs from";
|
||||||
|
|
||||||
private final List<Diff<?>> diffs;
|
private final List<Diff<?>> diffs;
|
||||||
private final Object lhs;
|
private final T lhs;
|
||||||
private final Object rhs;
|
private final T rhs;
|
||||||
private final ToStringStyle style;
|
private final ToStringStyle style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +72,7 @@ public class DiffResult implements Iterable<Diff<?>> {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if {@code lhs}, {@code rhs} or {@code diffs} is {@code null}
|
* if {@code lhs}, {@code rhs} or {@code diffs} is {@code null}
|
||||||
*/
|
*/
|
||||||
DiffResult(final Object lhs, final Object rhs, final List<Diff<?>> diffs,
|
DiffResult(final T lhs, final T rhs, final List<Diff<?>> diffs,
|
||||||
final ToStringStyle style) {
|
final ToStringStyle style) {
|
||||||
Validate.isTrue(lhs != null, "Left hand object cannot be null");
|
Validate.isTrue(lhs != null, "Left hand object cannot be null");
|
||||||
Validate.isTrue(rhs != null, "Right hand object cannot be null");
|
Validate.isTrue(rhs != null, "Right hand object cannot be null");
|
||||||
@ -94,7 +95,7 @@ public class DiffResult implements Iterable<Diff<?>> {
|
|||||||
* @return the left object of the diff
|
* @return the left object of the diff
|
||||||
* @since 3.10
|
* @since 3.10
|
||||||
*/
|
*/
|
||||||
public Object getLeft() {
|
public T getLeft() {
|
||||||
return this.lhs;
|
return this.lhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ public Object getLeft() {
|
|||||||
* @return the right object of the diff
|
* @return the right object of the diff
|
||||||
* @since 3.10
|
* @since 3.10
|
||||||
*/
|
*/
|
||||||
public Object getRight() {
|
public T getRight() {
|
||||||
return this.rhs;
|
return this.rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,5 +49,5 @@ public interface Diffable<T> {
|
|||||||
* @return a list of differences
|
* @return a list of differences
|
||||||
* @throws NullPointerException if the specified object is {@code null}
|
* @throws NullPointerException if the specified object is {@code null}
|
||||||
*/
|
*/
|
||||||
DiffResult diff(T obj);
|
DiffResult<T> diff(T obj);
|
||||||
}
|
}
|
||||||
|
@ -59,17 +59,19 @@
|
|||||||
* {@code DiffResult.toString()} method. This style choice can be overridden by
|
* {@code DiffResult.toString()} method. This style choice can be overridden by
|
||||||
* calling {@link DiffResult#toString(ToStringStyle)}.
|
* calling {@link DiffResult#toString(ToStringStyle)}.
|
||||||
* </p>
|
* </p>
|
||||||
|
* @param <T>
|
||||||
|
* type of the left and right object to diff.
|
||||||
* @see Diffable
|
* @see Diffable
|
||||||
* @see Diff
|
* @see Diff
|
||||||
* @see DiffResult
|
* @see DiffResult
|
||||||
* @see ToStringStyle
|
* @see ToStringStyle
|
||||||
* @since 3.6
|
* @since 3.6
|
||||||
*/
|
*/
|
||||||
public class ReflectionDiffBuilder implements Builder<DiffResult> {
|
public class ReflectionDiffBuilder<T> implements Builder<DiffResult<T>> {
|
||||||
|
|
||||||
private final Object left;
|
private final Object left;
|
||||||
private final Object right;
|
private final Object right;
|
||||||
private final DiffBuilder diffBuilder;
|
private final DiffBuilder<T> diffBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -81,8 +83,6 @@ public class ReflectionDiffBuilder implements Builder<DiffResult> {
|
|||||||
* not evaluate any calls to {@code append(...)} and will return an empty
|
* not evaluate any calls to {@code append(...)} and will return an empty
|
||||||
* {@link DiffResult} when {@link #build()} is executed.
|
* {@link DiffResult} when {@link #build()} is executed.
|
||||||
* </p>
|
* </p>
|
||||||
* @param <T>
|
|
||||||
* type of the objects to diff
|
|
||||||
* @param lhs
|
* @param lhs
|
||||||
* {@code this} object
|
* {@code this} object
|
||||||
* @param rhs
|
* @param rhs
|
||||||
@ -93,14 +93,14 @@ public class ReflectionDiffBuilder implements Builder<DiffResult> {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if {@code lhs} or {@code rhs} is {@code null}
|
* if {@code lhs} or {@code rhs} is {@code null}
|
||||||
*/
|
*/
|
||||||
public <T> ReflectionDiffBuilder(final T lhs, final T rhs, final ToStringStyle style) {
|
public ReflectionDiffBuilder(final T lhs, final T rhs, final ToStringStyle style) {
|
||||||
this.left = lhs;
|
this.left = lhs;
|
||||||
this.right = rhs;
|
this.right = rhs;
|
||||||
diffBuilder = new DiffBuilder(lhs, rhs, style);
|
diffBuilder = new DiffBuilder<>(lhs, rhs, style);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffResult build() {
|
public DiffResult<T> build() {
|
||||||
if (left.equals(right)) {
|
if (left.equals(right)) {
|
||||||
return diffBuilder.build();
|
return diffBuilder.build();
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ private static class TypeTestClass implements Diffable<TypeTestClass> {
|
|||||||
private Object[] objectArrayField = {null};
|
private Object[] objectArrayField = {null};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DiffResult diff(final TypeTestClass obj) {
|
public DiffResult<TypeTestClass> diff(final TypeTestClass obj) {
|
||||||
return new DiffBuilder(this, obj, style)
|
return new DiffBuilder<>(this, obj, style)
|
||||||
.append("boolean", booleanField, obj.booleanField)
|
.append("boolean", booleanField, obj.booleanField)
|
||||||
.append("booleanArray", booleanArrayField, obj.booleanArrayField)
|
.append("booleanArray", booleanArrayField, obj.booleanArrayField)
|
||||||
.append("byte", byteField, obj.byteField)
|
.append("byte", byteField, obj.byteField)
|
||||||
@ -99,7 +99,7 @@ public void testBoolean() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.booleanField = false;
|
class2.booleanField = false;
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(Boolean.class, diff.getType());
|
assertEquals(Boolean.class, diff.getType());
|
||||||
@ -112,7 +112,7 @@ public void testBooleanArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.booleanArrayField = new boolean[] {false, false};
|
class2.booleanArrayField = new boolean[] {false, false};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(ArrayUtils.toObject(class1.booleanArrayField),
|
assertArrayEquals(ArrayUtils.toObject(class1.booleanArrayField),
|
||||||
@ -127,7 +127,7 @@ public void testByte() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.byteField = 0x01;
|
class2.byteField = 0x01;
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(Byte.valueOf(class1.byteField), diff.getLeft());
|
assertEquals(Byte.valueOf(class1.byteField), diff.getLeft());
|
||||||
@ -139,7 +139,7 @@ public void testByteArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.byteArrayField= new byte[] {0x01, 0x02};
|
class2.byteArrayField= new byte[] {0x01, 0x02};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(ArrayUtils.toObject(class1.byteArrayField),
|
assertArrayEquals(ArrayUtils.toObject(class1.byteArrayField),
|
||||||
@ -153,7 +153,7 @@ public void testChar() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.charField = 'z';
|
class2.charField = 'z';
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(Character.valueOf(class1.charField), diff.getLeft());
|
assertEquals(Character.valueOf(class1.charField), diff.getLeft());
|
||||||
@ -166,7 +166,7 @@ public void testCharArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.charArrayField = new char[] {'f', 'o', 'o'};
|
class2.charArrayField = new char[] {'f', 'o', 'o'};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(ArrayUtils.toObject(class1.charArrayField),
|
assertArrayEquals(ArrayUtils.toObject(class1.charArrayField),
|
||||||
@ -181,7 +181,7 @@ public void testDouble() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.doubleField = 99.99;
|
class2.doubleField = 99.99;
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(Double.valueOf(class1.doubleField), diff.getLeft());
|
assertEquals(Double.valueOf(class1.doubleField), diff.getLeft());
|
||||||
@ -194,7 +194,7 @@ public void testDoubleArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.doubleArrayField = new double[] {3.0, 2.9, 2.8};
|
class2.doubleArrayField = new double[] {3.0, 2.9, 2.8};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(ArrayUtils.toObject(class1.doubleArrayField),
|
assertArrayEquals(ArrayUtils.toObject(class1.doubleArrayField),
|
||||||
@ -208,7 +208,7 @@ public void testFloat() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.floatField = 99.99F;
|
class2.floatField = 99.99F;
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(Float.valueOf(class1.floatField), diff.getLeft());
|
assertEquals(Float.valueOf(class1.floatField), diff.getLeft());
|
||||||
@ -221,7 +221,7 @@ public void testFloatArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.floatArrayField = new float[] {3.0F, 2.9F, 2.8F};
|
class2.floatArrayField = new float[] {3.0F, 2.9F, 2.8F};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(ArrayUtils.toObject(class1.floatArrayField),
|
assertArrayEquals(ArrayUtils.toObject(class1.floatArrayField),
|
||||||
@ -236,7 +236,7 @@ public void testInt() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.intField = 42;
|
class2.intField = 42;
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(Integer.valueOf(class1.intField), diff.getLeft());
|
assertEquals(Integer.valueOf(class1.intField), diff.getLeft());
|
||||||
@ -249,7 +249,7 @@ public void testIntArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.intArrayField = new int[] {3, 2, 1};
|
class2.intArrayField = new int[] {3, 2, 1};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(ArrayUtils.toObject(class1.intArrayField),
|
assertArrayEquals(ArrayUtils.toObject(class1.intArrayField),
|
||||||
@ -263,7 +263,7 @@ public void testLong() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.longField = 42L;
|
class2.longField = 42L;
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(Long.valueOf(class1.longField), diff.getLeft());
|
assertEquals(Long.valueOf(class1.longField), diff.getLeft());
|
||||||
@ -276,7 +276,7 @@ public void testLongArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.longArrayField = new long[] {3L, 2L, 1L};
|
class2.longArrayField = new long[] {3L, 2L, 1L};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(ArrayUtils.toObject(class1.longArrayField),
|
assertArrayEquals(ArrayUtils.toObject(class1.longArrayField),
|
||||||
@ -290,7 +290,7 @@ public void testShort() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.shortField = 42;
|
class2.shortField = 42;
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(Short.valueOf(class1.shortField), diff.getLeft());
|
assertEquals(Short.valueOf(class1.shortField), diff.getLeft());
|
||||||
@ -303,7 +303,7 @@ public void testShortArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.shortArrayField = new short[] {3, 2, 1};
|
class2.shortArrayField = new short[] {3, 2, 1};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(ArrayUtils.toObject(class1.shortArrayField),
|
assertArrayEquals(ArrayUtils.toObject(class1.shortArrayField),
|
||||||
@ -317,7 +317,7 @@ public void testObject() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.objectField = "Some string";
|
class2.objectField = "Some string";
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertEquals(class1.objectField, diff.getLeft());
|
assertEquals(class1.objectField, diff.getLeft());
|
||||||
@ -337,7 +337,7 @@ public void testObjectsSameAndEqual() {
|
|||||||
assertSame(left.objectField, right.objectField);
|
assertSame(left.objectField, right.objectField);
|
||||||
assertEquals(left.objectField, right.objectField);
|
assertEquals(left.objectField, right.objectField);
|
||||||
|
|
||||||
final DiffResult list = left.diff(right);
|
final DiffResult<TypeTestClass> list = left.diff(right);
|
||||||
assertEquals(0, list.getNumberOfDiffs());
|
assertEquals(0, list.getNumberOfDiffs());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ public void testObjectsNotSameButEqual() {
|
|||||||
assertNotSame(left.objectField, right.objectField);
|
assertNotSame(left.objectField, right.objectField);
|
||||||
assertEquals(left.objectField, right.objectField);
|
assertEquals(left.objectField, right.objectField);
|
||||||
|
|
||||||
final DiffResult list = left.diff(right);
|
final DiffResult<TypeTestClass> list = left.diff(right);
|
||||||
assertEquals(0, list.getNumberOfDiffs());
|
assertEquals(0, list.getNumberOfDiffs());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ public void testObjectsNotSameNorEqual() {
|
|||||||
assertNotSame(left.objectField, right.objectField);
|
assertNotSame(left.objectField, right.objectField);
|
||||||
assertNotEquals(left.objectField, right.objectField);
|
assertNotEquals(left.objectField, right.objectField);
|
||||||
|
|
||||||
final DiffResult list = left.diff(right);
|
final DiffResult<TypeTestClass> list = left.diff(right);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ public void testObjectArray() {
|
|||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.objectArrayField = new Object[] {"string", 1, 2};
|
class2.objectArrayField = new Object[] {"string", 1, 2};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
final Diff<?> diff = list.getDiffs().get(0);
|
final Diff<?> diff = list.getDiffs().get(0);
|
||||||
assertArrayEquals(class1.objectArrayField, (Object[]) diff.getLeft());
|
assertArrayEquals(class1.objectArrayField, (Object[]) diff.getLeft());
|
||||||
@ -391,14 +391,14 @@ public void testObjectArrayEqual() {
|
|||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class1.objectArrayField = new Object[] {"string", 1, 2};
|
class1.objectArrayField = new Object[] {"string", 1, 2};
|
||||||
class2.objectArrayField = new Object[] {"string", 1, 2};
|
class2.objectArrayField = new Object[] {"string", 1, 2};
|
||||||
final DiffResult list = class1.diff(class2);
|
final DiffResult<TypeTestClass> list = class1.diff(class2);
|
||||||
assertEquals(0, list.getNumberOfDiffs());
|
assertEquals(0, list.getNumberOfDiffs());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testByteArrayEqualAsObject() {
|
public void testByteArrayEqualAsObject() {
|
||||||
final DiffResult list = new DiffBuilder("String1", "String2", SHORT_STYLE)
|
final DiffResult<String> list = new DiffBuilder<>("String1", "String2", SHORT_STYLE)
|
||||||
.append("foo", new boolean[] {false}, new boolean[] {false})
|
.append("foo", new boolean[] {false}, new boolean[] {false})
|
||||||
.append("foo", new byte[] {0x01}, new byte[] {0x01})
|
.append("foo", new byte[] {0x01}, new byte[] {0x01})
|
||||||
.append("foo", new char[] {'a'}, new char[] {'a'})
|
.append("foo", new char[] {'a'}, new char[] {'a'})
|
||||||
@ -419,7 +419,7 @@ public void testDiffResult() {
|
|||||||
final TypeTestClass class2 = new TypeTestClass();
|
final TypeTestClass class2 = new TypeTestClass();
|
||||||
class2.intField = 2;
|
class2.intField = 2;
|
||||||
|
|
||||||
final DiffResult list = new DiffBuilder(class1, class2, SHORT_STYLE)
|
final DiffResult<TypeTestClass> list = new DiffBuilder<>(class1, class2, SHORT_STYLE)
|
||||||
.append("prop1", class1.diff(class2))
|
.append("prop1", class1.diff(class2))
|
||||||
.build();
|
.build();
|
||||||
assertEquals(1, list.getNumberOfDiffs());
|
assertEquals(1, list.getNumberOfDiffs());
|
||||||
@ -428,19 +428,19 @@ public void testDiffResult() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullLhs() {
|
public void testNullLhs() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> new DiffBuilder(null, this, ToStringStyle.DEFAULT_STYLE));
|
assertThrows(IllegalArgumentException.class, () -> new DiffBuilder<>(null, this, ToStringStyle.DEFAULT_STYLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullRhs() {
|
public void testNullRhs() {
|
||||||
assertThrows(IllegalArgumentException.class, () -> new DiffBuilder(this, null, ToStringStyle.DEFAULT_STYLE));
|
assertThrows(IllegalArgumentException.class, () -> new DiffBuilder<>(this, null, ToStringStyle.DEFAULT_STYLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSameObjectIgnoresAppends() {
|
public void testSameObjectIgnoresAppends() {
|
||||||
final TypeTestClass testClass = new TypeTestClass();
|
final TypeTestClass testClass = new TypeTestClass();
|
||||||
final DiffResult list = new DiffBuilder(testClass, testClass, SHORT_STYLE)
|
final DiffResult<TypeTestClass> list = new DiffBuilder<>(testClass, testClass, SHORT_STYLE)
|
||||||
.append("ignored", false, true)
|
.append("ignored", false, true)
|
||||||
.build();
|
.build();
|
||||||
assertEquals(0, list.getNumberOfDiffs());
|
assertEquals(0, list.getNumberOfDiffs());
|
||||||
@ -450,7 +450,7 @@ public void testSameObjectIgnoresAppends() {
|
|||||||
public void testSimilarObjectIgnoresAppends() {
|
public void testSimilarObjectIgnoresAppends() {
|
||||||
final TypeTestClass testClass1 = new TypeTestClass();
|
final TypeTestClass testClass1 = new TypeTestClass();
|
||||||
final TypeTestClass testClass2 = new TypeTestClass();
|
final TypeTestClass testClass2 = new TypeTestClass();
|
||||||
final DiffResult list = new DiffBuilder(testClass1, testClass2, SHORT_STYLE)
|
final DiffResult<TypeTestClass> list = new DiffBuilder<>(testClass1, testClass2, SHORT_STYLE)
|
||||||
.append("ignored", false, true)
|
.append("ignored", false, true)
|
||||||
.build();
|
.build();
|
||||||
assertEquals(0, list.getNumberOfDiffs());
|
assertEquals(0, list.getNumberOfDiffs());
|
||||||
@ -460,7 +460,7 @@ public void testSimilarObjectIgnoresAppends() {
|
|||||||
@Test
|
@Test
|
||||||
public void testStylePassedToDiffResult() {
|
public void testStylePassedToDiffResult() {
|
||||||
final TypeTestClass class1 = new TypeTestClass();
|
final TypeTestClass class1 = new TypeTestClass();
|
||||||
DiffResult list = class1.diff(class1);
|
DiffResult<TypeTestClass> list = class1.diff(class1);
|
||||||
assertEquals(SHORT_STYLE, list.getToStringStyle());
|
assertEquals(SHORT_STYLE, list.getToStringStyle());
|
||||||
|
|
||||||
class1.style = ToStringStyle.MULTI_LINE_STYLE;
|
class1.style = ToStringStyle.MULTI_LINE_STYLE;
|
||||||
@ -473,12 +473,12 @@ public void testTriviallyEqualTestDisabled() {
|
|||||||
final Matcher<Integer> equalToOne = equalTo(1);
|
final Matcher<Integer> equalToOne = equalTo(1);
|
||||||
|
|
||||||
// Constructor's arguments are not trivially equal, but not testing for that.
|
// Constructor's arguments are not trivially equal, but not testing for that.
|
||||||
final DiffBuilder explicitTestAndNotEqual1 = new DiffBuilder(1, 2, null, false);
|
final DiffBuilder<Integer> explicitTestAndNotEqual1 = new DiffBuilder<>(1, 2, null, false);
|
||||||
explicitTestAndNotEqual1.append("letter", "X", "Y");
|
explicitTestAndNotEqual1.append("letter", "X", "Y");
|
||||||
assertThat(explicitTestAndNotEqual1.build().getNumberOfDiffs(), equalToOne);
|
assertThat(explicitTestAndNotEqual1.build().getNumberOfDiffs(), equalToOne);
|
||||||
|
|
||||||
// Constructor's arguments are trivially equal, but not testing for that.
|
// Constructor's arguments are trivially equal, but not testing for that.
|
||||||
final DiffBuilder explicitTestAndNotEqual2 = new DiffBuilder(1, 1, null, false);
|
final DiffBuilder<Integer> explicitTestAndNotEqual2 = new DiffBuilder<>(1, 1, null, false);
|
||||||
// This append(f, l, r) will not abort early.
|
// This append(f, l, r) will not abort early.
|
||||||
explicitTestAndNotEqual2.append("letter", "X", "Y");
|
explicitTestAndNotEqual2.append("letter", "X", "Y");
|
||||||
assertThat(explicitTestAndNotEqual2.build().getNumberOfDiffs(), equalToOne);
|
assertThat(explicitTestAndNotEqual2.build().getNumberOfDiffs(), equalToOne);
|
||||||
@ -490,19 +490,19 @@ public void testTriviallyEqualTestEnabled() {
|
|||||||
final Matcher<Integer> equalToOne = equalTo(1);
|
final Matcher<Integer> equalToOne = equalTo(1);
|
||||||
|
|
||||||
// The option to test if trivially equal is enabled by default.
|
// The option to test if trivially equal is enabled by default.
|
||||||
final DiffBuilder implicitTestAndEqual = new DiffBuilder(1, 1, null);
|
final DiffBuilder<Integer> implicitTestAndEqual = new DiffBuilder<>(1, 1, null);
|
||||||
// This append(f, l, r) will abort without creating a Diff for letter.
|
// This append(f, l, r) will abort without creating a Diff for letter.
|
||||||
implicitTestAndEqual.append("letter", "X", "Y");
|
implicitTestAndEqual.append("letter", "X", "Y");
|
||||||
assertThat(implicitTestAndEqual.build().getNumberOfDiffs(), equalToZero);
|
assertThat(implicitTestAndEqual.build().getNumberOfDiffs(), equalToZero);
|
||||||
|
|
||||||
final DiffBuilder implicitTestAndNotEqual = new DiffBuilder(1, 2, null);
|
final DiffBuilder<Integer> implicitTestAndNotEqual = new DiffBuilder<>(1, 2, null);
|
||||||
// This append(f, l, r) will not abort early
|
// This append(f, l, r) will not abort early
|
||||||
// because the constructor's arguments were not trivially equal.
|
// because the constructor's arguments were not trivially equal.
|
||||||
implicitTestAndNotEqual.append("letter", "X", "Y");
|
implicitTestAndNotEqual.append("letter", "X", "Y");
|
||||||
assertThat(implicitTestAndNotEqual.build().getNumberOfDiffs(), equalToOne);
|
assertThat(implicitTestAndNotEqual.build().getNumberOfDiffs(), equalToOne);
|
||||||
|
|
||||||
// This is explicitly enabling the trivially equal test.
|
// This is explicitly enabling the trivially equal test.
|
||||||
final DiffBuilder explicitTestAndEqual = new DiffBuilder(1, 1, null, true);
|
final DiffBuilder<Integer> explicitTestAndEqual = new DiffBuilder<>(1, 1, null, true);
|
||||||
explicitTestAndEqual.append("letter", "X", "Y");
|
explicitTestAndEqual.append("letter", "X", "Y");
|
||||||
assertThat(explicitTestAndEqual.build().getNumberOfDiffs(), equalToZero);
|
assertThat(explicitTestAndEqual.build().getNumberOfDiffs(), equalToZero);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user