Merge branch 'stable-2.15'

* stable-2.15:
  Consistently import utility methods from Collectors as static
  ListMailFilter: Static import from Collectors
  Fix plugin IT test for plugins using @PluginData annotation
  Update hooks plugin to latest revision on master

Change-Id: Ife8549cfaefb7a5ddab20164d8ac2ca23644d845
This commit is contained in:
David Pursehouse
2017-12-15 19:11:51 +09:00
16 changed files with 49 additions and 42 deletions

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.client.api; package com.google.gerrit.client.api;
import static java.util.stream.Collectors.toList;
import com.google.gerrit.client.ErrorDialog; import com.google.gerrit.client.ErrorDialog;
import com.google.gerrit.client.Gerrit; import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.VoidResult; import com.google.gerrit.client.VoidResult;
@@ -28,7 +30,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.DialogBox; import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwtexpui.progress.client.ProgressBar; import com.google.gwtexpui.progress.client.ProgressBar;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** Loads JavaScript plugins with a progress meter visible. */ /** Loads JavaScript plugins with a progress meter visible. */
public class PluginLoader extends DialogBox { public class PluginLoader extends DialogBox {
@@ -39,7 +40,7 @@ public class PluginLoader extends DialogBox {
if (plugins == null || plugins.isEmpty()) { if (plugins == null || plugins.isEmpty()) {
callback.onSuccess(VoidResult.create()); callback.onSuccess(VoidResult.create());
} else { } else {
plugins = plugins.stream().filter(p -> p.endsWith(".js")).collect(Collectors.toList()); plugins = plugins.stream().filter(p -> p.endsWith(".js")).collect(toList());
if (plugins.isEmpty()) { if (plugins.isEmpty()) {
callback.onSuccess(VoidResult.create()); callback.onSuccess(VoidResult.create());
} else { } else {

View File

@@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertAbout;
import static com.google.gerrit.extensions.api.changes.RecipientType.BCC; import static com.google.gerrit.extensions.api.changes.RecipientType.BCC;
import static com.google.gerrit.extensions.api.changes.RecipientType.CC; import static com.google.gerrit.extensions.api.changes.RecipientType.CC;
import static com.google.gerrit.extensions.api.changes.RecipientType.TO; import static com.google.gerrit.extensions.api.changes.RecipientType.TO;
import static java.util.stream.Collectors.toList;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -48,7 +49,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@@ -121,7 +121,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
.stream() .stream()
.map(Address::getEmail) .map(Address::getEmail)
.filter(e -> !recipients.get(TO).contains(e) && !recipients.get(CC).contains(e)) .filter(e -> !recipients.get(TO).contains(e) && !recipients.get(CC).contains(e))
.collect(Collectors.toList())); .collect(toList()));
this.users = users; this.users = users;
if (!message.headers().containsKey("X-Gerrit-MessageType")) { if (!message.headers().containsKey("X-Gerrit-MessageType")) {
fail("a message was sent with X-Gerrit-MessageType header"); fail("a message was sent with X-Gerrit-MessageType header");
@@ -162,7 +162,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
} }
Truth.assertThat(header).isInstanceOf(AddressList.class); Truth.assertThat(header).isInstanceOf(AddressList.class);
AddressList addrList = (AddressList) header; AddressList addrList = (AddressList) header;
return addrList.getAddressList().stream().map(Address::getEmail).collect(Collectors.toList()); return addrList.getAddressList().stream().map(Address::getEmail).collect(toList());
} }
public FakeEmailSenderSubject to(String... emails) { public FakeEmailSenderSubject to(String... emails) {

View File

@@ -20,12 +20,16 @@ import com.google.gerrit.server.plugins.TestServerPlugin;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.TemporaryFolder;
public class LightweightPluginDaemonTest extends AbstractDaemonTest { public class LightweightPluginDaemonTest extends AbstractDaemonTest {
@Inject private PluginGuiceEnvironment env; @Inject private PluginGuiceEnvironment env;
@Inject private PluginUser.Factory pluginUserFactory; @Inject private PluginUser.Factory pluginUserFactory;
@Rule public TemporaryFolder tempDataDir = new TemporaryFolder();
private TestServerPlugin plugin; private TestServerPlugin plugin;
@Before @Before
@@ -40,7 +44,8 @@ public class LightweightPluginDaemonTest extends AbstractDaemonTest {
getClass().getClassLoader(), getClass().getClassLoader(),
testPlugin.sysModule(), testPlugin.sysModule(),
testPlugin.httpModule(), testPlugin.httpModule(),
testPlugin.sshModule()); testPlugin.sshModule(),
tempDataDir.getRoot().toPath());
plugin.start(env); plugin.start(env);
env.onStartPlugin(plugin); env.onStartPlugin(plugin);

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.fixes; package com.google.gerrit.server.fixes;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.stream.Collectors.groupingBy;
import com.google.gerrit.common.RawInputUtil; import com.google.gerrit.common.RawInputUtil;
import com.google.gerrit.extensions.restapi.BinaryResult; import com.google.gerrit.extensions.restapi.BinaryResult;
@@ -33,7 +34,6 @@ import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
@@ -73,9 +73,7 @@ public class FixReplacementInterpreter {
checkNotNull(fixReplacements, "Fix replacements must not be null"); checkNotNull(fixReplacements, "Fix replacements must not be null");
Map<String, List<FixReplacement>> fixReplacementsPerFilePath = Map<String, List<FixReplacement>> fixReplacementsPerFilePath =
fixReplacements fixReplacements.stream().collect(groupingBy(fixReplacement -> fixReplacement.path));
.stream()
.collect(Collectors.groupingBy(fixReplacement -> fixReplacement.path));
List<TreeModification> treeModifications = new ArrayList<>(); List<TreeModification> treeModifications = new ArrayList<>();
for (Map.Entry<String, List<FixReplacement>> entry : fixReplacementsPerFilePath.entrySet()) { for (Map.Entry<String, List<FixReplacement>> entry : fixReplacementsPerFilePath.entrySet()) {

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.server.git.strategy; package com.google.gerrit.server.git.strategy;
import static java.util.stream.Collectors.toSet;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.client.SubmitType;
@@ -31,7 +33,6 @@ import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
@@ -68,7 +69,7 @@ public class SubmitDryRun {
repo.getRefDatabase().getRefs(Constants.R_TAGS).values().stream()) repo.getRefDatabase().getRefs(Constants.R_TAGS).values().stream())
.map(Ref::getObjectId) .map(Ref::getObjectId)
.filter(o -> o != null) .filter(o -> o != null)
.collect(Collectors.toSet()); .collect(toSet());
} }
public static Set<RevCommit> getAlreadyAccepted(Repository repo, RevWalk rw) throws IOException { public static Set<RevCommit> getAlreadyAccepted(Repository repo, RevWalk rw) throws IOException {

View File

@@ -14,13 +14,14 @@
package com.google.gerrit.server.mail; package com.google.gerrit.server.mail;
import static java.util.stream.Collectors.joining;
import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.mail.receive.MailMessage; import com.google.gerrit.server.mail.receive.MailMessage;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.util.Arrays; import java.util.Arrays;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -42,7 +43,7 @@ public class ListMailFilter implements MailFilter {
ListMailFilter(@GerritServerConfig Config cfg) { ListMailFilter(@GerritServerConfig Config cfg) {
this.mode = cfg.getEnum("receiveemail", "filter", "mode", ListFilterMode.OFF); this.mode = cfg.getEnum("receiveemail", "filter", "mode", ListFilterMode.OFF);
String[] addresses = cfg.getStringList("receiveemail", "filter", "patterns"); String[] addresses = cfg.getStringList("receiveemail", "filter", "patterns");
String concat = Arrays.asList(addresses).stream().collect(Collectors.joining("|")); String concat = Arrays.asList(addresses).stream().collect(joining("|"));
this.mailPattern = Pattern.compile(concat); this.mailPattern = Pattern.compile(concat);
} }

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.notedb;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.gerrit.reviewdb.client.PatchLineComment.Status.PUBLISHED; import static com.google.gerrit.reviewdb.client.PatchLineComment.Status.PUBLISHED;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
@@ -31,7 +32,6 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.CommitBuilder; import org.eclipse.jgit.lib.CommitBuilder;
import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.ObjectId;
@@ -139,7 +139,7 @@ public class DeleteCommentRewriter implements NoteDbRewriter {
.values() .values()
.stream() .stream()
.flatMap(n -> n.getComments().stream()) .flatMap(n -> n.getComments().stream())
.collect(Collectors.toMap(c -> c.key.uuid, c -> c)); .collect(toMap(c -> c.key.uuid, c -> c));
} }
/** /**

View File

@@ -18,6 +18,7 @@ import static com.google.gerrit.server.ioutil.BasicSerialization.readEnum;
import static com.google.gerrit.server.ioutil.BasicSerialization.readVarInt32; import static com.google.gerrit.server.ioutil.BasicSerialization.readVarInt32;
import static com.google.gerrit.server.ioutil.BasicSerialization.writeEnum; import static com.google.gerrit.server.ioutil.BasicSerialization.writeEnum;
import static com.google.gerrit.server.ioutil.BasicSerialization.writeVarInt32; import static com.google.gerrit.server.ioutil.BasicSerialization.writeVarInt32;
import static java.util.stream.Collectors.toList;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.gerrit.reviewdb.client.CodedEnum; import com.google.gerrit.reviewdb.client.CodedEnum;
@@ -30,7 +31,6 @@ import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.jgit.diff.Edit; import org.eclipse.jgit.diff.Edit;
import org.eclipse.jgit.diff.ReplaceEdit; import org.eclipse.jgit.diff.ReplaceEdit;
@@ -109,7 +109,7 @@ public class IntraLineDiff implements Serializable {
for (int j = 0; j < innerCount; j++) { for (int j = 0; j < innerCount; j++) {
inner[j] = readEdit(in); inner[j] = readEdit(in);
} }
editArray[i] = new ReplaceEdit(editArray[i], toList(inner)); editArray[i] = new ReplaceEdit(editArray[i], asList(inner));
} }
} }
edits = ImmutableList.copyOf(editArray); edits = ImmutableList.copyOf(editArray);
@@ -128,7 +128,7 @@ public class IntraLineDiff implements Serializable {
private static ReplaceEdit copy(ReplaceEdit edit) { private static ReplaceEdit copy(ReplaceEdit edit) {
List<Edit> internalEdits = List<Edit> internalEdits =
edit.getInternalEdits().stream().map(IntraLineDiff::copy).collect(Collectors.toList()); edit.getInternalEdits().stream().map(IntraLineDiff::copy).collect(toList());
return new ReplaceEdit( return new ReplaceEdit(
edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB(), internalEdits); edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB(), internalEdits);
} }
@@ -148,7 +148,7 @@ public class IntraLineDiff implements Serializable {
return new Edit(beginA, endA, beginB, endB); return new Edit(beginA, endA, beginB, endB);
} }
private static List<Edit> toList(Edit[] l) { private static List<Edit> asList(Edit[] l) {
return Collections.unmodifiableList(Arrays.asList(l)); return Collections.unmodifiableList(Arrays.asList(l));
} }
} }

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.plugins; package com.google.gerrit.server.plugins;
import static java.util.Comparator.comparing; import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toMap;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.gerrit.common.data.GlobalCapability; import com.google.gerrit.common.data.GlobalCapability;
@@ -30,7 +31,6 @@ import java.util.Locale;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.kohsuke.args4j.Option; import org.kohsuke.args4j.Option;
@@ -137,7 +137,7 @@ public class ListPlugins implements RestReadView<TopLevelResource> {
if (limit > 0) { if (limit > 0) {
s = s.limit(limit); s = s.limit(limit);
} }
return new TreeMap<>(s.collect(Collectors.toMap(p -> p.getName(), p -> toPluginInfo(p)))); return new TreeMap<>(s.collect(toMap(p -> p.getName(), p -> toPluginInfo(p))));
} }
private void checkMatchOptions(boolean cond) throws BadRequestException { private void checkMatchOptions(boolean cond) throws BadRequestException {

View File

@@ -15,6 +15,7 @@
package com.google.gerrit.server.plugins; package com.google.gerrit.server.plugins;
import com.google.gerrit.server.PluginUser; import com.google.gerrit.server.PluginUser;
import java.nio.file.Path;
public class TestServerPlugin extends ServerPlugin { public class TestServerPlugin extends ServerPlugin {
private final ClassLoader classLoader; private final ClassLoader classLoader;
@@ -29,9 +30,10 @@ public class TestServerPlugin extends ServerPlugin {
ClassLoader classloader, ClassLoader classloader,
String sysName, String sysName,
String httpName, String httpName,
String sshName) String sshName,
Path dataDir)
throws InvalidPluginException { throws InvalidPluginException {
super(name, pluginCanonicalWebUrl, user, null, null, null, null, classloader); super(name, pluginCanonicalWebUrl, user, null, null, null, dataDir, classloader);
this.classLoader = classloader; this.classLoader = classloader;
this.sysName = sysName; this.sysName = sysName;
this.httpName = httpName; this.httpName = httpName;

View File

@@ -14,6 +14,8 @@
package com.google.gerrit.server.project; package com.google.gerrit.server.project;
import static java.util.stream.Collectors.toMap;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.gerrit.common.data.LabelType; import com.google.gerrit.common.data.LabelType;
import com.google.gerrit.common.data.LabelValue; import com.google.gerrit.common.data.LabelValue;
@@ -28,7 +30,6 @@ import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Singleton @Singleton
public class ProjectJson { public class ProjectJson {
@@ -48,9 +49,7 @@ public class ProjectJson {
for (LabelType t : projectState.getLabelTypes().getLabelTypes()) { for (LabelType t : projectState.getLabelTypes().getLabelTypes()) {
LabelTypeInfo labelInfo = new LabelTypeInfo(); LabelTypeInfo labelInfo = new LabelTypeInfo();
labelInfo.values = labelInfo.values =
t.getValues() t.getValues().stream().collect(toMap(LabelValue::formatValue, LabelValue::getText));
.stream()
.collect(Collectors.toMap(LabelValue::formatValue, LabelValue::getText));
labelInfo.defaultValue = t.getDefaultValue(); labelInfo.defaultValue = t.getDefaultValue();
info.labels.put(t.getName(), labelInfo); info.labels.put(t.getName(), labelInfo);
} }

View File

@@ -89,7 +89,6 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
@@ -1244,7 +1243,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
} }
List<Predicate<ChangeData>> predicates = List<Predicate<ChangeData>> predicates =
parts.stream().map(fullPredicateFunc).collect(Collectors.toList()); parts.stream().map(fullPredicateFunc).collect(toList());
return Predicate.and(predicates); return Predicate.and(predicates);
} }

View File

@@ -49,6 +49,7 @@ import static com.google.gerrit.server.project.testing.Util.category;
import static com.google.gerrit.server.project.testing.Util.value; import static com.google.gerrit.server.project.testing.Util.value;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toSet; import static java.util.stream.Collectors.toSet;
@@ -154,7 +155,6 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository; import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
@@ -461,7 +461,7 @@ public class ChangeIT extends AbstractDaemonTest {
assertThat(result.reviewers).isNotEmpty(); assertThat(result.reviewers).isNotEmpty();
ChangeInfo info = gApi.changes().id(changeId).get(); ChangeInfo info = gApi.changes().id(changeId).get();
Function<Collection<AccountInfo>, Collection<String>> toEmails = Function<Collection<AccountInfo>, Collection<String>> toEmails =
ais -> ais.stream().map(ai -> ai.email).collect(Collectors.toSet()); ais -> ais.stream().map(ai -> ai.email).collect(toSet());
assertThat(toEmails.apply(info.pendingReviewers.get(REVIEWER))) assertThat(toEmails.apply(info.pendingReviewers.get(REVIEWER)))
.containsExactly( .containsExactly(
admin.email, user1.email, user2.email, "byemail1@example.com", "byemail2@example.com"); admin.email, user1.email, user2.email, "byemail1@example.com", "byemail2@example.com");
@@ -3230,7 +3230,7 @@ public class ChangeIT extends AbstractDaemonTest {
@Test @Test
public void putTopicExceedLimitFails() throws Exception { public void putTopicExceedLimitFails() throws Exception {
String changeId = createChange().getChangeId(); String changeId = createChange().getChangeId();
String topic = Stream.generate(() -> "t").limit(2049).collect(Collectors.joining()); String topic = Stream.generate(() -> "t").limit(2049).collect(joining());
exception.expect(BadRequestException.class); exception.expect(BadRequestException.class);
exception.expectMessage("topic length exceeds the limit"); exception.expectMessage("topic length exceeds the limit");

View File

@@ -19,6 +19,8 @@ import static com.google.common.truth.TruthJUnit.assume;
import static com.google.gerrit.extensions.common.testing.DiffInfoSubject.assertThat; import static com.google.gerrit.extensions.common.testing.DiffInfoSubject.assertThat;
import static com.google.gerrit.extensions.common.testing.FileInfoSubject.assertThat; import static com.google.gerrit.extensions.common.testing.FileInfoSubject.assertThat;
import static com.google.gerrit.reviewdb.client.Patch.COMMIT_MSG; import static com.google.gerrit.reviewdb.client.Patch.COMMIT_MSG;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toMap;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@@ -44,7 +46,6 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.eclipse.jgit.lib.Config; import org.eclipse.jgit.lib.Config;
@@ -64,7 +65,7 @@ public class RevisionDiffIT extends AbstractDaemonTest {
private static final String FILE_CONTENT = private static final String FILE_CONTENT =
IntStream.rangeClosed(1, 100) IntStream.rangeClosed(1, 100)
.mapToObj(number -> String.format("Line %d\n", number)) .mapToObj(number -> String.format("Line %d\n", number))
.collect(Collectors.joining()); .collect(joining());
private static final String FILE_CONTENT2 = "1st line\n2nd line\n3rd line\n"; private static final String FILE_CONTENT2 = "1st line\n2nd line\n3rd line\n";
private boolean intraline; private boolean intraline;
@@ -1286,7 +1287,7 @@ public class RevisionDiffIT extends AbstractDaemonTest {
testRepo.reset(parentCommit); testRepo.reset(parentCommit);
Map<String, String> files = Map<String, String> files =
Arrays.stream(removedFilePaths) Arrays.stream(removedFilePaths)
.collect(Collectors.toMap(Function.identity(), path -> "Irrelevant content")); .collect(toMap(Function.identity(), path -> "Irrelevant content"));
PushOneCommit push = PushOneCommit push =
pushFactory.create(db, admin.getIdent(), testRepo, "Remove files from repo", files); pushFactory.create(db, admin.getIdent(), testRepo, "Remove files from repo", files);
PushOneCommit.Result result = push.rm("refs/for/master"); PushOneCommit.Result result = push.rm("refs/for/master");

View File

@@ -93,7 +93,6 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.junit.TestRepository;
@@ -353,14 +352,14 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
@Test @Test
public void pushForMasterWithTopicInRefExceedLimitFails() throws Exception { public void pushForMasterWithTopicInRefExceedLimitFails() throws Exception {
String topic = Stream.generate(() -> "t").limit(2049).collect(Collectors.joining()); String topic = Stream.generate(() -> "t").limit(2049).collect(joining());
PushOneCommit.Result r = pushTo("refs/for/master/" + topic); PushOneCommit.Result r = pushTo("refs/for/master/" + topic);
r.assertErrorStatus("topic length exceeds the limit (2048)"); r.assertErrorStatus("topic length exceeds the limit (2048)");
} }
@Test @Test
public void pushForMasterWithTopicAsOptionExceedLimitFails() throws Exception { public void pushForMasterWithTopicAsOptionExceedLimitFails() throws Exception {
String topic = Stream.generate(() -> "t").limit(2049).collect(Collectors.joining()); String topic = Stream.generate(() -> "t").limit(2049).collect(joining());
PushOneCommit.Result r = pushTo("refs/for/master%topic=" + topic); PushOneCommit.Result r = pushTo("refs/for/master%topic=" + topic);
r.assertErrorStatus("topic length exceeds the limit (2048)"); r.assertErrorStatus("topic length exceeds the limit (2048)");
} }

View File

@@ -18,6 +18,8 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat; import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.acceptance.PushOneCommit.FILE_NAME; import static com.google.gerrit.acceptance.PushOneCommit.FILE_NAME;
import static com.google.gerrit.acceptance.PushOneCommit.SUBJECT; import static com.google.gerrit.acceptance.PushOneCommit.SUBJECT;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@@ -68,7 +70,6 @@ import java.util.Optional;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.eclipse.jgit.lib.ObjectReader; import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
@@ -962,7 +963,7 @@ public class CommentsIT extends AbstractDaemonTest {
.values() .values()
.stream() .stream()
.flatMap(List::stream) .flatMap(List::stream)
.collect(Collectors.toList()); .collect(toList());
} }
private CommentInput addComment(String changeId, String message) throws Exception { private CommentInput addComment(String changeId, String message) throws Exception {
@@ -976,7 +977,7 @@ public class CommentsIT extends AbstractDaemonTest {
private void addComments(String changeId, String revision, CommentInput... commentInputs) private void addComments(String changeId, String revision, CommentInput... commentInputs)
throws Exception { throws Exception {
ReviewInput input = new ReviewInput(); ReviewInput input = new ReviewInput();
input.comments = Arrays.stream(commentInputs).collect(Collectors.groupingBy(c -> c.path)); input.comments = Arrays.stream(commentInputs).collect(groupingBy(c -> c.path));
gApi.changes().id(changeId).revision(revision).review(input); gApi.changes().id(changeId).revision(revision).review(input);
} }