protected String describeFieldComparatorsByName() { if (comparatorsByPropertyOrField.isEmpty()) { return ""; } List<String> fieldComparatorsDescription = this.comparatorsByPropertyOrField.entrySet().stream() .map(FieldByFieldComparator::formatFieldComparator) .collect(toList()); return format("- for elements fields (by name): {%s}", join(fieldComparatorsDescription).with(", ")); }
protected String describeFieldComparatorsByName() { if (comparatorsByPropertyOrField.isEmpty()) { return ""; } List<String> fieldComparatorsDescription = this.comparatorsByPropertyOrField.entrySet().stream() .map(FieldByFieldComparator::formatFieldComparator) .collect(toList()); return format("- for elements fields (by name): {%s}", join(fieldComparatorsDescription).with(", ")); }
@Override public String toString() { List<String> registeredComparatorsDescription = new ArrayList<>(); for (Entry<Class<?>, Comparator<?>> registeredComparator : this.typeComparators.entrySet()) { registeredComparatorsDescription.add(formatRegisteredComparator(registeredComparator)); } return format("{%s}", join(registeredComparatorsDescription).with(", ")); }
/** * Specifies the delimiter to use to join {@code String}s. * * @param delimiter the delimiter to use. * @return the {@code String}s joined using the given delimiter. */ public String with(String delimiter) { return with(delimiter, null); }
public String get() { if (value == 0) { return "none"; } return Strings.join(parts.values()).with(", "); } }
private void assertDescriptorsNotPresentInFile(File logFile) { try { List<String> contents = Files.readAllLines(logFile.toPath()); String result = Strings.join(contents).with("\n"); assertThat(result).doesNotContain(DESCRIPTOR_1.getLockIdAsString()); assertThat(result).doesNotContain(DESCRIPTOR_2.getLockIdAsString()); } catch (IOException e) { throw new RuntimeException(e); } }
private static String describeDifference(Difference difference, Representation representation) { String actualFieldValue = representation.toStringOf(difference.getActual()); String otherFieldValue = representation.toStringOf(difference.getOther()); boolean sameRepresentation = Objects.areEqual(actualFieldValue, otherFieldValue); String actualFieldValueRepresentation = sameRepresentation ? representation.unambiguousToStringOf(difference.getActual()) : actualFieldValue; String otherFieldValueRepresentation = sameRepresentation ? representation.unambiguousToStringOf(difference.getOther()) : otherFieldValue; String additionalInfo = difference.getDescription() .map(desc -> format("%n- reason : %s", escapePercent(desc))) .orElse(""); return format("%nPath to difference: <%s>%n" + "- actual : <%s>%n" + "- expected: <%s>" + additionalInfo, join(difference.getPath()).with("."), escapePercent(actualFieldValueRepresentation), escapePercent(otherFieldValueRepresentation)); }
private static String directionToString(@GridLayoutAnimationControllerDirection int direction) { List<String> parts = new ArrayList<>(); int horizontal = direction & DIRECTION_HORIZONTAL_MASK; int vertical = direction & DIRECTION_VERTICAL_MASK; if ((horizontal & DIRECTION_RIGHT_TO_LEFT) != 0) { parts.add("rightToLeft"); } else { parts.add("leftToRight"); } if ((vertical & DIRECTION_BOTTOM_TO_TOP) != 0) { parts.add("bottomToTop"); } else { parts.add("topToBottom"); } return Strings.join(parts).with(", "); }
public static ErrorMessageFactory shouldBeEqualByComparingFieldByFieldRecursive(Object actual, Object other, List<Difference> differences, Representation representation) { List<String> descriptionOfDifferences = differences.stream() .map(difference -> describeDifference(difference, representation)) .collect(toList()); return new ShouldBeEqualByComparingFieldByFieldRecursively("%n" + "Expecting:%n" + " <%s>%n" + "to be equal to:%n" + " <%s>%n" + "when recursively comparing field by field, but found the following difference(s):%n" + join(descriptionOfDifferences).with(format("%n")), actual, other); }
public static String extractedDescriptionOf(String... itemsDescription) { return format("Extracted: %s", Strings.join(itemsDescription).with(", ")); }
public String get() { if (value == 0) { return "none"; } return Strings.join(parts.values()).with(", "); } }
public String getConcatenatedPath() { return join(path).with("."); } }
private static String describeDifference(Difference difference, Representation representation) { String actualFieldValue = representation.toStringOf(difference.getActual()); String otherFieldValue = representation.toStringOf(difference.getOther()); boolean sameRepresentation = Objects.areEqual(actualFieldValue, otherFieldValue); String actualFieldValueRepresentation = sameRepresentation ? representation.unambiguousToStringOf(difference.getActual()) : actualFieldValue; String otherFieldValueRepresentation = sameRepresentation ? representation.unambiguousToStringOf(difference.getOther()) : otherFieldValue; String additionalInfo = difference.getDescription() .map(desc -> format("%n- reason : %s", escapePercent(desc))) .orElse(""); return format("%nPath to difference: <%s>%n" + "- actual : <%s>%n" + "- expected: <%s>" + additionalInfo, join(difference.getPath()).with("."), escapePercent(actualFieldValueRepresentation), escapePercent(otherFieldValueRepresentation)); }
/** * Specifies the delimiter to use to join {@code String}s. * * @param delimiter the delimiter to use. * @return the {@code String}s joined using the given delimiter. */ public String with(String delimiter) { return with(delimiter, null); }
@Test public void testExecuteFunctionOnMultipleMembers() { gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION1 + " --member=" + Strings.join(server1.getName(), server2.getName()).with(",")).statusIsSuccess() .tableHasColumnWithValuesContaining("Member", server1.getName(), server2.getName()) .tableHasColumnWithExactValuesInAnyOrder(RESULT_HEADER, "[false]", "[false]"); }
@Override public String toString() { List<String> registeredComparatorsDescription = new ArrayList<>(); for (Entry<Class<?>, Comparator<?>> registeredComparator : this.typeComparators.entrySet()) { registeredComparatorsDescription.add(formatRegisteredComparator(registeredComparator)); } return format("{%s}", join(registeredComparatorsDescription).with(", ")); }
public static ErrorMessageFactory shouldBeEqualByComparingFieldByFieldRecursive(Object actual, Object other, List<Difference> differences, Representation representation) { List<String> descriptionOfDifferences = differences.stream() .map(difference -> describeDifference(difference, representation)) .collect(toList()); return new ShouldBeEqualByComparingFieldByFieldRecursively("%n" + "Expecting:%n" + " <%s>%n" + "to be equal to:%n" + " <%s>%n" + "when recursively comparing field by field, but found the following difference(s):%n" + join(descriptionOfDifferences).with(format("%n")), actual, other); }
public static String extractedDescriptionOf(String... itemsDescription) { return format("Extracted: %s", Strings.join(itemsDescription).with(", ")); }
public String getConcatenatedPath() { return join(path).with("."); } }
/** * Specifies the delimiter to use to join {@code String}s. * * @param delimiter the delimiter to use. * @return the {@code String}s joined using the given delimiter. */ public String with(String delimiter) { return with(delimiter, null); }