@Override boolean test() { return thisObj == thatObj || (thisObj != null && testEquality(thisObj.isEqualTo(thatObj))); }
public static TestableEquality of(String name, Testable a, Testable b) { return new TestableEquality(name, a.isEqualTo(b)); }
public static TestableEquality of(String name, Testable a, Testable b) { return new TestableEquality(name, a.isEqualTo(b)); }
private boolean isEqual(T thatObj) { Equality equality = thisObj.isEqualTo(thatObj); equality.accept(reporter); return reporter.lineList().isEmpty(); }
br.com.objectos.way.testable.Testable thisTestable = (br.com.objectos.way.testable.Testable) thisObj; br.com.objectos.way.testable.Testable thatTestable = (br.com.objectos.way.testable.Testable) thatObj; if (!testEquality(thisTestable.isEqualTo(thatTestable))) { return false;
@Override protected boolean matchesSafely(List<T> thatList) { if (thisList == thatList) { return true; } if (thisList.size() != thatList.size()) { return false; } List<Equality> equalityList = new ArrayList<>(); Iterator<T> thisIter = thisList.iterator(); Iterator<T> thatIter = thatList.iterator(); int index = -1; while (thisIter.hasNext()) { index++; Testable thisObj = thisIter.next(); T thatObj = thatIter.next(); if (thisObj == null && thatObj != null) { equalityList.add(Equality.elementNotExpected(index, thatObj)); break; } equalityList.add(thisObj.isEqualTo(thatObj)); } Reporter reporter = Reporter.start(); for (Equality equality : equalityList) { if (!equality.isEqual()) { equality.accept(reporter); } } return reporter.lineList().isEmpty(); }
protected S isEqualTo0(Object another) { Equality equality = ((Testable) subject()).isEqualTo(another); testEquality(equality); return self(); }
public static Equality of(String name, Optional<?> a, Optional<?> b) { if (a == b) { return Equality.equal(); } if (b == null) { return new OptionalEquality(name, Equality.nullValue()); } Object maybeA = a.orElse(null); Object maybeB = b.orElse(null); Equality result = maybeA instanceof Testable ? ((Testable) maybeA).isEqualTo(maybeB) : Objects.equals(maybeA, maybeB) ? Equality.equal() : Equality.fail(Objects.toString(maybeA), Objects.toString(maybeB)); return new OptionalEquality(name, result); }
public static Equality of(String name, Optional<?> a, Optional<?> b) { if (a == b) { return Equality.equal(); } if (b == null) { return new OptionalEquality(name, Equality.nullValue()); } Object maybeA = a.orElse(null); Object maybeB = b.orElse(null); Equality result = maybeA instanceof Testable ? ((Testable) maybeA).isEqualTo(maybeB) : Objects.equals(maybeA, maybeB) ? Equality.equal() : Equality.fail(Objects.toString(maybeA), Objects.toString(maybeB)); return new OptionalEquality(name, result); }
public OptionalAssertion<T> isEqualTo(T value) { if (subject().isPresent()) { T actual = subject().get(); if (actual instanceof Testable) { Equality equality = ((Testable) actual).isEqualTo(value); testEquality(equality); } else { fail("Value is not an instance of Testable."); } } return self(); }
public OptionalAssertion<T> isEqualTo(T value) { if (subject().isPresent()) { T actual = subject().get(); if (actual instanceof Testable) { Equality equality = ((Testable) actual).isEqualTo(value); testEquality(equality); } else { fail("Value is not an instance of Testable."); } } return self(); }
protected S isEqualTo0(T another) { Equality equality = ((Testable) subject()).isEqualTo(another); testEquality(equality); return self(); }
? ((Testable) nextA).isEqualTo(nextB) : Objects.equals(nextA, nextB) ? Equality.equal()
? ((Testable) nextA).isEqualTo(nextB) : Objects.equals(nextA, nextB) ? Equality.equal()
public final SELF isEqualTo(COL thatList) { if (subject() == thatList) { return self(); } hasSize(thatList.size()); List<Equality> equalityList = new ArrayList<>(); Iterator<T> thisIter = subject().iterator(); Iterator<T> thatIter = thatList.iterator(); int index = -1; while (thisIter.hasNext()) { index++; Testable thisObj = (Testable) thisIter.next(); T thatObj = thatIter.next(); if (thisObj == null && thatObj != null) { equalityList.add(Equality.elementNotExpected(index, thatObj)); break; } equalityList.add(thisObj.isEqualTo(thatObj)); } Reporter reporter = Reporter.start(); for (Equality equality : equalityList) { if (!equality.isEqual()) { equality.accept(reporter); } } reporter.test(); return self(); }
public final SELF isEqualTo(List<T> thatList) { if (subject() == thatList) { return self(); } hasSize(thatList.size()); List<Equality> equalityList = new ArrayList<>(); Iterator<T> thisIter = subject().iterator(); Iterator<T> thatIter = thatList.iterator(); int index = -1; while (thisIter.hasNext()) { index++; Testable thisObj = (Testable) thisIter.next(); T thatObj = thatIter.next(); if (thisObj == null && thatObj != null) { equalityList.add(Equality.elementNotExpected(index, thatObj)); break; } equalityList.add(thisObj.isEqualTo(thatObj)); } Reporter reporter = Reporter.start(); for (Equality equality : equalityList) { if (!equality.isEqual()) { equality.accept(reporter); } } reporter.test(); return self(); }