@Test public void getFirstWords5_Null() { String sentence = null; String expectedResult = ""; String actualResult = TranscribeUtils.getFirstWords(sentence, 5); assertEquals(expectedResult, actualResult); }
public static String getFirstWords(String text, int numberOfWords) { if (text != null) { String[] words = StringUtils.split(text, " "); return words.length > numberOfWords ? StringUtils.join(words, " ", 0, numberOfWords) + " ..." : StringUtils.join(words, " ", 0, words.length); } return ""; }
TranscribeUtils { public static String getFirstWords(String text, int numberOfWords) { if (text != null) { String[] words = StringUtils.split(text, " "); return words.length > numberOfWords ? StringUtils.join(words, " ", 0, numberOfWords) + " ..." : StringUtils.join(words, " ", 0, words.length); } return ""; } }
TranscribeUtils { public static String getFirstWords(String text, int numberOfWords) { if (text != null) { String[] words = StringUtils.split(text, " "); return words.length > numberOfWords ? StringUtils.join(words, " ", 0, numberOfWords) + " ..." : StringUtils.join(words, " ", 0, words.length); } return ""; }  }
TranscribeUtils { public static String getFirstWords(String text, int numberOfWords) { if (text != null) { String[] words = StringUtils.split(text, " "); return words.length > numberOfWords ? StringUtils.join(words, " ", 0, numberOfWords) + " ..." : StringUtils.join(words, " ", 0, words.length); } return ""; }  static String getFirstWords(String text, int numberOfWords); static String extractMediaType(String mimeType); static Predicate<T> distinctByProperty(Function<? super T, ?> propertyExtractor); static List<TranscribeItem> clone(List<TranscribeItem> items); static String getText(List<TranscribeItem> items); }
TranscribeUtils { public static String getFirstWords(String text, int numberOfWords) { if (text != null) { String[] words = StringUtils.split(text, " "); return words.length > numberOfWords ? StringUtils.join(words, " ", 0, numberOfWords) + " ..." : StringUtils.join(words, " ", 0, words.length); } return ""; }  static String getFirstWords(String text, int numberOfWords); static String extractMediaType(String mimeType); static Predicate<T> distinctByProperty(Function<? super T, ?> propertyExtractor); static List<TranscribeItem> clone(List<TranscribeItem> items); static String getText(List<TranscribeItem> items);  }