BranchNotificationMessageBuilderSlack { String getSummaryString(List<String> strings) { return strings.stream() .limit(STRING_IN_SUMMARY_COUNT) .map(s -> StringUtils.abbreviate(s, STRING_IN_SUMMARY_ABRREVIATE_LENGHT)) .collect(Collectors.joining(", ")); }  Message getNewMessage(String channel, String pr, List<String> sourceStrings); Message getUpdatedMessage(String channel, String threadTs, String pr, List<String> sourceStrings); Message getTranslatedMessage(String channel, String threadTs); Message getScreenshotMissingMessage(String channel, String threadTs);  }
@Test public void testGetSummaryString() { List<String> strings = new ArrayList<>(); strings.add("string 1"); strings.add("very long string 2 ---------------------------------------------------------"); for (int i = 3; i < 30; i++) { strings.add("s" + i); } String summaryString = branchNotificationMessageBuilderSlack.getSummaryString(strings); assertEquals("string 1, very long string 2 ------------------..., s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20", summaryString); }
@Test public void testGetSummaryString1Element() { String summaryString = branchNotificationMessageBuilderSlack.getSummaryString(Arrays.asList("string 1")); assertEquals("string 1", summaryString); }