Skip to content

Commit 1b41bb4

Browse files
tomasroy-ibmGitHub Enterprise
authored andcommitted
SDK expects string content from listKubeconfig (#5)
* regenerated after changing order of swagger context type * tests fixed
1 parent bd3352e commit 1b41bb4

5 files changed

Lines changed: 15 additions & 9 deletions

File tree

modules/examples/src/main/java/com/ibm/cloud/code_engine/ibm_cloud_code_engine/v1/IbmCloudCodeEngineExamples.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828

2929
public class IbmCloudCodeEngineExamples {
3030

31+
// Suppress utility class error by making private constructor
32+
private IbmCloudCodeEngineExamples() {
33+
throw new IllegalStateException("Just an example");
34+
}
35+
3136
public static void main(String[] args) throws Exception {
3237

3338
// Create an IAM authenticator.

modules/ibm-cloud-code-engine/src/main/java/com/ibm/cloud/code_engine/ibm_cloud_code_engine/v1/IbmCloudCodeEngine.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public IbmCloudCodeEngine(String serviceName, Authenticator authenticator) {
8282
* Returns the KUBECONFIG, similar to the output of `kubectl config view --minify=true`.
8383
*
8484
* @param listKubeconfigOptions the {@link ListKubeconfigOptions} containing the options for the call
85-
* @return a {@link ServiceCall} with a void result
85+
* @return a {@link ServiceCall} with a result of type {@link String}
8686
*/
8787
public ServiceCall<String> listKubeconfig(ListKubeconfigOptions listKubeconfigOptions) {
8888
com.ibm.cloud.sdk.core.util.Validator.notNull(listKubeconfigOptions,
@@ -98,7 +98,8 @@ public ServiceCall<String> listKubeconfig(ListKubeconfigOptions listKubeconfigOp
9898
if (listKubeconfigOptions.accept() != null) {
9999
builder.header("Accept", listKubeconfigOptions.accept());
100100
}
101-
ResponseConverter<String> responseConverter = ResponseConverterUtils.getString();
101+
ResponseConverter<String> responseConverter =
102+
ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<String>() { }.getType());
102103
return createServiceCall(builder.build(), responseConverter);
103104
}
104105

modules/ibm-cloud-code-engine/src/main/java/com/ibm/cloud/code_engine/ibm_cloud_code_engine/v1/model/ListKubeconfigOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public String id() {
141141
/**
142142
* Gets the accept.
143143
*
144-
* The type of the response: application/json or text/html. A character encoding can be specified by including a
144+
* The type of the response: text/html or application/json. A character encoding can be specified by including a
145145
* `charset` parameter. For example, 'text/html;charset=utf-8'.
146146
*
147147
* @return the accept

modules/ibm-cloud-code-engine/src/test/java/com/ibm/cloud/code_engine/ibm_cloud_code_engine/v1/IbmCloudCodeEngineTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ public void testConstructorWithNullAuthenticator() throws Throwable {
8787
@Test
8888
public void testListKubeconfigWOptions() throws Throwable {
8989
// Schedule some responses.
90-
String mockResponseBody = "";
90+
String mockResponseBody = "\"operationResponse\"";
9191
String listKubeconfigPath = java.net.URLEncoder.encode("/namespaces/testString/config", "UTF-8").replace("%2F", "/");
9292

9393
server.enqueue(new MockResponse()
94+
.setHeader("Content-type", "text/html")
9495
.setResponseCode(200)
9596
.setBody(mockResponseBody));
9697

@@ -100,15 +101,14 @@ public void testListKubeconfigWOptions() throws Throwable {
100101
ListKubeconfigOptions listKubeconfigOptionsModel = new ListKubeconfigOptions.Builder()
101102
.refreshToken("testString")
102103
.id("testString")
103-
.accept("application/json")
104+
.accept("text/html")
104105
.build();
105106

106107
// Invoke operation with valid options model (positive test)
107108
Response<String> response = ibmCloudCodeEngineService.listKubeconfig(listKubeconfigOptionsModel).execute();
108109
assertNotNull(response);
109110
String responseObj = response.getResult();
110-
// Response does not have a return type. Check that the result is null.
111-
assertEquals(responseObj.length(), 0);
111+
assertNotNull(responseObj);
112112

113113
// Verify the contents of the request
114114
RecordedRequest request = server.takeRequest();

modules/ibm-cloud-code-engine/src/test/java/com/ibm/cloud/code_engine/ibm_cloud_code_engine/v1/model/ListKubeconfigOptionsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ public void testListKubeconfigOptions() throws Throwable {
3737
ListKubeconfigOptions listKubeconfigOptionsModel = new ListKubeconfigOptions.Builder()
3838
.refreshToken("testString")
3939
.id("testString")
40-
.accept("application/json")
40+
.accept("text/html")
4141
.build();
4242
assertEquals(listKubeconfigOptionsModel.refreshToken(), "testString");
4343
assertEquals(listKubeconfigOptionsModel.id(), "testString");
44-
assertEquals(listKubeconfigOptionsModel.accept(), "application/json");
44+
assertEquals(listKubeconfigOptionsModel.accept(), "text/html");
4545
}
4646

4747
@Test(expectedExceptions = IllegalArgumentException.class)

0 commit comments

Comments
 (0)