Skip to content

Commit

Permalink
Libs(java,js,kt): whitespace fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-onelson committed Oct 23, 2024
1 parent e27e643 commit 6f43344
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 68 deletions.
6 changes: 3 additions & 3 deletions java/lib/src/main/java/com/svix/SvixOptions.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.svix;

public final class SvixOptions {
private static final String DEFAULT_URL = "https://api.svix.com";
private static final String DEFAULT_URL = "https://api.svix.com";

private boolean debug = false;
private String serverUrl;
private boolean debug = false;
private String serverUrl;

public SvixOptions() {
}
Expand Down
119 changes: 58 additions & 61 deletions java/lib/src/test/java/com/svix/KitcheSinkTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,65 +20,62 @@


public class KitcheSinkTest {
static final int HTTP_CONFLICT = 409;

/**
* Builds the client to use in the test cases based on env vars.
* If the env vars are not set, the tests in this class are skipped (via the `assume*` calls.
*/
public static Svix getTestClient() {
String token = System.getenv("SVIX_TOKEN");
assumeNotNull(token);
String serverUrl = System.getenv("SVIX_SERVER_URL");
assumeNotNull(serverUrl);
SvixOptions opts = new SvixOptions();
opts.setServerUrl(serverUrl);
return new Svix(token, opts);
}

@Test
public void testEndpointCRUD() throws Exception {
Svix client = getTestClient();

ApplicationIn appIn = new ApplicationIn();
appIn.setName("test");

ApplicationOut app = client.getApplication().create(appIn);
assertEquals("test", app.getName());

EventTypeIn et1 = new EventTypeIn();
et1.setName("event.started");
et1.setDescription("Something started");
try {
client.getEventType().create(et1);
} catch (ApiException e) {
assertEquals(e.getCode(), HTTP_CONFLICT);
}

EventTypeIn et2 = new EventTypeIn();
et2.setName("event.ended");
et2.setDescription("Something ended");
try {
client.getEventType().create(et2);
} catch (ApiException e) {
assertEquals(e.getCode(), HTTP_CONFLICT);
}

EndpointIn epIn = new EndpointIn();
epIn.setUrl(new URI("https://example.svix.com/"));
EndpointOut ep1 = client.getEndpoint().create(app.getId(), epIn);

EndpointPatch epPatched = new EndpointPatch();
epPatched.addFilterTypesItem("event.started");
epPatched.addFilterTypesItem("event.ended");
EndpointOut ep2 = client.getEndpoint().patch(app.getId(), ep1.getId(), epPatched);

assertEquals(
ep2.getFilterTypes(),
new HashSet<>(Arrays.asList("event.started", "event.ended"))
);


}

static final int HTTP_CONFLICT = 409;

/**
* Builds the client to use in the test cases based on env vars.
* If the env vars are not set, the tests in this class are skipped (via the `assume*` calls.
*/
public static Svix getTestClient() {
String token = System.getenv("SVIX_TOKEN");
assumeNotNull(token);
String serverUrl = System.getenv("SVIX_SERVER_URL");
assumeNotNull(serverUrl);
SvixOptions opts = new SvixOptions();
opts.setServerUrl(serverUrl);
return new Svix(token, opts);
}

@Test
public void testEndpointCRUD() throws Exception {
Svix client = getTestClient();

ApplicationIn appIn = new ApplicationIn();
appIn.setName("test");

ApplicationOut app = client.getApplication().create(appIn);
assertEquals("test", app.getName());

EventTypeIn et1 = new EventTypeIn();
et1.setName("event.started");
et1.setDescription("Something started");
try {
client.getEventType().create(et1);
} catch (ApiException e) {
assertEquals(e.getCode(), HTTP_CONFLICT);
}

EventTypeIn et2 = new EventTypeIn();
et2.setName("event.ended");
et2.setDescription("Something ended");
try {
client.getEventType().create(et2);
} catch (ApiException e) {
assertEquals(e.getCode(), HTTP_CONFLICT);
}

EndpointIn epIn = new EndpointIn();
epIn.setUrl(new URI("https://example.svix.com/"));
EndpointOut ep1 = client.getEndpoint().create(app.getId(), epIn);

EndpointPatch epPatched = new EndpointPatch();
epPatched.addFilterTypesItem("event.started");
epPatched.addFilterTypesItem("event.ended");
EndpointOut ep2 = client.getEndpoint().patch(app.getId(), ep1.getId(), epPatched);

assertEquals(
ep2.getFilterTypes(),
new HashSet<>(Arrays.asList("event.started", "event.ended"))
);
}
}
2 changes: 0 additions & 2 deletions javascript/templates/api/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ export class {{classname}}ResponseProcessor {
* @throws ApiException if the response code was not in [200, 299]
*/
public async {{nickname}}WithHttpInfo(response: ResponseContext): Promise<HttpInfo<{{{returnType}}} {{^returnType}}void{{/returnType}}>> {
// FIXME(onelson): verify that special handling of empty body is no longer required.
const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
{{#responses}}
if (isCodeInRange("{{code}}", response.httpStatusCode)) {
Expand Down Expand Up @@ -266,7 +265,6 @@ export class {{classname}}ResponseProcessor {
return new HttpInfo(response.httpStatusCode, response.headers, response.body, undefined);
{{/returnType}}
}
// FIXME(onelson): verify that special handling of empty body is no longer required.
throw new ApiException<string | {{{fileContentDataType}}} | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
}

Expand Down
2 changes: 1 addition & 1 deletion javascript/templates/http/http.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,4 @@ export class HttpInfo<T> extends ResponseContext {
) {
super(httpStatusCode, headers, body);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,4 @@ import kotlin.random.Random
return value.toString()
{{/toJson}}
}
}
}

0 comments on commit 6f43344

Please sign in to comment.