@@ -67,6 +67,11 @@ private OperatorExtension(
6767 this .waitForNamespaceDeletion = waitForNamespaceDeletion ;
6868 }
6969
70+ /**
71+ * Creates a {@link Builder} to set up an {@link OperatorExtension} instance.
72+ *
73+ * @return the builder.
74+ */
7075 public static Builder builder () {
7176 return new Builder ();
7277 }
@@ -96,17 +101,32 @@ public KubernetesClient getKubernetesClient() {
96101 return kubernetesClient ;
97102 }
98103
104+ /**
105+ * Returns the test namespace.
106+ *
107+ * @return the namespace name.
108+ */
99109 public String getNamespace () {
100110 return namespace ;
101111 }
102112
113+ /**
114+ * The list of controllers known by the operator.
115+ *
116+ * @return the list of {@link ResourceController}.
117+ */
103118 @ SuppressWarnings ({"rawtypes" })
104119 public List <ResourceController > getControllers () {
105120 return operator .getControllers ().stream ()
106121 .map (ConfiguredController ::getController )
107122 .collect (Collectors .toUnmodifiableList ());
108123 }
109124
125+ /**
126+ * The list of controllers of the give {@code type} known by the operator.
127+ *
128+ * @return the list of {@link ResourceController} matching the required type.
129+ */
110130 @ SuppressWarnings ({"rawtypes" })
111131 public <T extends ResourceController > T getControllerOfType (Class <T > type ) {
112132 return operator .getControllers ().stream ()
@@ -123,22 +143,42 @@ public <T extends HasMetadata> NonNamespaceOperation<T, KubernetesResourceList<T
123143 return kubernetesClient .resources (type ).inNamespace (namespace );
124144 }
125145
126- public <T extends HasMetadata > T getNamedResource (Class <T > type , String name ) {
146+ /**
147+ * Lookup a resource given its {@code type} and {@code name} in the current test namespace.
148+ *
149+ * @param type Class for resource
150+ * @param name the name of the resource
151+ * @param <T> T type represents resource type
152+ * @return The resource or null if it does not exist
153+ */
154+ public <T extends HasMetadata > T get (Class <T > type , String name ) {
127155 return kubernetesClient .resources (type ).inNamespace (namespace ).withName (name ).get ();
128156 }
129157
158+ /**
159+ * Creates a resource in the current test namespace.
160+ *
161+ * @param type Class for resource
162+ * @param resource the resource to create
163+ * @param <T> T type represents resource type
164+ * @return The resource or null if it does not exist
165+ */
130166 public <T extends HasMetadata > T create (Class <T > type , T resource ) {
131167 return kubernetesClient .resources (type ).inNamespace (namespace ).create (resource );
132168 }
133169
170+ /**
171+ * Replaces a resource in the current test namespace.
172+ *
173+ * @param type Class for resource
174+ * @param resource the resource to create
175+ * @param <T> T type represents resource type
176+ * @return The resource or null if it does not exist
177+ */
134178 public <T extends HasMetadata > T replace (Class <T > type , T resource ) {
135179 return kubernetesClient .resources (type ).inNamespace (namespace ).replace (resource );
136180 }
137181
138- public <T extends HasMetadata > T get (Class <T > type , String name ) {
139- return kubernetesClient .resources (type ).inNamespace (namespace ).withName (name ).get ();
140- }
141-
142182
143183 @ SuppressWarnings ("unchecked" )
144184 protected void before (ExtensionContext context ) {
@@ -225,33 +265,71 @@ protected Builder() {
225265 true );
226266 }
227267
268+ /**
269+ * Configures if the test namespace should be preserved in case of error for troubleshooting.
270+ *
271+ * @param value true if the namespace should be preserved.
272+ * @return this builder
273+ */
228274 public Builder preserveNamespaceOnError (boolean value ) {
229275 this .preserveNamespaceOnError = value ;
230276 return this ;
231277 }
232278
279+ /**
280+ * Configures if the extension should wait for the test namespace deletion.
281+ *
282+ * @param value true if the waiting for namespace deletion is required.
283+ * @return this builder
284+ */
233285 public Builder waitForNamespaceDeletion (boolean value ) {
234286 this .waitForNamespaceDeletion = value ;
235287 return this ;
236288 }
237289
290+ /**
291+ * Defines the {@link ConfigurationService} the operator should use.
292+ *
293+ * @param value the {@link ConfigurationService}.
294+ * @return this builder
295+ */
238296 public Builder withConfigurationService (ConfigurationService value ) {
239297 configurationService = value ;
240298 return this ;
241299 }
242300
301+ /**
302+ * Add a {@link ResourceController} to the operator.
303+ *
304+ * @param value the {@link ResourceController}
305+ * @return this builder
306+ */
243307 @ SuppressWarnings ("rawtypes" )
244308 public Builder withController (ResourceController value ) {
245309 controllers .add (new ControllerSpec (value , null ));
246310 return this ;
247311 }
248312
313+ /**
314+ * Add a {@link ResourceController} to the operator with a {@link Retry} policy.
315+ *
316+ * @param value the {@link ResourceController}
317+ * @param retry the {@link Retry} policy.
318+ * @return this builder
319+ */
249320 @ SuppressWarnings ("rawtypes" )
250321 public Builder withController (ResourceController value , Retry retry ) {
251322 controllers .add (new ControllerSpec (value , retry ));
252323 return this ;
253324 }
254325
326+ /**
327+ * Add a {@link ResourceController} to the operator by providing its class name. The controller
328+ * is instantiated using the default empty constructor.
329+ *
330+ * @param value the {@link ResourceController} type.
331+ * @return this builder
332+ */
255333 @ SuppressWarnings ("rawtypes" )
256334 public Builder withController (Class <? extends ResourceController > value ) {
257335 try {
@@ -262,6 +340,11 @@ public Builder withController(Class<? extends ResourceController> value) {
262340 return this ;
263341 }
264342
343+ /**
344+ * Build a new {@link OperatorExtension} instance.
345+ *
346+ * @return a new {@link OperatorExtension} instance.
347+ */
265348 public OperatorExtension build () {
266349 return new OperatorExtension (
267350 configurationService ,
0 commit comments