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

x33g5p2x  于2022-01-23 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(89)

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

ListAssert.usingElementComparator介绍

暂无

代码示例

代码示例来源:origin: jdbi/jdbi

private static <T extends Thing> AbstractListAssert<?, ? extends List<? extends T>, T, ?> assertThatThing(List<T> rs) {
    return assertThat(rs).usingElementComparator((Comparator<T>) (left, right) -> {
      if (left.getId() == right.getId()) {
        return Objects.toString(left.getName(), "").compareTo(Objects.toString(right.getName(), ""));
      }
      return left.getId() < right.getId() ? -1 : 1;
    });
  }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void should_timeout() {
 Block block = Block.builder()
  .setBlockHash(new ByteArray("AAAABBBBCCCC"))
  .setResourceId(batchComponent1.key())
  .build();
 index.insert(batchComponent1, Collections.singletonList(block));
 when(executorService.submit(ArgumentMatchers.any(Callable.class))).thenReturn(new CompletableFuture());
 executor.execute(1);
 readDuplications(0);
 assertThat(logTester.logs(LoggerLevel.WARN))
  .usingElementComparator((l, r) -> l.matches(r) ? 0 : 1)
  .containsOnly(
   "Timeout during detection of duplications for .*Foo.php");
}

代码示例来源:origin: net.rakugakibox.spring.boot/logback-access-spring-boot-starter

/**
 * Verifies that the response header names does not have contain the given one.
 *
 * @param name the response header name.
 * @return this instance.
 * @see IAccessEvent#getResponseHeaderNameList()
 */
public S doesNotHaveResponseHeaderName(String name) {
  List<String> actualResponseHeaderNames = actual.getResponseHeaderNameList();
  Assertions.assertThat(actualResponseHeaderNames)
      .usingElementComparator(String.CASE_INSENSITIVE_ORDER)
      .doesNotContain(name);
  return myself;
}

代码示例来源:origin: net.rakugakibox.spring.boot/logback-access-spring-boot-starter

/**
 * Verifies that the request header names contains the given one.
 *
 * @param name the request header name.
 * @return this instance.
 * @see IAccessEvent#getRequestHeaderNames()
 */
public S hasRequestHeaderName(String name) {
  Enumeration<String> actualRequestHeaderNamesAsEnumeration = actual.getRequestHeaderNames();
  List<String> actualRequestHeaderNames = list(actualRequestHeaderNamesAsEnumeration);
  Assertions.assertThat(actualRequestHeaderNames)
      .usingElementComparator(String.CASE_INSENSITIVE_ORDER)
      .contains(name);
  return myself;
}

代码示例来源:origin: net.rakugakibox.spring.boot/logback-access-spring-boot-starter

/**
 * Verifies that the request header names does not have contain the given one.
 *
 * @param name the request header name.
 * @return this instance.
 * @see IAccessEvent#getRequestHeaderNames()
 */
public S doesNotHaveRequestHeaderName(String name) {
  Enumeration<String> actualRequestHeaderNamesAsEnumeration = actual.getRequestHeaderNames();
  List<String> actualRequestHeaderNames = list(actualRequestHeaderNamesAsEnumeration);
  Assertions.assertThat(actualRequestHeaderNames)
      .usingElementComparator(String.CASE_INSENSITIVE_ORDER)
      .doesNotContain(name);
  return myself;
}

代码示例来源:origin: net.rakugakibox.spring.boot/logback-access-spring-boot-starter

/**
 * Verifies that the response header names contains the given one.
 *
 * @param name the response header name.
 * @return this instance.
 * @see IAccessEvent#getResponseHeaderNameList()
 */
public S hasResponseHeaderName(String name) {
  List<String> actualResponseHeaderNames = actual.getResponseHeaderNameList();
  Assertions.assertThat(actualResponseHeaderNames)
      .usingElementComparator(String.CASE_INSENSITIVE_ORDER)
      .contains(name);
  return myself;
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void shouldCreateObservationsFromTimer() {
 final OperationTimer timer = metricsSystem.createTimer(RPC, "request", "Some help");
 final TimingContext context = timer.startTimer();
 context.stopTimer();
 assertThat(metricsSystem.getMetrics())
   .usingElementComparator(IGNORE_VALUES)
   .containsExactlyInAnyOrder(
     new Observation(RPC, "request", null, asList("quantile", "0.2")),
     new Observation(RPC, "request", null, asList("quantile", "0.5")),
     new Observation(RPC, "request", null, asList("quantile", "0.8")),
     new Observation(RPC, "request", null, asList("quantile", "0.95")),
     new Observation(RPC, "request", null, asList("quantile", "0.99")),
     new Observation(RPC, "request", null, asList("quantile", "1.0")),
     new Observation(RPC, "request", null, singletonList("sum")),
     new Observation(RPC, "request", null, singletonList("count")));
}

代码示例来源:origin: PegaSysEng/pantheon

@Test
public void shouldCreateObservationsFromTimerWithLabels() {
 final LabelledMetric<OperationTimer> timer =
   metricsSystem.createLabelledTimer(RPC, "request", "Some help", "methodName");
 try (final TimingContext context = timer.labels("method").startTimer()) {}
 assertThat(metricsSystem.getMetrics())
   .usingElementComparator(IGNORE_VALUES) // We don't know how long it will actually take.
   .containsExactlyInAnyOrder(
     new Observation(RPC, "request", null, asList("method", "quantile", "0.2")),
     new Observation(RPC, "request", null, asList("method", "quantile", "0.5")),
     new Observation(RPC, "request", null, asList("method", "quantile", "0.8")),
     new Observation(RPC, "request", null, asList("method", "quantile", "0.95")),
     new Observation(RPC, "request", null, asList("method", "quantile", "0.99")),
     new Observation(RPC, "request", null, asList("method", "quantile", "1.0")),
     new Observation(RPC, "request", null, asList("method", "sum")),
     new Observation(RPC, "request", null, asList("method", "count")));
}

代码示例来源:origin: dhleong/intellivim

public void testSubClass() {
  SimpleResult result = getImplementablesAt(161);
  assertSuccess(result);
  final Implementables impl = result.getResult();
  assertThat(impl)
      .extracting("description", CharSequence.class)
        .usingElementComparator(charSequenceComparator)
        .contains("public void normalMethod()")
        .contains("public abstract void abstractMethod()");
}

代码示例来源:origin: dhleong/intellivim

public void testNestedClass() {
  SimpleResult result = getImplementablesAt(153);
  assertSuccess(result);
  // this nested class extends Dummy
  final Implementables impl = result.getResult();
  assertThat(impl)
      .extracting("description", CharSequence.class)
        .usingElementComparator(charSequenceComparator)
        .contains("public void boring()")
        .contains("public Dummy fluid()")
        .contains("public void notBoring(int number)");
}

相关文章

微信公众号

最新文章

更多

ListAssert类方法