Skip to content

Commit 385ea88

Browse files
feat: Fix google java style issues
1 parent 11fc8b7 commit 385ea88

File tree

8 files changed

+45
-36
lines changed

8 files changed

+45
-36
lines changed

jib-core/src/main/java/com/google/cloud/tools/jib/api/JibContainer.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,16 @@ public Set<String> getTags() {
101101
}
102102

103103
/**
104-
* Get the image tags with digest
104+
* Get the image tags with digest.
105+
*
105106
* @return the image tags with digest
106107
*/
107108
public Set<String> getImageTagsWithDigest() {
108109
return tags.stream()
109-
.map(tag -> {
110-
StringBuilder imageTagWithDigest = new StringBuilder()
110+
.map(
111+
tag -> {
112+
StringBuilder imageTagWithDigest =
113+
new StringBuilder()
111114
.append(targetImage.getRegistry())
112115
.append("/")
113116
.append(targetImage.getRepository())
@@ -117,7 +120,7 @@ public Set<String> getImageTagsWithDigest() {
117120
.append(imageDigest);
118121
return imageTagWithDigest.toString();
119122
})
120-
.collect(Collectors.toSet());
123+
.collect(Collectors.toSet());
121124
}
122125

123126
@Override

jib-core/src/test/java/com/google/cloud/tools/jib/api/JibContainerTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,8 @@
2323
import com.google.cloud.tools.jib.configuration.ImageConfiguration;
2424
import com.google.common.collect.ImmutableSet;
2525
import java.security.DigestException;
26-
import java.util.Collections;
27-
import java.util.HashSet;
2826
import java.util.Set;
2927
import java.util.stream.Collectors;
30-
3128
import org.junit.Assert;
3229
import org.junit.Before;
3330
import org.junit.Rule;
@@ -151,18 +148,21 @@ public void testCreation_withBuildContextAndBuildResult() {
151148
public void testGetImageTagsWithDigest_constructsCorrectImageTagsWithDigest() {
152149
JibContainer container = new JibContainer(targetImage1, digest1, digest2, tags1, true);
153150

154-
Set<String> expectedImageTagsWithDigest = tags1.stream()
155-
.map(tag -> {
156-
StringBuilder imageTagWithDigest = new StringBuilder()
157-
.append(targetImage1.getRegistry())
158-
.append("/")
159-
.append(targetImage1.getRepository())
160-
.append(":")
161-
.append(tag)
162-
.append("@")
163-
.append(digest1);
164-
return imageTagWithDigest.toString();
165-
})
151+
Set<String> expectedImageTagsWithDigest =
152+
tags1.stream()
153+
.map(
154+
tag -> {
155+
StringBuilder imageTagWithDigest =
156+
new StringBuilder()
157+
.append(targetImage1.getRegistry())
158+
.append("/")
159+
.append(targetImage1.getRepository())
160+
.append(":")
161+
.append(tag)
162+
.append("@")
163+
.append(digest1);
164+
return imageTagWithDigest.toString();
165+
})
166166
.collect(Collectors.toSet());
167167

168168
Set<String> imageTagsWithDigest = container.getImageTagsWithDigest();

jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/OutputPathsParameters.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public void setDigest(String digest) {
6161

6262
@Input
6363
public String getImageTagDigest() {
64-
return getRelativeToProjectRoot(imageTagDigest, PropertyNames.OUTPUT_PATHS_IMAGE_TAG_DIGEST).toString();
64+
return getRelativeToProjectRoot(imageTagDigest, PropertyNames.OUTPUT_PATHS_IMAGE_TAG_DIGEST)
65+
.toString();
6566
}
6667

6768
@Internal

jib-gradle-plugin/src/test/java/com/google/cloud/tools/jib/gradle/GradleRawConfigurationTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public void testGetters() {
103103
.thenReturn(new HashMap<>(ImmutableMap.of("docker", "client")));
104104

105105
Mockito.when(outputPathsParameters.getDigestPath()).thenReturn(Paths.get("digest/path"));
106-
Mockito.when(outputPathsParameters.getImageTagDigestPath()).thenReturn(Paths.get("image-tag-digest/path"));
106+
Mockito.when(outputPathsParameters.getImageTagDigestPath())
107+
.thenReturn(Paths.get("image-tag-digest/path"));
107108
Mockito.when(outputPathsParameters.getImageIdPath()).thenReturn(Paths.get("id/path"));
108109
Mockito.when(outputPathsParameters.getImageJsonPath()).thenReturn(Paths.get("json/path"));
109110
Mockito.when(outputPathsParameters.getTarPath()).thenReturn(Paths.get("tar/path"));
@@ -148,7 +149,8 @@ public void testGetters() {
148149
new HashMap<>(ImmutableMap.of("docker", "client")),
149150
rawConfiguration.getDockerEnvironment());
150151
Assert.assertEquals(Paths.get("digest/path"), rawConfiguration.getDigestOutputPath());
151-
Assert.assertEquals(Paths.get("image-tag-digest/path"), rawConfiguration.getImageTagDigestOutputPath());
152+
Assert.assertEquals(
153+
Paths.get("image-tag-digest/path"), rawConfiguration.getImageTagDigestOutputPath());
152154
Assert.assertEquals(Paths.get("id/path"), rawConfiguration.getImageIdOutputPath());
153155
Assert.assertEquals(Paths.get("json/path"), rawConfiguration.getImageJsonOutputPath());
154156
Assert.assertEquals(Paths.get("tar/path"), rawConfiguration.getTarOutputPath());

jib-maven-plugin/src/main/java/com/google/cloud/tools/jib/maven/JibPluginConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,9 +779,9 @@ Path getDigestOutputPath() {
779779

780780
Path getImageTagDigestOutputPath() {
781781
Path configuredPath =
782-
outputPaths.imageTagDigest == null
783-
? Paths.get(getProject().getBuild().getDirectory()).resolve("jib-image-tag.digest")
784-
: outputPaths.imageTagDigest.toPath();
782+
outputPaths.imageTagDigest == null
783+
? Paths.get(getProject().getBuild().getDirectory()).resolve("jib-image-tag.digest")
784+
: outputPaths.imageTagDigest.toPath();
785785
return getRelativeToProjectRoot(configuredPath, PropertyNames.OUTPUT_PATHS_IMAGE_TAG_DIGEST);
786786
}
787787

jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/JibPluginConfigurationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,6 @@ public void testSystemPropertiesOutputPaths() {
207207
assertThat(testPluginConfiguration.getDigestOutputPath()).isEqualTo(Paths.get("/digest/path"));
208208
sessionSystemProperties.put("jib.outputPaths.imageTagDigest", "/image-tag-digest/path");
209209
assertThat(testPluginConfiguration.getImageTagDigestOutputPath()).isEqualTo(Paths.get("/image-tag-digest/path"));
210-
sessionSystemProperties.put("jib.outputPaths.imageTagDigest", "/image-tag-digest/path");
211-
assertThat(testPluginConfiguration.getImageTagDigestOutputPath()).isEqualTo(Paths.get("/image-tag-digest/path"));
212210
sessionSystemProperties.put("jib.outputPaths.imageId", "/id/path");
213211
assertThat(testPluginConfiguration.getImageIdOutputPath()).isEqualTo(Paths.get("/id/path"));
214212
sessionSystemProperties.put("jib.outputPaths.tar", "/tar/path");
@@ -331,7 +329,8 @@ public void testPomPropertiesOutputPaths() {
331329
project.getProperties().setProperty("jib.outputPaths.digest", "/digest/path");
332330
assertThat(testPluginConfiguration.getDigestOutputPath()).isEqualTo(Paths.get("/digest/path"));
333331
project.getProperties().setProperty("jib.outputPaths.imageTagDigest", "/image-tag-digest/path");
334-
assertThat(testPluginConfiguration.getImageTagDigestOutputPath()).isEqualTo(Paths.get("/image-tag-digest/path"));
332+
assertThat(testPluginConfiguration.getImageTagDigestOutputPath())
333+
.isEqualTo(Paths.get("/image-tag-digest/path"));
335334
project.getProperties().setProperty("jib.outputPaths.imageId", "/id/path");
336335
assertThat(testPluginConfiguration.getImageIdOutputPath()).isEqualTo(Paths.get("/id/path"));
337336
project.getProperties().setProperty("jib.outputPaths.imageJson", "/json/path");

jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenRawConfigurationTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ public void testGetters() {
100100
Mockito.when(jibPluginConfiguration.getDockerClientEnvironment())
101101
.thenReturn(new HashMap<>(ImmutableMap.of("docker", "client")));
102102
Mockito.when(jibPluginConfiguration.getDigestOutputPath()).thenReturn(Paths.get("digest/path"));
103-
Mockito.when(jibPluginConfiguration.getImageTagDigestOutputPath()).thenReturn(Paths.get("image-tag-digest/path"));
103+
Mockito.when(jibPluginConfiguration.getImageTagDigestOutputPath())
104+
.thenReturn(Paths.get("image-tag-digest/path"));
104105
Mockito.when(jibPluginConfiguration.getImageIdOutputPath()).thenReturn(Paths.get("id/path"));
105106
Mockito.when(jibPluginConfiguration.getImageJsonOutputPath())
106107
.thenReturn(Paths.get("json/path"));
@@ -145,7 +146,8 @@ public void testGetters() {
145146
new HashMap<>(ImmutableMap.of("docker", "client")),
146147
rawConfiguration.getDockerEnvironment());
147148
Assert.assertEquals(Paths.get("digest/path"), jibPluginConfiguration.getDigestOutputPath());
148-
Assert.assertEquals(Paths.get("image-tag-digest/path"), jibPluginConfiguration.getImageTagDigestOutputPath());
149+
Assert.assertEquals(
150+
Paths.get("image-tag-digest/path"), jibPluginConfiguration.getImageTagDigestOutputPath());
149151
Assert.assertEquals(Paths.get("id/path"), jibPluginConfiguration.getImageIdOutputPath());
150152
Assert.assertEquals(Paths.get("json/path"), jibPluginConfiguration.getImageJsonOutputPath());
151153
Assert.assertEquals(Paths.get("tar/path"), jibPluginConfiguration.getTarOutputPath());

jib-plugins-common/src/test/java/com/google/cloud/tools/jib/plugins/common/JibBuildRunnerTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,23 +256,25 @@ public void testBuildImage_writesImageJson() throws Exception {
256256

257257
@Test
258258
public void testBuildImage_writeImageTagDigest() throws Exception {
259-
Set<String> imageTagsDigest = ImmutableSet.of(
259+
Set<String> imageTagsDigest =
260+
ImmutableSet.of(
260261
"gcr.io/project/image:latest@sha256:abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789",
261262
"gcr.io/project/image:custom-tag@sha256:abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789");
262263

263-
String expectedImageTagsDigestOutput = "gcr.io/project/image:latest@sha256:abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789\n" +
264-
"gcr.io/project/image:custom-tag@sha256:abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789\n";
264+
String expectedImageTagsDigestOutput =
265+
"gcr.io/project/image:latest@sha256:abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789\n"
266+
+ "gcr.io/project/image:custom-tag@sha256:abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789\n";
265267

266268
final Path outputPath = temporaryFolder.newFile("jib-image-tag.digest").toPath();
267269

268270
Mockito.when(mockJibContainer.getImageTagsWithDigest()).thenReturn(imageTagsDigest);
269271
Mockito.when(mockJibContainerBuilder.containerize(mockContainerizer))
270-
.thenReturn(mockJibContainer);
271-
Mockito.when(mockJibContainer.isImagePushed()).thenReturn(true);
272+
.thenReturn(mockJibContainer);
272273

273274
testJibBuildRunner.writeImageTagDigest(outputPath).runBuild();
274275

275-
final String imageTagDigestOutput = new String(Files.readAllBytes(outputPath), StandardCharsets.UTF_8);
276+
final String imageTagDigestOutput =
277+
new String(Files.readAllBytes(outputPath), StandardCharsets.UTF_8);
276278

277279
Assert.assertEquals(expectedImageTagsDigestOutput, imageTagDigestOutput);
278280
}

0 commit comments

Comments
 (0)