Skip to content

Commit

Permalink
fix: provide primitive type setters for ConfigBuilder
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa authored Aug 13, 2024
1 parent 76202f8 commit c70398e
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,71 @@ public void copyInstance(Config instance) {
this.withFile(instance.getFile());
}
}

// Fix #https://github.com/fabric8io/kubernetes-client/issues/6249
// Unboxed builder methods (should allow for the co-existience of <6.13.2 and 6.13.x)
public A withTrustCerts(boolean trustCerts) {
return this.withTrustCerts(Boolean.valueOf(trustCerts));
}

public A withDisableHostnameVerification(boolean disableHostnameVerification) {
return this.withDisableHostnameVerification(Boolean.valueOf(disableHostnameVerification));
}

public A withWebsocketPingInterval(long websocketPingInterval) {
return this.withWebsocketPingInterval(Long.valueOf(websocketPingInterval));
}

public A withConnectionTimeout(int connectionTimeout) {
return this.withConnectionTimeout(Integer.valueOf(connectionTimeout));
}

public A withMaxConcurrentRequests(int maxConcurrentRequests) {
return this.withMaxConcurrentRequests(Integer.valueOf(maxConcurrentRequests));
}

public A withWatchReconnectInterval(int watchReconnectInterval) {
return this.withWatchReconnectInterval(Integer.valueOf(watchReconnectInterval));
}

public A withWatchReconnectLimit(int watchReconnectLimit) {
return this.withWatchReconnectLimit(Integer.valueOf(watchReconnectLimit));
}

public A withUploadRequestTimeout(int uploadRequestTimeout) {
return this.withUploadRequestTimeout(Integer.valueOf(uploadRequestTimeout));
}

public A withRequestRetryBackoffLimit(int requestRetryBackoffLimit) {
return this.withRequestRetryBackoffLimit(Integer.valueOf(requestRetryBackoffLimit));
}

public A withRequestRetryBackoffInterval(int requestRetryBackoffInterval) {
return this.withRequestRetryBackoffInterval(Integer.valueOf(requestRetryBackoffInterval));
}

public A withRequestTimeout(int requestTimeout) {
return this.withRequestTimeout(Integer.valueOf(requestTimeout));
}

public A withScaleTimeout(long scaleTimeout) {
return this.withScaleTimeout(Long.valueOf(scaleTimeout));
}

public A withLoggingInterval(int loggingInterval) {
return this.withLoggingInterval(Integer.valueOf(loggingInterval));
}

public A withHttp2Disable(boolean http2Disable) {
return this.withHttp2Disable(Boolean.valueOf(http2Disable));
}

public A withOnlyHttpWatches(boolean onlyHttpWatches) {
return this.withOnlyHttpWatches(Boolean.valueOf(onlyHttpWatches));
}

public A withAutoConfigure(boolean autoConfigure) {
return this.withAutoConfigure(Boolean.valueOf(autoConfigure));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright (C) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.fabric8.kubernetes.client;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

class ConfigBuilderTest {

@Test
void withPrimitiveValues() {
final ConfigBuilder configBuilder = new ConfigBuilder()
.withAutoConfigure(false)
.withTrustCerts(true)
.withDisableHostnameVerification(true)
.withWebsocketPingInterval(133701)
.withConnectionTimeout(133702)
.withMaxConcurrentRequests(133703)
.withWatchReconnectInterval(133704)
.withWatchReconnectLimit(133705)
.withUploadRequestTimeout(133706)
.withRequestRetryBackoffLimit(133707)
.withRequestRetryBackoffInterval(133708)
.withRequestTimeout(133709)
.withScaleTimeout(133710)
.withLoggingInterval(133711)
.withHttp2Disable(true)
.withOnlyHttpWatches(true);
assertThat(configBuilder.build())
.hasFieldOrPropertyWithValue("autoConfigure", Boolean.FALSE)
.hasFieldOrPropertyWithValue("trustCerts", Boolean.TRUE)
.hasFieldOrPropertyWithValue("disableHostnameVerification", Boolean.TRUE)
.hasFieldOrPropertyWithValue("websocketPingInterval", 133701L)
.hasFieldOrPropertyWithValue("connectionTimeout", 133702)
.hasFieldOrPropertyWithValue("maxConcurrentRequests", 133703)
.hasFieldOrPropertyWithValue("watchReconnectInterval", 133704)
.hasFieldOrPropertyWithValue("watchReconnectLimit", 133705)
.hasFieldOrPropertyWithValue("uploadRequestTimeout", 133706)
.hasFieldOrPropertyWithValue("requestRetryBackoffLimit", 133707)
.hasFieldOrPropertyWithValue("requestRetryBackoffInterval", 133708)
.hasFieldOrPropertyWithValue("requestTimeout", 133709)
.hasFieldOrPropertyWithValue("scaleTimeout", 133710L)
.hasFieldOrPropertyWithValue("loggingInterval", 133711)
.hasFieldOrPropertyWithValue("http2Disable", Boolean.TRUE)
.hasFieldOrPropertyWithValue("onlyHttpWatches", Boolean.TRUE);
}

@Test
void withBoxedValues() {
final ConfigBuilder configBuilder = new ConfigBuilder()
.withAutoConfigure(Boolean.FALSE)
.withTrustCerts(Boolean.TRUE)
.withDisableHostnameVerification(Boolean.TRUE)
.withWebsocketPingInterval(Long.valueOf(133701))
.withConnectionTimeout(Integer.valueOf(133702))
.withMaxConcurrentRequests(Integer.valueOf(133703))
.withWatchReconnectInterval(Integer.valueOf(133704))
.withWatchReconnectLimit(Integer.valueOf(133705))
.withUploadRequestTimeout(Integer.valueOf(133706))
.withRequestRetryBackoffLimit(Integer.valueOf(133707))
.withRequestRetryBackoffInterval(Integer.valueOf(133708))
.withRequestTimeout(Integer.valueOf(133709))
.withScaleTimeout(Long.valueOf(133710))
.withLoggingInterval(Integer.valueOf(133711))
.withHttp2Disable(Boolean.TRUE)
.withOnlyHttpWatches(Boolean.TRUE);
assertThat(configBuilder.build())
.hasFieldOrPropertyWithValue("autoConfigure", false)
.hasFieldOrPropertyWithValue("trustCerts", true)
.hasFieldOrPropertyWithValue("disableHostnameVerification", true)
.hasFieldOrPropertyWithValue("websocketPingInterval", 133701L)
.hasFieldOrPropertyWithValue("connectionTimeout", 133702)
.hasFieldOrPropertyWithValue("maxConcurrentRequests", 133703)
.hasFieldOrPropertyWithValue("watchReconnectInterval", 133704)
.hasFieldOrPropertyWithValue("watchReconnectLimit", 133705)
.hasFieldOrPropertyWithValue("uploadRequestTimeout", 133706)
.hasFieldOrPropertyWithValue("requestRetryBackoffLimit", 133707)
.hasFieldOrPropertyWithValue("requestRetryBackoffInterval", 133708)
.hasFieldOrPropertyWithValue("requestTimeout", 133709)
.hasFieldOrPropertyWithValue("scaleTimeout", 133710L)
.hasFieldOrPropertyWithValue("loggingInterval", 133711)
.hasFieldOrPropertyWithValue("http2Disable", true)
.hasFieldOrPropertyWithValue("onlyHttpWatches", true);
}

}

0 comments on commit c70398e

Please sign in to comment.