本文整理了Java中org.assertj.core.api.IterableAssert.overridingErrorMessage()
方法的一些代码示例,展示了IterableAssert.overridingErrorMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IterableAssert.overridingErrorMessage()
方法的具体详情如下:
包路径:org.assertj.core.api.IterableAssert
类名称:IterableAssert
方法名:overridingErrorMessage
暂无
代码示例来源:origin: SonarSource/sonar-java
private void assertNoIssues(Set<AnalyzerMessage> issues, boolean bypass) {
assertThat(issues).overridingErrorMessage("No issues expected but got: " + issues).isEmpty();
if (!bypass) {
// make sure we do not copy&paste verifyNoIssue call when we intend to call verify
assertThat(expected.isEmpty()).overridingErrorMessage("The file should not declare noncompliants when no issues are expected").isTrue();
}
}
}
代码示例来源:origin: KrailOrg/krail
private void testForJavaxAnnotation(Class<? extends Annotation> annotation) {
Reflections reflections = new Reflections("");
Set<Class<?>> googleInjects = reflections.getTypesAnnotatedWith(annotation);
String outputMsg = "Testing for incorrect use of " + annotation.getName();
if (!googleInjects.isEmpty()) {
StringBuilder buf = new StringBuilder();
for (Class<?> clazz : googleInjects) {
buf.append(clazz.getName());
buf.append(";");
}
outputMsg = buf.toString();
}
assertThat(googleInjects).hasSize(0)
.overridingErrorMessage(outputMsg);
}
代码示例来源:origin: t28hub/json2java4idea
@Nonnull
public MethodSpecAssert hasModifier(@Nonnull Modifier... expected) {
isNotNull();
final Set<Modifier> actual = this.actual.modifiers;
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 hasModifier(@Nonnull Modifier... expected) {
isNotNull();
final Set<Modifier> actual = this.actual.modifiers;
Assertions.assertThat(actual)
.overridingErrorMessage("Expected modifier to be <%s>, but was <%s>", expected, actual)
.contains(expected);
return this;
}
代码示例来源:origin: eclipse/ditto
public ThingAssert hasFeatureProperties(final String featureId, final FeatureProperties expectedFeatureProperties) {
isNotNull();
final FeatureProperties actualProperties = actual.getFeatures() //
.flatMap(features -> features.getFeature(featureId)) //
.flatMap(Feature::getProperties) //
.orElse(null);
assertThat(actualProperties) //
.overridingErrorMessage("Expected Thing Feature <%s> to have the properties \n<%s> but it had \n<%s>",
featureId, expectedFeatureProperties, actualProperties) //
.isEqualTo(expectedFeatureProperties);
return this;
}
代码示例来源:origin: eclipse/ditto
public DittoHeadersAssert hasAuthorizationContext(final AuthorizationContext expectedAuthorizationContext) {
isNotNull();
final AuthorizationContext actualAuthorizationContext = actual.getAuthorizationContext();
Assertions.assertThat(actualAuthorizationContext)
.overridingErrorMessage("Expected AuthorizationContext of DittoHeaders to be\n<%s> but it " +
"was\n<%s>", expectedAuthorizationContext, actualAuthorizationContext)
.isEqualTo(expectedAuthorizationContext);
return myself;
}
代码示例来源:origin: eclipse/ditto
public DittoHeadersAssert hasNoReadSubjects() {
isNotNull();
final Set<String> actualReadSubjects = actual.getReadSubjects();
Assertions.assertThat(actualReadSubjects)
.overridingErrorMessage("Expected DittoHeaders not to have read subjects but it had <%s>",
actualReadSubjects)
.isEmpty();
return myself;
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void createByMap() {
final Map<Locale, String> map = new HashMap<>();
map.put(Locale.GERMAN, "Hundefutter");
map.put(Locale.ENGLISH, "dog food");
final LocalizedString ls = LocalizedString.of(map);
assertThat(ls.getLocales()).containsExactly(Locale.GERMAN, Locale.ENGLISH);
assertThat(ls).isEqualTo(LocalizedString.of(Locale.GERMAN, "Hundefutter", Locale.ENGLISH, "dog food"));
map.remove(Locale.GERMAN);
map.put(Locale.forLanguageTag("es"), "Comida para perro");
assertThat(ls.getLocales())
.overridingErrorMessage("changes in the creation map do not change the created object")
.containsExactly(Locale.GERMAN, Locale.ENGLISH);
assertThat(ls).isEqualTo(LocalizedString.of(Locale.GERMAN, "Hundefutter", Locale.ENGLISH, "dog food"));
assertThat(ls.get(Locale.GERMAN)).isEqualTo("Hundefutter");
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void createHierarchy() throws Exception {
final List<Category> allCategories = createCategoryHierarchyAsFlatList();
final CategoryTree tree = CategoryTree.of(allCategories);
assertThat(extractIdSet(tree.getAllAsFlatList()))
.overridingErrorMessage("all categories are present").isEqualTo(extractIdSet(allCategories));
assertThat(extractIdSet(tree.getRoots()))
.isEqualTo(new HashSet<>(rootIds));
final List<Category> nameSortedRoots = byNameSorted(tree);
final Category category0 = nameSortedRoots.get(0);
assertThat(category0.getId()).isEqualTo(rootIds.get(0));
final List<Category> childrenOf0 = tree.findChildren(category0);
assertThat(childrenOf0).hasSize(childIds.size());
final List<Category> sortedChildren = childrenOf0.stream().sorted(byNameComparator).collect(toList());
assertThat(sortedChildren.get(1).getId()).isEqualTo("0b");
final List<Category> sortedGrandChildren = tree.findChildren(sortedChildren.get(1)).stream().sorted(byNameComparator).collect(toList());
assertThat(extractIdList(sortedGrandChildren)).isEqualTo(asList("0bu", "0bv", "0bw", "0bx"));
}
代码示例来源:origin: KrailOrg/krail
.overridingErrorMessage(outputMsg);
代码示例来源:origin: eclipse/ditto
public PolicyAssert hasLabel(final Label expectedLabel) {
isNotNull();
assertThat(actual.getLabels()).contains(expectedLabel) //
.overridingErrorMessage("Expected Labels to contain \n<%s> but did not: \n<%s>", expectedLabel,
actual.getLabels());
return this;
}
代码示例来源:origin: eclipse/ditto
public PolicyAssert doesNotHaveLabel(final Label expectedLabel) {
isNotNull();
assertThat(actual.getLabels()).doesNotContain(expectedLabel) //
.overridingErrorMessage("Expected Labels to NOT contain \n<%s> but it did: \n<%s>", expectedLabel,
actual.getLabels());
return this;
}
代码示例来源:origin: eclipse/ditto
private void isEqualTo(final Iterable<JsonField> expectedFields, final boolean compareFieldDefinitions) {
isNotNull();
final Collection<JsonField> missingFields = new ArrayList<>();
for (final JsonField expectedField : expectedFields) {
final Optional<JsonField> actualFieldOptional = actual.getField(expectedField.getKey());
if (!actualFieldOptional.isPresent()) {
missingFields.add(expectedField);
} else {
compareFields(expectedField, actualFieldOptional.get(), compareFieldDefinitions);
}
}
Assertions.assertThat(missingFields)
.overridingErrorMessage("Expected JSON object to contain \n<%s> but it did not contain \n<%s>",
expectedFields, missingFields)
.isEmpty();
final Collection<JsonField> unexpectedActualFields = new ArrayList<>();
for (final JsonField actualField : actual) {
final Optional<JsonField> expectedFieldOptional = getField(expectedFields, actualField.getKey());
if (!expectedFieldOptional.isPresent()) {
unexpectedActualFields.add(actualField);
}
}
Assertions.assertThat(unexpectedActualFields)
.overridingErrorMessage("Expected JSON object not to contain\n<%s> but it did", unexpectedActualFields)
.isEmpty();
}
代码示例来源:origin: com.qualinsight.libs.sonarqube/qualinsight-libs-sonarqube-test
/**
* Asserts that a {@link JavaCheck} will raise the expected issue provided as method parameter, and not more. Expected issues are provided as a parameter.
*
* @see ExpectedIssuesCollector
* @param testFileName the name of the test file that has to be checked for issues
* @param check the {@link JavaCheck} that is to be run against the test file
* @param expectedLine the line number on which the issue message is expected (or 0 if it is a file wide issue)
* @param expectedMessage the expected message
*/
public static void assertHasSingleIssue(final String testFileName, final JavaFileScanner check, @Nonnull @Nonnegative final Integer expectedLine, final String expectedMessage) {
final TreeMultimap<Integer, String> actualIssues = ActualIssuesCollector.collect(new File(testFileName), check);
final SoftAssertions softly = new SoftAssertions();
softly.assertThat(actualIssues.get(expectedLine))
.overridingErrorMessage(EXPECTED_MESSAGE_PREFIX, formatIssue(expectedLine, expectedMessage))
.contains(expectedMessage);
actualIssues.remove(expectedLine, expectedMessage);
softly.assertThat(actualIssues.size())
.overridingErrorMessage(UNEXPECTED_MESSAGE_PREFIX, formatIssues(actualIssues))
.isEqualTo(0);
softly.assertAll();
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
assertThat(result.head().map(e -> e.getId())).contains(entry.getId());
assertThat(result.head().get().getSupplyChannel().getObj().getRoles())
.overridingErrorMessage("can expand supplyChannel reference")
.contains(channelRole);
return entry;
内容来源于网络,如有侵权,请联系作者删除!