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(", ")); }
public String getConcatenatedPath() { return join(path).with("."); } }
public static String extractedDescriptionOf(String... itemsDescription) { return format("Extracted: %s", Strings.join(itemsDescription).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(", ")); }
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(", ")); }
public String get() { if (value == 0) { return "none"; } return Strings.join(parts.values()).with(", "); } }
public String getConcatenatedPath() { return join(path).with("."); } }
public static String extractedDescriptionOf(String... itemsDescription) { return format("Extracted: %s", Strings.join(itemsDescription).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(", ")); }
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 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); }
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 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)); }
@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]"); }
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); } }
public String get() { if (value == 0) { return "none"; } return Strings.join(parts.values()).with(", "); } }
/** * Creates a new {@link JMenuItemMatcher}. * * @param path the path of the menu to match. */ public JMenuItemMatcher(@Nonnull String... path) { this.label = join(path).with(SEPARATOR); }
static String screenshotFileNameFrom(ITestResult result) { String[] parts = namePartsFrom(result); return join(parts).with("."); }
protected <T> T getObjects(TypeReference<T> typeReference, String path, String queryParamName, String... queryParams) throws IOException { String urlString = "http://localhost:" + port + "/test" + path; if (queryParams.length > 0) { urlString += "?" + queryParamName + "=" + Strings.join(queryParams).with("&" + queryParamName + "="); } URL url = new URL(urlString); return reader.forType(typeReference).readValue(url.openStream()); } }