Skip to content

Commit 0af0830

Browse files
committed
refactor: code style
Signed-off-by: xstefank <[email protected]>
1 parent b54f707 commit 0af0830

File tree

646 files changed

+9077
-7314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

646 files changed

+9077
-7314
lines changed

bootstrapper-maven-plugin/src/main/java/io/javaoperatorsdk/boostrapper/Bootstrapper.java

+42-25
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public class Bootstrapper {
2727
private static final Map<String, String> TOP_LEVEL_STATIC_FILES =
2828
Map.of("_.gitignore", ".gitignore", "README.md", "README.md");
2929
private static final List<String> JAVA_FILES =
30-
List.of("CustomResource.java", "Reconciler.java",
31-
"Spec.java", "Status.java");
30+
List.of("CustomResource.java", "Reconciler.java", "Spec.java", "Status.java");
3231

3332
public void create(File targetDir, String groupId, String artifactId) {
3433
try {
@@ -61,42 +60,62 @@ private void addJavaFiles(File projectDir, String groupId, String artifactId) {
6160
var targetTestDir = new File(projectDir, "src/test/java/" + packages);
6261
FileUtils.forceMkdir(targetDir);
6362
var classFileNamePrefix = artifactClassId(artifactId);
64-
JAVA_FILES.forEach(f -> addTemplatedFile(projectDir, f, groupId, artifactId, targetDir,
65-
classFileNamePrefix + f));
63+
JAVA_FILES.forEach(
64+
f ->
65+
addTemplatedFile(
66+
projectDir, f, groupId, artifactId, targetDir, classFileNamePrefix + f));
6667

6768
addTemplatedFile(projectDir, "Runner.java", groupId, artifactId, targetDir, null);
68-
addTemplatedFile(projectDir, "ConfigMapDependentResource.java", groupId, artifactId,
69-
targetDir, null);
70-
addTemplatedFile(projectDir, "ReconcilerIntegrationTest.java", groupId,
69+
addTemplatedFile(
70+
projectDir, "ConfigMapDependentResource.java", groupId, artifactId, targetDir, null);
71+
addTemplatedFile(
72+
projectDir,
73+
"ReconcilerIntegrationTest.java",
74+
groupId,
7175
artifactId,
72-
targetTestDir, artifactClassId(artifactId) + "ReconcilerIntegrationTest.java");
76+
targetTestDir,
77+
artifactClassId(artifactId) + "ReconcilerIntegrationTest.java");
7378
} catch (IOException e) {
7479
throw new RuntimeException(e);
7580
}
76-
7781
}
7882

7983
private void addTemplatedFiles(File projectDir, String groupId, String artifactId) {
8084
addTemplatedFile(projectDir, "pom.xml", groupId, artifactId);
8185
addTemplatedFile(projectDir, "k8s/test-resource.yaml", groupId, artifactId);
8286
}
8387

84-
private void addTemplatedFile(File projectDir, String fileName, String groupId,
85-
String artifactId) {
88+
private void addTemplatedFile(
89+
File projectDir, String fileName, String groupId, String artifactId) {
8690
addTemplatedFile(projectDir, fileName, groupId, artifactId, null, null);
8791
}
8892

89-
private void addTemplatedFile(File projectDir, String fileName, String groupId, String artifactId,
90-
File targetDir, String targetFileName) {
93+
private void addTemplatedFile(
94+
File projectDir,
95+
String fileName,
96+
String groupId,
97+
String artifactId,
98+
File targetDir,
99+
String targetFileName) {
91100
try {
92-
var values = Map.of("groupId", groupId, "artifactId", artifactId,
93-
"artifactClassId", artifactClassId(artifactId),
94-
"josdkVersion", Versions.JOSDK,
95-
"fabric8Version", Versions.KUBERNETES_CLIENT);
101+
var values =
102+
Map.of(
103+
"groupId",
104+
groupId,
105+
"artifactId",
106+
artifactId,
107+
"artifactClassId",
108+
artifactClassId(artifactId),
109+
"josdkVersion",
110+
Versions.JOSDK,
111+
"fabric8Version",
112+
Versions.KUBERNETES_CLIENT);
96113

97114
var mustache = mustacheFactory.compile("templates/" + fileName);
98-
var targetFile = new File(targetDir == null ? projectDir : targetDir,
99-
targetFileName == null ? fileName : targetFileName);
115+
var targetFile =
116+
new File(
117+
targetDir == null ? projectDir : targetDir,
118+
targetFileName == null ? fileName : targetFileName);
100119
FileUtils.forceMkdir(targetFile.getParentFile());
101120
var writer = new FileWriter(targetFile);
102121
mustache.execute(writer, values);
@@ -114,8 +133,8 @@ private void addStaticFile(File targetDir, String fileName, String targetFileNam
114133
addStaticFile(targetDir, fileName, targetFileName, null);
115134
}
116135

117-
private void addStaticFile(File targetDir, String fileName, String targetFilename,
118-
String subDir) {
136+
private void addStaticFile(
137+
File targetDir, String fileName, String targetFilename, String subDir) {
119138
String sourcePath = subDir == null ? "/static/" : "/static/" + subDir;
120139
String path = sourcePath + fileName;
121140
try (var is = Bootstrapper.class.getResourceAsStream(path)) {
@@ -127,14 +146,12 @@ private void addStaticFile(File targetDir, String fileName, String targetFilenam
127146
} catch (IOException e) {
128147
throw new RuntimeException("File path: " + path, e);
129148
}
130-
131149
}
132150

133151
public static String artifactClassId(String artifactId) {
134152
var parts = artifactId.split("-");
135-
return Arrays.stream(parts).map(p -> p.substring(0, 1)
136-
.toUpperCase() + p.substring(1))
153+
return Arrays.stream(parts)
154+
.map(p -> p.substring(0, 1).toUpperCase() + p.substring(1))
137155
.collect(Collectors.joining(""));
138156
}
139-
140157
}

bootstrapper-maven-plugin/src/main/java/io/javaoperatorsdk/boostrapper/BootstrapperMojo.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@
88
import org.apache.maven.plugins.annotations.Parameter;
99

1010
@Mojo(name = "create", requiresProject = false)
11-
public class BootstrapperMojo
12-
extends AbstractMojo {
11+
public class BootstrapperMojo extends AbstractMojo {
1312

1413
@Parameter(defaultValue = "${projectGroupId}")
1514
protected String projectGroupId;
1615

1716
@Parameter(defaultValue = "${projectArtifactId}")
1817
protected String projectArtifactId;
1918

20-
public void execute()
21-
throws MojoExecutionException {
19+
public void execute() throws MojoExecutionException {
2220
String userDir = System.getProperty("user.dir");
2321
new Bootstrapper().create(new File(userDir), projectGroupId, projectArtifactId);
2422
}

bootstrapper-maven-plugin/src/test/java/io/javaoperatorsdk/bootstrapper/BootstrapperTest.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ void copiesFilesToTarget() {
3030

3131
private void assertProjectCompiles() {
3232
try {
33-
var process = Runtime.getRuntime()
34-
.exec(
35-
"mvn clean install -f target/test-project/pom.xml -DskipTests -Dspotless.apply.skip");
33+
var process =
34+
Runtime.getRuntime()
35+
.exec(
36+
"mvn clean install -f target/test-project/pom.xml -DskipTests"
37+
+ " -Dspotless.apply.skip");
3638

3739
BufferedReader stdOut = new BufferedReader(new InputStreamReader(process.getInputStream()));
3840

caffeine-bounded-cache-support/src/main/java/io/javaoperatorsdk/operator/processing/event/source/cache/CaffeineBoundedItemStores.java

+2-6
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,13 @@ private CaffeineBoundedItemStores() {}
3939
*/
4040
@SuppressWarnings("unused")
4141
public static <R extends HasMetadata> BoundedItemStore<R> boundedItemStore(
42-
KubernetesClient client, Class<R> rClass,
43-
Duration accessExpireDuration) {
44-
Cache<String, R> cache = Caffeine.newBuilder()
45-
.expireAfterAccess(accessExpireDuration)
46-
.build();
42+
KubernetesClient client, Class<R> rClass, Duration accessExpireDuration) {
43+
Cache<String, R> cache = Caffeine.newBuilder().expireAfterAccess(accessExpireDuration).build();
4744
return boundedItemStore(client, rClass, cache);
4845
}
4946

5047
public static <R extends HasMetadata> BoundedItemStore<R> boundedItemStore(
5148
KubernetesClient client, Class<R> rClass, Cache<String, R> cache) {
5249
return new BoundedItemStore<>(new CaffeineBoundedCache<>(cache), rClass, client);
5350
}
54-
5551
}

caffeine-bounded-cache-support/src/test/java/io/javaoperatorsdk/operator/processing/event/source/cache/BoundedCacheTestBase.java

+38-26
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import static org.assertj.core.api.Assertions.assertThat;
1818
import static org.awaitility.Awaitility.await;
1919

20-
public abstract class BoundedCacheTestBase<P extends CustomResource<BoundedCacheTestSpec, BoundedCacheTestStatus>> {
20+
public abstract class BoundedCacheTestBase<
21+
P extends CustomResource<BoundedCacheTestSpec, BoundedCacheTestStatus>> {
2122

2223
private static final Logger log = LoggerFactory.getLogger(BoundedCacheTestBase.class);
2324

@@ -42,34 +43,46 @@ void reconciliationWorksWithLimitedCache() {
4243
}
4344

4445
private void assertConfigMapsDeleted() {
45-
await().atMost(Duration.ofSeconds(30))
46-
.untilAsserted(() -> IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST).forEach(i -> {
47-
var cm = extension().get(ConfigMap.class, RESOURCE_NAME_PREFIX + i);
48-
assertThat(cm).isNull();
49-
}));
46+
await()
47+
.atMost(Duration.ofSeconds(30))
48+
.untilAsserted(
49+
() ->
50+
IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST)
51+
.forEach(
52+
i -> {
53+
var cm = extension().get(ConfigMap.class, RESOURCE_NAME_PREFIX + i);
54+
assertThat(cm).isNull();
55+
}));
5056
}
5157

5258
private void deleteTestResources() {
53-
IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST).forEach(i -> {
54-
var cm = extension().get(customResourceClass(), RESOURCE_NAME_PREFIX + i);
55-
var deleted = extension().delete(cm);
56-
if (!deleted) {
57-
log.warn("Custom resource might not be deleted: {}", cm);
58-
}
59-
});
59+
IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST)
60+
.forEach(
61+
i -> {
62+
var cm = extension().get(customResourceClass(), RESOURCE_NAME_PREFIX + i);
63+
var deleted = extension().delete(cm);
64+
if (!deleted) {
65+
log.warn("Custom resource might not be deleted: {}", cm);
66+
}
67+
});
6068
}
6169

6270
private void updateTestResources() {
63-
IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST).forEach(i -> {
64-
var cm = extension().get(ConfigMap.class, RESOURCE_NAME_PREFIX + i);
65-
cm.getData().put(DATA_KEY, UPDATED_PREFIX + i);
66-
extension().replace(cm);
67-
});
71+
IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST)
72+
.forEach(
73+
i -> {
74+
var cm = extension().get(ConfigMap.class, RESOURCE_NAME_PREFIX + i);
75+
cm.getData().put(DATA_KEY, UPDATED_PREFIX + i);
76+
extension().replace(cm);
77+
});
6878
}
6979

7080
void assertConfigMapData(String dataPrefix) {
71-
await().untilAsserted(() -> IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST)
72-
.forEach(i -> assertConfigMap(i, dataPrefix)));
81+
await()
82+
.untilAsserted(
83+
() ->
84+
IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST)
85+
.forEach(i -> assertConfigMap(i, dataPrefix)));
7386
}
7487

7588
private void assertConfigMap(int i, String prefix) {
@@ -79,17 +92,16 @@ private void assertConfigMap(int i, String prefix) {
7992
}
8093

8194
private void createTestResources() {
82-
IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST).forEach(i -> {
83-
extension().create(createTestResource(i));
84-
});
95+
IntStream.range(0, NUMBER_OF_RESOURCE_TO_TEST)
96+
.forEach(
97+
i -> {
98+
extension().create(createTestResource(i));
99+
});
85100
}
86101

87102
abstract P createTestResource(int index);
88103

89104
abstract Class<P> customResourceClass();
90105

91106
abstract LocallyRunOperatorExtension extension();
92-
93-
94-
95107
}

caffeine-bounded-cache-support/src/test/java/io/javaoperatorsdk/operator/processing/event/source/cache/CaffeineBoundedCacheClusterScopeIT.java

+11-10
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ public class CaffeineBoundedCacheClusterScopeIT
1919
@RegisterExtension
2020
LocallyRunOperatorExtension extension =
2121
LocallyRunOperatorExtension.builder()
22-
.withReconciler(new BoundedCacheClusterScopeTestReconciler(), o -> {
23-
o.withItemStore(boundedItemStore(
24-
new KubernetesClientBuilder().build(),
25-
BoundedCacheClusterScopeTestCustomResource.class,
26-
Duration.ofMinutes(1),
27-
1));
28-
})
22+
.withReconciler(
23+
new BoundedCacheClusterScopeTestReconciler(),
24+
o -> {
25+
o.withItemStore(
26+
boundedItemStore(
27+
new KubernetesClientBuilder().build(),
28+
BoundedCacheClusterScopeTestCustomResource.class,
29+
Duration.ofMinutes(1),
30+
1));
31+
})
2932
.build();
3033

3134
@Override
3235
BoundedCacheClusterScopeTestCustomResource createTestResource(int index) {
3336
var res = new BoundedCacheClusterScopeTestCustomResource();
34-
res.setMetadata(new ObjectMetaBuilder()
35-
.withName(RESOURCE_NAME_PREFIX + index)
36-
.build());
37+
res.setMetadata(new ObjectMetaBuilder().withName(RESOURCE_NAME_PREFIX + index).build());
3738
res.setSpec(new BoundedCacheTestSpec());
3839
res.getSpec().setData(INITIAL_DATA_PREFIX + index);
3940
res.getSpec().setTargetNamespace(extension.getNamespace());

caffeine-bounded-cache-support/src/test/java/io/javaoperatorsdk/operator/processing/event/source/cache/CaffeineBoundedCacheNamespacedIT.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@ class CaffeineBoundedCacheNamespacedIT
1818

1919
@RegisterExtension
2020
LocallyRunOperatorExtension extension =
21-
LocallyRunOperatorExtension.builder().withReconciler(new BoundedCacheTestReconciler(), o -> {
22-
o.withItemStore(boundedItemStore(
23-
new KubernetesClientBuilder().build(), BoundedCacheTestCustomResource.class,
24-
Duration.ofMinutes(1),
25-
1));
26-
})
21+
LocallyRunOperatorExtension.builder()
22+
.withReconciler(
23+
new BoundedCacheTestReconciler(),
24+
o -> {
25+
o.withItemStore(
26+
boundedItemStore(
27+
new KubernetesClientBuilder().build(),
28+
BoundedCacheTestCustomResource.class,
29+
Duration.ofMinutes(1),
30+
1));
31+
})
2732
.build();
2833

2934
BoundedCacheTestCustomResource createTestResource(int index) {
3035
var res = new BoundedCacheTestCustomResource();
31-
res.setMetadata(new ObjectMetaBuilder()
32-
.withName(RESOURCE_NAME_PREFIX + index)
33-
.build());
36+
res.setMetadata(new ObjectMetaBuilder().withName(RESOURCE_NAME_PREFIX + index).build());
3437
res.setSpec(new BoundedCacheTestSpec());
3538
res.getSpec().setData(INITIAL_DATA_PREFIX + index);
3639
res.getSpec().setTargetNamespace(extension.getNamespace());
@@ -46,5 +49,4 @@ Class<BoundedCacheTestCustomResource> customResourceClass() {
4649
LocallyRunOperatorExtension extension() {
4750
return extension;
4851
}
49-
5052
}

0 commit comments

Comments
 (0)