CommonUtils { public static boolean isValidUrl(String url) { try { return !isNullOrEmpty(new URL(url).getHost()); } catch (MalformedURLException e) { return false; } } private  CommonUtils(); static List<String> getSortedList(Collection<String> collection); static String joinStrings(Iterable<String> strings); static Predicate<String> notEmptyOrNull(); static boolean contains(T item, Collection<T> collection); static boolean contains(T item, T[] array); static void add(Collection<T> collection, T item); static void addAll(Collection<T> left, Collection<T> right); static void removeAll(Collection<T> left, Collection<T> right); static Set<T> intersectionIfNotNull(Set<T> left, Set<T> right); static List<T> nullToEmptyList(List<T> in); static Collection<T> nullToEmptyCollection(Collection<T> in); static Set<T> nullToEmptySet(Set<T> in); static Map<K, V> nullToEmptyMap(Map<K, V> in); static Set<T> toSingletonSet(T in); static String nullToEmptyString(Object in); static Set<String> splitToSet(String value); static int toUnsignedInt(String string); static boolean oneIsNull(Object... objects); static boolean allAreEmptyOrNull(Collection... collections); static boolean allAreEmptyOrNull(Map... maps); static boolean allAreEmptyOrNull(String... strings); static boolean atLeastOneIsNotEmpty(Collection... collections); static boolean atLeastOneIsNotEmpty(Map... maps); static boolean atLeastOneIsNotEmpty(String... strings); static boolean allAreEmpty(Object... objects); static boolean atLeastOneIsNotEmpty(Object... objects); static int compareAsNullsAreSmaller(Object o1, Object o2); static boolean allHaveSameLength(Object... arrays); static Optional<Attachment> getAttachmentOptional(final String attachmentId, Set<Attachment> attachments); @NotNull static Attachment getNewAttachment(User user, String attachmentContentId, String fileName); @NotNull static Comparator<ModerationRequest> compareByTimeStampDescending(); static boolean isInProgressOrPending(ModerationRequest moderationRequest); @NotNull static DocumentState getOriginalDocumentState(); static Optional<ModerationRequest> getFirstModerationRequestOfUser(List<ModerationRequest> moderationRequestsForDocumentId, final String email); @NotNull static DocumentState getModeratedDocumentState(ModerationRequest moderationRequest); static boolean isStillRelevant(ModerationRequest request); static AfterFunction<T, V> afterFunction(Function<V, T> function); static void closeQuietly(Closeable closeable, Logger logger); static boolean isValidUrl(String url); static String getTargetNameOfUrl(String url); static Boolean getBoolOrNull(String in); static Integer getIntegerOrNull(String in); static int getIntOrDefault(String in, int defaultValue); static String getEnumStringOrNull(T val); static Map<String, User> getStringUserMap(UserService.Iface userClient); static void getMessageForRequestSummary(RequestSummary releaseRequestSummary, String typeInfo, StringBuilder stringBuilder); static RequestSummary prepareMessage(RequestSummary input, String info); static RequestStatus reduceRequestStatus(RequestStatus r1, RequestStatus r2); static RequestSummary addToMessage(RequestSummary left, RequestSummary right, String info); @NotNull static RequestSummary addRequestSummaries(RequestSummary left, String typeInfoLeft, RequestSummary right, String typeInfoRight); static ImmutableList<String> getAttachmentURLsFromAttachmentContents(List<AttachmentContent> attachmentContents); static RequestSummary addRequestSummaries(RequestSummary left, RequestSummary right); @NotNull static Map<String, List<String>> getIdentifierToListOfDuplicates(ListMultimap<String, String> identifierToIds); @NotNull static RequestSummary getRequestSummary(List<String> ids, List<DocumentOperationResult> documentOperationResults); static RequestSummary getRequestSummary(int total, int failures); static Properties loadProperties(Class<?> clazz, String propertiesFilePath); static Properties loadProperties(Class<?> clazz, String propertiesFilePath, boolean useSystemConfig); static Optional<byte[]> loadResource(Class<?> clazz, String resourceFilePath); static Optional<byte[]> loadResource(Class<?> clazz, String resourceFilePath, boolean useSystemResourses); static T getFirst(Iterable<T> iterable); static Optional<Attachment> getBestClearingReport(Release release); static boolean isTemporaryTodo(Todo todo); static Optional<T> wrapThriftOptionalReplacement(List<T> thriftOutput); static String formatTime(int seconds); static Map<String, Set<String>> mergeMapIntoMap(Map<String, Set<String>> source, Map<String, Set<String>> destination); static boolean isNullEmptyOrWhitespace(String string); static java.util.function.Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor); static Set<String> getNullToEmptyKeyset(Map<String, ?> map); static Set<String> getNullToEmptyValue(Map<String, Set<String>> map, String key); static Set<String> unifiedKeyset(Map<String, ?>... maps); static boolean isMapFieldMapOfStringSets(U field,
                                                                                                    T document,
                                                                                                    T documentAdditions,
                                                                                                    T documentDeletions,
                                                                                                    Logger logger); static final String SYSTEM_CONFIGURATION_PATH; static final CSVFormat sw360CsvFormat; static final Joiner COMMA_JOINER; static final String TMP_TODO_ID_PREFIX; }
@Test public void testIsUrl() throws Exception { assertThat(isValidUrl("http: }
@Test public void testIsUrl1() throws Exception { assertThat(isValidUrl("www.google.com"), is(false)); }
@Test public void testIsUrl2() throws Exception { assertThat(isValidUrl("ftp: }
@Test public void testIsUrl3() throws Exception { assertThat(isValidUrl("httpwww: }
@Test public void testIsUrl4() throws Exception { assertThat(isValidUrl("http: }
@Test public void testIsUrl5() throws Exception { assertThat(isValidUrl(null), is(false)); }
@Test public void testIsUrl6() throws Exception { assertThat(isValidUrl(""), is(false)); }