org.assertj.core.api.AbstractIterableAssert.usingElementComparator()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(73)

本文整理了Java中org.assertj.core.api.AbstractIterableAssert.usingElementComparator()方法的一些代码示例,展示了AbstractIterableAssert.usingElementComparator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractIterableAssert.usingElementComparator()方法的具体详情如下:
包路径:org.assertj.core.api.AbstractIterableAssert
类名称:AbstractIterableAssert
方法名:usingElementComparator

AbstractIterableAssert.usingElementComparator介绍

暂无

代码示例

代码示例来源:origin: org.assertj/assertj-core

@CheckReturnValue
private SELF usingExtendedByTypesElementComparator(Comparator<Object> elementComparator) {
 return usingElementComparator(new ExtendedByTypesComparator(elementComparator, getComparatorsByType()));
}

代码示例来源:origin: joel-costigliola/assertj-core

@CheckReturnValue
private SELF usingExtendedByTypesElementComparator(Comparator<Object> elementComparator) {
 return usingElementComparator(new ExtendedByTypesComparator(elementComparator, getComparatorsByType()));
}

代码示例来源:origin: org.assertj/assertj-core

@Override
@CheckReturnValue
public SELF usingElementComparator(Comparator<? super ELEMENT> customComparator) {
 lists = new Lists(new ComparatorBasedComparisonStrategy(customComparator));
 return super.usingElementComparator(customComparator);
}

代码示例来源:origin: joel-costigliola/assertj-core

@Override
@CheckReturnValue
public SELF usingElementComparator(Comparator<? super ELEMENT> customComparator) {
 lists = new Lists(new ComparatorBasedComparisonStrategy(customComparator));
 return super.usingElementComparator(customComparator);
}

代码示例来源:origin: org.assertj/assertj-core

public <T> SELF usingComparatorForType(Comparator<T> comparator, Class<T> type) {
 if (iterables.getComparator() == null) {
  usingElementComparator(new ExtendedByTypesComparator(getComparatorsByType()));

代码示例来源:origin: joel-costigliola/assertj-core

public <T> SELF usingComparatorForType(Comparator<T> comparator, Class<T> type) {
 if (iterables.getComparator() == null) {
  usingElementComparator(new ExtendedByTypesComparator(getComparatorsByType()));

代码示例来源:origin: org.assertj/assertj-core-java8

/**
 * Use field by field comparison on all fields <b>except</b> the given ones (fields can be inherited fields) instead
 * of relying on actual type A <code>equals</code> method to compare group elements for incoming assertion checks.
 * <p/>
 * This can be handy if <code>equals</code> method of the objects to compare does not suit you.
 * <p/>
 * Note that only <b>accessible </b>fields values are compared, accessible fields include directly accessible fields
 * (e.g. public) or fields with an accessible getter.<br/>
 * Moreover comparison is <b>not</b> recursive, if one of the field is an Object, it will be compared to the other
 * field using its <code>equals</code> method.
 * </p>
 * Example:
 *
 * <pre><code class='java'>
 * TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);
 * TolkienCharacter sam = new TolkienCharacter("Sam", 38, HOBBIT);
 * 
 * // frodo and sam both are hobbits, so they are equals when comparing only race (i.e. ignoring all other fields)
 * assertThat(newArrayList(frodo)).usingElementComparatorIgnoringFields("name", "age").contains(sam); // OK
 * 
 * // ... but not when comparing both name and race
 * assertThat(newArrayList(frodo)).usingElementComparatorIgnoringFields("age").contains(sam); // FAIL
 * </code></pre>
 *
 * @return {@code this} assertion object.
 */
public S usingElementComparatorIgnoringFields(String... fields) {
 return usingElementComparator(new IgnoringFieldsComparator(fields));
}

代码示例来源:origin: org.assertj/assertj-core-java8

/**
 * Use field by field comparison (including inherited fields) instead of relying on actual type A <code>equals</code>
 * method to compare group elements for incoming assertion checks.
 * <p/>
 * This can be handy if <code>equals</code> method of the objects to compare does not suit you.
 * <p/>
 * Note that only <b>accessible </b>fields values are compared, accessible fields include directly accessible fields
 * (e.g. public) or fields with an accessible getter.<br/>
 * Moreover comparison is <b>not</b> recursive, if one of the field is an Object, it will be compared to the other
 * field using its <code>equals</code> method.
 * </p>
 * Example:
 *
 * <pre><code class='java'>
 * TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);
 * TolkienCharacter frodoClone = new TolkienCharacter("Frodo", 33, HOBBIT);
 * 
 * // Fail if equals has not been overriden in TolkienCharacter as equals default implementation only compares references
 * assertThat(newArrayList(frodo)).contains(frodoClone);
 * 
 * // frodo and frodoClone are equals when doing a field by field comparison.
 * assertThat(newArrayList(frodo)).usingFieldByFieldElementComparator().contains(frodoClone);
 * </code></pre>
 *
 * @return {@code this} assertion object.
 */
public S usingFieldByFieldElementComparator() {
 return usingElementComparator(new FieldByFieldComparator());
}

代码示例来源:origin: org.assertj/assertj-core-java8

/**
 * Use field by field comparison on the <b>given fields only</b> (fields can be inherited fields) instead of relying
 * on actual type A <code>equals</code> method to compare group elements for incoming assertion checks.
 * <p/>
 * This can be handy if <code>equals</code> method of the objects to compare does not suit you.
 * <p/>
 * Note that only <b>accessible </b>fields values are compared, accessible fields include directly accessible fields
 * (e.g. public) or fields with an accessible getter.<br/>
 * Moreover comparison is <b>not</b> recursive, if one of the field is an Object, it will be compared to the other
 * field using its <code>equals</code> method.
 * </p>
 * Example:
 *
 * <pre><code class='java'>
 * TolkienCharacter frodo = new TolkienCharacter("Frodo", 33, HOBBIT);
 * TolkienCharacter sam = new TolkienCharacter("Sam", 38, HOBBIT);
 * 
 * // frodo and sam both are hobbits, so they are equals when comparing only race
 * assertThat(newArrayList(frodo)).usingElementComparatorOnFields("race").contains(sam); // OK
 * 
 * // ... but not when comparing both name and race
 * assertThat(newArrayList(frodo)).usingElementComparatorOnFields("name", "race").contains(sam); // FAIL
 * </code></pre>
 *
 * @return {@code this} assertion object.
 */
public S usingElementComparatorOnFields(String... fields) {
 return usingElementComparator(new OnFieldsComparator(fields));
}

代码示例来源:origin: org.assertj/assertj-core-java8

@Override
public S usingElementComparator(Comparator<? super T> customComparator) {
  super.usingElementComparator(customComparator);
  lists = new Lists(new ComparatorBasedComparisonStrategy(customComparator));
  return myself;
}

相关文章

微信公众号

最新文章

更多