Skip to content

Commit 39bc29f

Browse files
committed
Kate's comments and fix tests
Signed-off-by: Lukas Kral <[email protected]>
1 parent 150841c commit 39bc29f

File tree

3 files changed

+38
-33
lines changed

3 files changed

+38
-33
lines changed

cluster-operator/src/test/java/io/strimzi/operator/cluster/operator/assembly/KafkaAssemblyOperatorManualRollingUpdatesTest.java

+1-6
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,7 @@ public void testManualPodRollingUpdateWithPodSets(VertxTestContext context) {
349349
}
350350

351351
@Test
352-
public void testManualPodRollingUpdateWithPodSetsWithError1(VertxTestContext context) {
353-
testManualPodRollingUpdateWithPodSetsWithErrorConditions(context, "", true);
354-
}
355-
356-
@Test
357-
public void testManualPodRollingUpdateWithPodSetsWithError3(VertxTestContext context) {
352+
public void testManualPodRollingUpdateWithPodSetsWithError(VertxTestContext context) {
358353
testManualPodRollingUpdateWithPodSetsWithErrorConditions(context, "", false);
359354
}
360355

operator-common/src/main/java/io/strimzi/operator/common/featuregates/FeatureGates.java

+34-21
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@ public FeatureGates(String featureGateConfig) {
3939
boolean value = '+' == featureGate.charAt(0);
4040
featureGate = featureGate.substring(1);
4141

42-
// TODO: Once we have new FeatureGate, we should add back the switch, as it was here before
42+
// TODO: Once we have new FeatureGate, we should add back the switch, example is below
43+
// The switch is not implemented here to pass the spotbugs/checkstyle check.
44+
// switch (featureGate) {
45+
// case CONTINUE_ON_MANUAL_RU_FAILURE:
46+
// setValueOnlyOnce(continueOnManualRUFailure, value);
47+
// break;
48+
// default:
49+
// throw new InvalidConfigurationException("Unknown feature gate " + featureGate + " found in the configuration");
50+
// }
51+
4352
throw new InvalidConfigurationException("Unknown feature gate " + featureGate + " found in the configuration");
4453
}
4554

@@ -82,8 +91,11 @@ private void setValueOnlyOnce(FeatureGate gate, boolean value) {
8291

8392
@Override
8493
public String toString() {
85-
// TODO: Once we have new FeatureGate, we should add it here
8694
return "FeatureGates()";
95+
// TODO: Once we have new FeatureGate, we should add it here (example below)
96+
// return "FeatureGates(" +
97+
// "ContinueReconciliationOnManualRollingUpdateFailure=" + continueOnManualRUFailure.isEnabled() +
98+
// ")";
8799
}
88100

89101
/**
@@ -106,25 +118,26 @@ public String toEnvironmentVariable() {
106118
return String.join(",", gateSettings);
107119
}
108120

109-
// TODO: Once we have new FeatureGate, we should implement the equals method (below is example)
110-
// @Override
111-
// public boolean equals(Object o) {
112-
// if (this == o) {
113-
// return true;
114-
// } else if (o == null || getClass() != o.getClass()) {
115-
// return false;
116-
// } else {
117-
// FeatureGates other = (FeatureGates) o;
118-
// return Objects.equals(continueOnManualRUFailure, other.continueOnManualRUFailure);
119-
// }
120-
// return true;
121-
// }
122-
123-
// TODO: Once we have new FeatureGate, we should implement the hashCode method (below is example)
124-
// @Override
125-
// public int hashCode() {
126-
// return Objects.hashCode(continueOnManualRUFailure);
127-
// }
121+
@Override
122+
public boolean equals(Object o) {
123+
if (this == o) {
124+
return true;
125+
} else if (o == null || getClass() != o.getClass()) {
126+
return false;
127+
} else {
128+
FeatureGates other = (FeatureGates) o;
129+
return other instanceof FeatureGates;
130+
// TODO: Once we have new FeatureGate, we should implement the equals method (below is example)
131+
// return Objects.equals(continueOnManualRUFailure, other.continueOnManualRUFailure);
132+
}
133+
}
134+
135+
@Override
136+
public int hashCode() {
137+
return 1;
138+
// TODO: Once we have new FeatureGate, we should implement the hashCode method (below is example)
139+
// return Objects.hashCode(continueOnManualRUFailure);
140+
}
128141

129142
/**
130143
* Feature gate class represents individual feature fate

operator-common/src/test/java/io/strimzi/operator/common/featuregates/FeatureGatesTest.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import io.strimzi.operator.common.InvalidConfigurationException;
88
import io.strimzi.test.annotations.ParallelSuite;
99
import io.strimzi.test.annotations.ParallelTest;
10-
import org.junit.jupiter.api.Disabled;
1110

1211
import java.util.ArrayList;
1312
import java.util.List;
@@ -52,7 +51,6 @@ public void testAllFeatureGates() {
5251
}
5352

5453
@ParallelTest
55-
@Disabled("Once we add new FeatureGate we should enable this test test.")
5654
public void testFeatureGatesParsing() {
5755
// TODO: Once we have new FeatureGate, we should implement the checks as shown below
5856
// assertThat(new FeatureGates("+ContinueReconciliationOnManualRollingUpdateFailure").continueOnManualRUFailureEnabled(), is(true));
@@ -69,7 +67,6 @@ public void testFeatureGatesParsing() {
6967
}
7068

7169
@ParallelTest
72-
@Disabled("Once we add new FeatureGate we should enable this test suite.")
7370
public void testFeatureGatesEquals() {
7471
// TODO: Once we have new FeatureGate, we should implement the checks as shown below
7572
// FeatureGates fg = new FeatureGates("+ContinueReconciliationOnManualRollingUpdateFailure");
@@ -95,23 +92,20 @@ public void testEmptyFeatureGates() {
9592
}
9693

9794
@ParallelTest
98-
@Disabled("Once we add new FeatureGate we should enable this test suite.")
9995
public void testDuplicateFeatureGateWithSameValue() {
10096
// TODO: Once we have new FeatureGate, we should implement the checks as shown below
10197
// InvalidConfigurationException e = assertThrows(InvalidConfigurationException.class, () -> new FeatureGates("+ContinueReconciliationOnManualRollingUpdateFailure,+ContinueReconciliationOnManualRollingUpdateFailure"));
10298
// assertThat(e.getMessage(), containsString("Feature gate ContinueReconciliationOnManualRollingUpdateFailure is configured multiple times"));
10399
}
104100

105101
@ParallelTest
106-
@Disabled("Once we add new FeatureGate we should enable this test suite.")
107102
public void testDuplicateFeatureGateWithDifferentValue() {
108103
// TODO: Once we have new FeatureGate, we should implement the checks as shown below
109104
// InvalidConfigurationException e = assertThrows(InvalidConfigurationException.class, () -> new FeatureGates("+ContinueReconciliationOnManualRollingUpdateFailure,"));
110105
// assertThat(e.getMessage(), containsString("Feature gate ContinueReconciliationOnManualRollingUpdateFailure is configured multiple times"));
111106
}
112107

113108
@ParallelTest
114-
@Disabled("Once we add new FeatureGate we should enable this test suite.")
115109
public void testMissingSign() {
116110
// TODO: Once we have new FeatureGate, we should implement the checks as shown below
117111
// InvalidConfigurationException e = assertThrows(InvalidConfigurationException.class, () -> new FeatureGates("ContinueReconciliationOnManualRollingUpdateFailure"));
@@ -127,5 +121,8 @@ public void testNonExistingGate() {
127121
@ParallelTest
128122
public void testEnvironmentVariable() {
129123
assertThat(new FeatureGates("").toEnvironmentVariable(), is(""));
124+
// TODO: Once we have new FeatureGate, we should implement the checks as shown below
125+
// assertThat(new FeatureGates("-ContinueReconciliationOnManualRollingUpdateFailure").toEnvironmentVariable(), is("-ContinueReconciliationOnManualRollingUpdateFailure"));
126+
// assertThat(new FeatureGates("+ContinueReconciliationOnManualRollingUpdateFailure").toEnvironmentVariable(), is(""));
130127
}
131128
}

0 commit comments

Comments
 (0)