Skip to content

Commit

Permalink
Remove guava dep from logging package
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jul 8, 2018
1 parent 61f35cf commit 5a8b480
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 19 deletions.
3 changes: 1 addition & 2 deletions java/client/src/org/openqa/selenium/logging/BUCK
Expand Up @@ -25,9 +25,8 @@ java_library(name = 'logging',
'//java/client/src/org/openqa/selenium:beta',
'//java/client/src/org/openqa/selenium:exceptions',
'//java/client/src/org/openqa/selenium/json:json',
'//third_party/java/guava:guava',
],
visibility = [
'//java/client/src/org/openqa/selenium:selenium'
'//java/client/src/org/openqa/selenium:selenium',
],
)
Expand Up @@ -17,9 +17,8 @@

package org.openqa.selenium.logging;

import com.google.common.collect.Sets;

import java.util.Set;
import java.util.TreeSet;

/**
* LocalLogs implementation that holds two other local logs.
Expand Down Expand Up @@ -50,7 +49,10 @@ public LogEntries get(String logType) {
}

public Set<String> getAvailableLogTypes() {
return Sets.union(predefinedTypeLogger.getAvailableLogTypes(), allTypesLogger.getAvailableLogTypes());
TreeSet<String> toReturn = new TreeSet<>();
toReturn.addAll(predefinedTypeLogger.getAvailableLogTypes());
toReturn.addAll(allTypesLogger.getAvailableLogTypes());
return toReturn;
}

@Override
Expand Down
Expand Up @@ -17,8 +17,6 @@

package org.openqa.selenium.logging;

import com.google.common.collect.ImmutableSet;

import java.util.Collection;
import java.util.Collections;
import java.util.Set;
Expand Down Expand Up @@ -46,7 +44,7 @@ public LogEntries get(String logType) {
}

public Set<String> getAvailableLogTypes() {
return ImmutableSet.of(LogType.CLIENT);
return Collections.singleton(LogType.CLIENT);
}

public void addEntry(String logType, LogEntry entry) {
Expand Down
13 changes: 9 additions & 4 deletions java/client/src/org/openqa/selenium/logging/LogCombiner.java
Expand Up @@ -17,17 +17,22 @@

package org.openqa.selenium.logging;

import com.google.common.collect.Iterables;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class LogCombiner {
private static final Comparator<LogEntry> LOG_ENTRY_TIMESTAMP_COMPARATOR =
Comparator.comparingLong(LogEntry::getTimestamp);

public static LogEntries combine(LogEntries... entries) {

return new LogEntries(
Iterables.mergeSorted(Arrays.asList(entries), LOG_ENTRY_TIMESTAMP_COMPARATOR));
Stream.of(entries)
.map(LogEntries::getAll)
.flatMap(Collection::stream)
.sorted(LOG_ENTRY_TIMESTAMP_COMPARATOR)
.collect(Collectors.toList()));
}
}
Expand Up @@ -17,11 +17,9 @@

package org.openqa.selenium.logging.profiler;

import com.google.common.collect.ImmutableMap;

import org.openqa.selenium.json.Json;

import java.util.Map;
import java.util.TreeMap;

public class HttpProfilerLogEntry extends ProfilerLogEntry {

Expand All @@ -30,10 +28,10 @@ public HttpProfilerLogEntry(String commandName, boolean isStart) {
}

private static String constructMessage(EventType eventType, String commandName, boolean isStart) {
Map<String, ?> map = ImmutableMap.of(
"event", eventType.toString(),
"command", commandName,
"startorend", isStart ? "start" : "end");
TreeMap<Object, Object> map = new TreeMap<>();
map.put("event", eventType.toString());
map.put("command", commandName);
map.put("startorend", isStart ? "start" : "end");
return new Json().toJson(map);
}

Expand Down

0 comments on commit 5a8b480

Please sign in to comment.