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

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

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

ListAssert.overridingErrorMessage介绍

暂无

代码示例

代码示例来源:origin: t28hub/json2java4idea

@Nonnull
public MethodSpecAssert hasNoParameter() {
  isNotNull();
  final List<ParameterSpec> actual = this.actual.parameters;
  Assertions.assertThat(actual)
      .overridingErrorMessage("Expected parameters to be empty, but was <%s>", actual)
      .isEmpty();
  return this;
}

代码示例来源:origin: t28hub/json2java4idea

@Nonnull
public FieldSpecAssert hasNoAnnotation() {
  isNotNull();
  final List<AnnotationSpec> actual = this.actual.annotations;
  Assertions.assertThat(actual)
      .overridingErrorMessage("Expected annotation to be empty, but was <%s>", actual)
      .isEmpty();
  return this;
}

代码示例来源:origin: t28hub/json2java4idea

@Nonnull
public MethodSpecAssert hasNoException() {
  isNotNull();
  final List<TypeName> actual = this.actual.exceptions;
  Assertions.assertThat(actual)
      .overridingErrorMessage("Expected exception to be empty, but was <%s>", actual)
      .isEmpty();
  return this;
}

代码示例来源:origin: t28hub/json2java4idea

@Nonnull
public MethodSpecAssert hasNoAnnotation() {
  isNotNull();
  final List<AnnotationSpec> actual = this.actual.annotations;
  Assertions.assertThat(actual)
      .overridingErrorMessage("Expected annotation to be empty, but was <%s>", actual)
      .isEmpty();
  return this;
}

代码示例来源:origin: t28hub/json2java4idea

@Nonnull
public MethodSpecAssert hasAnnotation(@Nonnull AnnotationSpec expected) {
  isNotNull();
  final List<AnnotationSpec> actual = this.actual.annotations;
  Assertions.assertThat(actual)
      .overridingErrorMessage("Expecting <%s> to contain but could not find <%s>", actual, expected)
      .contains(expected);
  return this;
}

代码示例来源:origin: t28hub/json2java4idea

@Nonnull
public MethodSpecAssert hasParameter(@Nonnull ParameterSpec expected) {
  isNotNull();
  final List<ParameterSpec> actual = this.actual.parameters;
  Assertions.assertThat(actual)
      .overridingErrorMessage("Expecting <%s> to contain but could not find <%s>", actual, expected)
      .contains(expected);
  return this;
}

代码示例来源:origin: t28hub/json2java4idea

@Nonnull
  public TypeSpecAssert hasAnnotation(@Nonnull AnnotationSpec expected) {
    isNotNull();

    final List<AnnotationSpec> actual = this.actual.annotations;
    Assertions.assertThat(actual)
        .overridingErrorMessage("Expecting <%s> to contain but could not find <%s>", actual, expected)
        .contains(expected);

    return this;
  }
}

代码示例来源:origin: t28hub/json2java4idea

@Nonnull
public FieldSpecAssert hasAnnotation(@Nonnull AnnotationSpec expected) {
  isNotNull();
  final List<AnnotationSpec> actual = this.actual.annotations;
  Assertions.assertThat(actual)
      .overridingErrorMessage("Expecting <%s> to contain but could not find <%s>", actual, expected)
      .contains(expected);
  return this;
}

代码示例来源:origin: eclipse/ditto

public DittoHeadersAssert hasNoAuthorizationSubjects() {
  isNotNull();
  final List<String> actualAuthorizationSubjects = actual.getAuthorizationSubjects();
  Assertions.assertThat(actualAuthorizationSubjects)
      .overridingErrorMessage("Expected DittoHeaders not to have authorization subjects but it had <%s>",
          actualAuthorizationSubjects)
      .isEmpty();
  return myself;
}

代码示例来源:origin: eclipse/ditto

/**
 * Verifies that the JSON object contains all specified keys.
 *
 * @param expectedJsonKey the mandatory key whose existence is checked.
 * @param furtherExpectedJsonKeys further optional keys whose existence in the JSON object is checked.
 * @return this assertion object.
 */
public JsonObjectAssert containsKey(final CharSequence expectedJsonKey,
    final CharSequence... furtherExpectedJsonKeys) {
  isNotNull();
  final Collection<CharSequence> allExpectedJsonKeys = new ArrayList<>(1 + furtherExpectedJsonKeys.length);
  allExpectedJsonKeys.add(expectedJsonKey);
  Collections.addAll(allExpectedJsonKeys, furtherExpectedJsonKeys);
  final List<CharSequence> missingKeys = new ArrayList<>();
  for (final CharSequence jsonKey : allExpectedJsonKeys) {
    if (!actual.contains(jsonKey)) {
      missingKeys.add(jsonKey);
    }
  }
  Assertions.assertThat(missingKeys)
      .overridingErrorMessage("Expected JSON object to contain key(s) <%s> but it did not contain <%s>",
          allExpectedJsonKeys, missingKeys)
      .isEmpty();
  return myself;
}

代码示例来源:origin: io.holunda.testing/camunda-bpm-assert

private ProcessInstanceAssert isWaitingFor(final String[] messageNames, boolean isWaitingFor) {
 isNotNull();
 Assertions.assertThat(messageNames)
  .overridingErrorMessage("Expecting list of messageNames not to be null, not to be empty and not to contain null values: %s."
   , Lists.newArrayList(messageNames))
  .isNotNull().isNotEmpty().doesNotContainNull();
 for (String messageName : messageNames) {
  List<Execution> executions = executionQuery().messageEventSubscriptionName(messageName).list();
  ListAssert<Execution> assertion = Assertions.assertThat(executions).overridingErrorMessage("Expecting %s " +
    (isWaitingFor ? "to be waiting for %s, " : "NOT to be waiting for %s, ") +
    "but actually did " + (isWaitingFor ? "not " : "") + "find it to be waiting for message [%s].",
   actual, Arrays.asList(messageNames), messageName);
  if (isWaitingFor) {
   assertion.isNotEmpty();
  } else {
   assertion.isEmpty();
  }
 }
 return this;
}

代码示例来源:origin: eclipse/ditto

public void containsAuthorizationSubject(final String... expectedAuthSubject) {
  final DittoHeaders actualDittoHeaders = actual.getDittoHeaders();
  final List<String> actualAuthorizationSubjects = actualDittoHeaders.getAuthorizationSubjects();
  Assertions.assertThat(actualAuthorizationSubjects)
      .overridingErrorMessage("Expected command headers to contain <%s> but it did not", expectedAuthSubject)
      .contains(expectedAuthSubject);
}

代码示例来源:origin: eclipse/ditto

/**
 * Verifies that the actual JSON pointer does not contain the specified key(s).
 *
 * @param unexpectedKey the key which should not be contained in the JSON pointer.
 * @param furtherUnexpectedKeys further keys which should not be contained in the JSON pointer.
 * @return this assert to allow method chaining.
 */
public JsonPointerAssert doesNotContainKey(final CharSequence unexpectedKey,
    final CharSequence... furtherUnexpectedKeys) {
  isNotNull();
  final List<CharSequence> allUnexpectedKeys = merge(unexpectedKey, furtherUnexpectedKeys);
  final List<CharSequence> existingKeys = new ArrayList<>();
  for (final CharSequence unexpKey : allUnexpectedKeys) {
    if (containsKey(unexpectedKey)) {
      existingKeys.add(unexpKey);
    }
  }
  Assertions.assertThat(existingKeys)
      .overridingErrorMessage("Expected JSON pointer not to contain key(s) <%s> but it contained <%s>",
          allUnexpectedKeys, existingKeys)
      .isEmpty();
  return myself;
}

代码示例来源:origin: org.camunda.bpm.incubation/camunda-bpm-assert

private ProcessInstanceAssert isWaitingAt(final String[] activityIds, boolean exactly) {
 ProcessInstance current = getExistingCurrent();
 Assertions.assertThat(activityIds)
  .overridingErrorMessage("Expecting list of activityIds not to be null, not to be empty and not to contain null values: %s."
   , Lists.newArrayList(activityIds))
  .isNotNull().isNotEmpty().doesNotContainNull();
 final List<String> activeActivityIds = runtimeService().getActiveActivityIds(actual.getId());
 ListAssert<String> assertion = Assertions.assertThat(activeActivityIds)
  .overridingErrorMessage("Expecting %s to be waiting at '%s' but it is actually waiting at %s", 
   toString(current),
   Lists.newArrayList(activityIds), 
   activeActivityIds);
 if (exactly) {
  String[] sorted = activityIds.clone();
  Arrays.sort(sorted);
  assertion.containsExactly(sorted);
 } else {
  assertion.contains(activityIds);
 }
 return this;
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void queryByNameScenario() {
  assertModelsNotPresent();
  final List<Product> instances = createInBackendByName(modelNames());
  final List<String> actualNames = instances.stream().map(o -> extractName(o)).
      filter(name -> modelNames().contains(name)).sorted().collect(toList());
  final StringJoiner joiner = new StringJoiner(", ");
  modelNames().forEach(item -> joiner.add(item.toString()));
  assertThat(actualNames).
      overridingErrorMessage(String.format("The test requires instances with the names %s.", "[" + joiner.toString() + "]")).
      isEqualTo(modelNames());
  final String nameToFind = modelNames().get(1);
  final List<Product> results = client().executeBlocking(queryObjectForName(nameToFind)).getResults();
  assertThat(results).hasSize(1);
  assertThat(getNames(results)).isEqualTo(asList(nameToFind));
  assertModelsNotPresent();
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void plusExpansionPathDemo() throws Exception {
  final ProductProjectionByIdGet fetch = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT);
  assertThat(fetch.expansionPaths()).isEmpty();
  final ProductProjectionByIdGet fetch2 =
      fetch.plusExpansionPaths(ProductProjectionExpansionModel.of().categories());
  assertThat(fetch.expansionPaths()).overridingErrorMessage("old object is unchanged").isEmpty();
  assertThat(fetch2.expansionPaths()).isEqualTo(asList(ExpansionPath.of("categories[*]")));
  assertThat(fetch2).isNotSameAs(fetch);
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void withExpansionPathDslDemo() throws Exception {
  final ProductProjectionByIdGet fetch = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT)
          .plusExpansionPaths(ProductProjectionExpansionModel.of().categories());
  assertThat(fetch.expansionPaths())
      .isEqualTo(asList(ExpansionPath.of("categories[*]")));
  final ProductProjectionByIdGet fetch2 =
      fetch.withExpansionPaths(m -> m.productType());
  assertThat(fetch.expansionPaths()).overridingErrorMessage("old object is unchanged")
      .isEqualTo(asList(ExpansionPath.of("categories[*]")));
  assertThat(fetch2.expansionPaths()).isEqualTo(asList(ExpansionPath.of("productType")));
  assertThat(fetch2).isNotSameAs(fetch);
}

代码示例来源:origin: eclipse/ditto

/**
 * Verifies that the actual JSON object contains the expected value for the specified key.
 *
 * @param key the key of the expected value.
 * @param expectedValue the expected value to be associated with {@code key}.
 * @return this assert to allow method chaining.
 */
public JsonObjectAssert contains(final JsonKey key, final JsonValue expectedValue) {
  isNotNull();
  final List<JsonKey> actualNames = actual.getKeys();
  Assertions.assertThat(actualNames).contains(key)
      .overridingErrorMessage("Expected JSON object to contain a field with name <%s> but it did not.",
          key);
  final Optional<JsonValue> actualValue = actual.getValue(key);
  assertThat(actualValue)
      .overridingErrorMessage("Expected JSON object to contain value <%s> for key <%s> but the actual value" +
          " was <%s>", expectedValue, key, actualValue.orElse(null))
      .contains(expectedValue);
  return this;
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void withExpansionPathDemo() throws Exception {
  final ProductProjectionByIdGet fetch = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT)
          .withExpansionPaths(ProductProjectionExpansionModel.of().categories());
  assertThat(fetch.expansionPaths())
      .isEqualTo(asList(ExpansionPath.of("categories[*]")));
  final ProductProjectionByIdGet fetch2 =
      fetch.withExpansionPaths(ProductProjectionExpansionModel.of().productType());
  assertThat(fetch.expansionPaths()).overridingErrorMessage("old object is unchanged")
      .isEqualTo(asList(ExpansionPath.of("categories[*]")));
  assertThat(fetch2.expansionPaths()).isEqualTo(asList(ExpansionPath.of("productType")));
  assertThat(fetch2).isNotSameAs(fetch);
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

private void assertModelsNotPresent() {
    cleanUpByName(modelNames());
    assertThat(getNames(client().executeBlocking(queryRequestForQueryAll()).getResults())).overridingErrorMessage("the instances with the names " + modelNames() + " should not be present.").doesNotContainAnyElementsOf(modelNames());
  }
}

相关文章

微信公众号

最新文章

更多

ListAssert类方法