Skip to content

Commit

Permalink
Replaced Collectors.joining() with String.join() where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Feb 12, 2018
1 parent b21bb01 commit 86a13c3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.assertj.core.api.Assertions;
import org.gradle.testkit.runner.BuildResult;
Expand Down Expand Up @@ -49,7 +48,7 @@ private void writeBuild(String... toInsert) throws IOException {
lines.add(" }");
lines.add(" }");
lines.addAll(Arrays.asList(toInsert));
setFile("build.gradle").toContent(lines.stream().collect(Collectors.joining("\n")));
setFile("build.gradle").toContent(String.join("\n", lines));
}

@Test
Expand Down Expand Up @@ -133,7 +132,7 @@ private void assertResultAndMessages(BuildResult result, TaskOutcome outcome, St
String expectedToStartWith = StringPrinter.buildStringFromLines(messages).trim();
int numNewlines = CharMatcher.is('\n').countIn(expectedToStartWith);
List<String> actualLines = Splitter.on('\n').splitToList(LineEnding.toUnix(result.getOutput()));
String actualStart = actualLines.subList(0, numNewlines + 1).stream().collect(Collectors.joining("\n"));
String actualStart = String.join("\n", actualLines.subList(0, numNewlines + 1));
Assertions.assertThat(actualStart).isEqualTo(expectedToStartWith);
Assertions.assertThat(result.tasks(outcome).size() + result.tasks(TaskOutcome.UP_TO_DATE).size())
.isEqualTo(result.getTasks().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.Locale;
import java.util.stream.Collectors;

import org.assertj.core.api.Assertions;
import org.gradle.api.GradleException;
Expand Down Expand Up @@ -163,7 +162,7 @@ public void paddedCellCheckFailureFiles() throws Throwable {
private void assertFolderContents(String subfolderName, String... files) throws IOException {
File subfolder = new File(rootFolder(), subfolderName);
Assert.assertTrue(subfolder.isDirectory());
String asList = Arrays.stream(subfolder.list()).sorted().collect(Collectors.joining("\n"));
String asList = String.join("\n", Arrays.asList(files));
Assert.assertEquals(StringPrinter.buildStringFromLines(files).trim(), asList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.diffplug.spotless.maven;

import static java.util.stream.Collectors.joining;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -65,7 +64,7 @@ private Result run() throws IOException, InterruptedException {
Objects.requireNonNull(projectDir, "Need to call withProjectDir() first");
Objects.requireNonNull(args, "Need to call withArguments() first");
// run maven with the given args in the given directory
String argsString = Arrays.stream(args).collect(joining(" "));
String argsString = String.join(" ", Arrays.asList(args));
List<String> cmds = getPlatformCmds("-e -Dmaven.repo.local=" + localRepositoryDir + ' ' + argsString);
ProcessBuilder builder = new ProcessBuilder(cmds);
builder.directory(projectDir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Objects;
import java.util.function.Consumer;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import org.assertj.core.api.AbstractCharSequenceAssert;
import org.assertj.core.api.Assertions;
Expand Down Expand Up @@ -175,7 +174,7 @@ public void hasContent(String expected, Charset charset) {
}

public void hasLines(String... lines) {
hasContent(Arrays.stream(lines).collect(Collectors.joining("\n")));
hasContent(String.join("\n", Arrays.asList(lines)));
}

public void sameAsResource(String resource) throws IOException {
Expand All @@ -201,7 +200,7 @@ private WriteAsserter(File file) {
}

public File toLines(String... lines) throws IOException {
return toContent(Arrays.stream(lines).collect(Collectors.joining("\n")));
return toContent(String.join("\n", Arrays.asList(lines)));
}

public File toContent(String content) throws IOException {
Expand Down

0 comments on commit 86a13c3

Please sign in to comment.