Skip to content

Commit c7217be

Browse files
committed
fix: unit test
1 parent d5affa3 commit c7217be

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

operator-framework/src/main/java/io/javaoperatorsdk/operator/ControllerUtils.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ static String getFinalizer(ResourceController controller) {
1313
if (!Controller.NULL.equals(annotationFinalizerName)) {
1414
return annotationFinalizerName;
1515
}
16+
return getDefaultFinalizerIdentifier(controller);
17+
}
18+
19+
static String getDefaultFinalizerIdentifier(ResourceController controller) {
1620
return controller.getClass().getCanonicalName() + FINALIZER_NAME_SUFFIX;
1721
}
18-
22+
1923
static boolean getGenerationEventProcessing(ResourceController controller) {
2024
return getAnnotation(controller).generationAwareEventProcessing();
2125
}
22-
26+
2327
static <R extends CustomResource> Class<R> getCustomResourceClass(ResourceController<R> controller) {
2428
return (Class<R>) getAnnotation(controller).customResourceClass();
2529
}

operator-framework/src/test/java/io/javaoperatorsdk/operator/ControllerUtilsTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
import org.junit.jupiter.api.Assertions;
1010
import org.junit.jupiter.api.Test;
1111

12-
import static org.junit.jupiter.api.Assertions.*;
12+
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
import static org.junit.jupiter.api.Assertions.assertFalse;
1314

1415
class ControllerUtilsTest {
1516

1617
public static final String CUSTOM_FINALIZER_NAME = "a.custom/finalizer";
1718

1819
@Test
1920
public void returnsValuesFromControllerAnnotationFinalizer() {
20-
Assertions.assertEquals(TestCustomResourceController.CRD_NAME + "/finalizer", ControllerUtils.getFinalizer(new TestCustomResourceController(null)));
21-
assertEquals(TestCustomResource.class, ControllerUtils.getCustomResourceClass(new TestCustomResourceController(null)));
22-
Assertions.assertEquals(TestCustomResourceController.CRD_NAME, ControllerUtils.getCrdName(new TestCustomResourceController(null)));
23-
assertFalse(ControllerUtils.getGenerationEventProcessing(new TestCustomResourceController(null)));
21+
final TestCustomResourceController controller = new TestCustomResourceController(null);
22+
Assertions.assertEquals(ControllerUtils.getDefaultFinalizerIdentifier(controller), ControllerUtils.getFinalizer(controller));
23+
assertEquals(TestCustomResource.class, ControllerUtils.getCustomResourceClass(controller));
24+
Assertions.assertEquals(TestCustomResourceController.CRD_NAME, ControllerUtils.getCrdName(controller));
25+
assertFalse(ControllerUtils.getGenerationEventProcessing(controller));
2426
}
2527

2628
@Controller(crdName = "test.crd", customResourceClass = TestCustomResource.class, finalizerName = CUSTOM_FINALIZER_NAME)

0 commit comments

Comments
 (0)