Skip to content

Commit e0a353f

Browse files
committed
drop the unchecked suppressions that the warning fixes left behind
`HelmTest` uses the static, non-deprecated `Serialization.unmarshal` with a Jackson `TypeReference`, so the `KubernetesSerialization` constant and two `@SuppressWarnings("unchecked")` go away. `ClusterConnectionReconcilerErrorTest` uses the reified `mock()` of Mockito 5, which needs no suppression and no temporary variable.
1 parent e13c50b commit e0a353f

2 files changed

Lines changed: 9 additions & 12 deletions

File tree

operator/src/test/java/it/aboutbits/postgresql/crd/clusterconnection/ClusterConnectionReconcilerErrorTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ void setUp() {
5252
resource.setSpec(spec);
5353
resource.setMetadata(metadata);
5454

55-
@SuppressWarnings("unchecked")
56-
Context<ClusterConnection> mockedContext = mock(Context.class);
57-
context = mockedContext;
55+
context = mock();
5856
}
5957

6058
@Test

operator/src/test/java/it/aboutbits/postgresql/helm/HelmTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package it.aboutbits.postgresql.helm;
22

3+
import com.fasterxml.jackson.core.type.TypeReference;
34
import com.fasterxml.jackson.databind.JsonNode;
45
import io.fabric8.kubernetes.api.model.ConfigBuilder;
56
import io.fabric8.kubernetes.api.model.LocalObjectReference;
67
import io.fabric8.kubernetes.api.model.Volume;
78
import io.fabric8.kubernetes.api.model.VolumeMount;
89
import io.fabric8.kubernetes.api.model.apps.Deployment;
910
import io.fabric8.kubernetes.client.KubernetesClient;
10-
import io.fabric8.kubernetes.client.utils.KubernetesSerialization;
1111
import io.fabric8.kubernetes.client.utils.Serialization;
1212
import io.quarkus.test.junit.QuarkusTest;
1313
import io.smallrye.common.process.ProcessBuilder;
@@ -37,7 +37,6 @@
3737
@NullMarked
3838
class HelmTest {
3939
private static final String ENV_VAR_KUBECONFIG = "KUBECONFIG";
40-
private static final KubernetesSerialization KUBERNETES_SERIALIZATION = new KubernetesSerialization();
4140

4241
/// The Pod and Container list fields that the chart exposes as free-form Helm values.
4342
private static final List<String> LIST_VALUES = List.of(
@@ -86,19 +85,19 @@ void helmInstall_createsDeployment() throws IOException {
8685

8786
// 1. Verify files exist and contain expected data
8887
// ./Chart.yaml
89-
@SuppressWarnings("unchecked")
90-
Map<String, Object> chartMetadata = KUBERNETES_SERIALIZATION.unmarshal(
88+
Map<String, Object> chartMetadata = Serialization.unmarshal(
9189
Files.newInputStream(chartPath.resolve("Chart.yaml")),
92-
Map.class
90+
new TypeReference<Map<String, Object>>() {
91+
}
9392
);
9493

9594
assertThat(chartMetadata.get("name")).isEqualTo(chartName);
9695

9796
// ./values.yaml
98-
@SuppressWarnings("unchecked")
99-
Map<String, Object> values = KUBERNETES_SERIALIZATION.unmarshal(
97+
Map<String, Object> values = Serialization.unmarshal(
10098
Files.newInputStream(chartPath.resolve("values.yaml")),
101-
Map.class
99+
new TypeReference<Map<String, Object>>() {
100+
}
102101
);
103102

104103
assertThat(values).containsKey(rootValuesAlias);
@@ -124,7 +123,7 @@ void helmInstall_createsDeployment() throws IOException {
124123
// ./values.schema.json
125124
// The type must be declared for every list value, otherwise the generated schema
126125
// falls back to `string` and `helm install` rejects a list.
127-
var valuesSchema = KUBERNETES_SERIALIZATION.unmarshal(
126+
var valuesSchema = Serialization.unmarshal(
128127
Files.newInputStream(chartPath.resolve("values.schema.json")),
129128
JsonNode.class
130129
);

0 commit comments

Comments
 (0)