Skip to content

Commit 959e6fb

Browse files
committed
feat: speakeasy configure tests
1 parent cd0403e commit 959e6fb

File tree

695 files changed

+182699
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

695 files changed

+182699
-5
lines changed

.github/workflows/sdk_test.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test
2+
permissions:
3+
checks: write
4+
contents: write
5+
pull-requests: write
6+
statuses: write
7+
id-token: write
8+
"on":
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- '**'
14+
workflow_dispatch:
15+
inputs:
16+
target:
17+
description: Provided SDK target to run tests for, (all) is valid
18+
type: string
19+
jobs:
20+
test:
21+
uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-test.yaml@v15
22+
with:
23+
target: ${{ github.event.inputs.target || 'glean' }}
24+
secrets:
25+
github_access_token: ${{ secrets.GITHUB_TOKEN }}
26+
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}

.speakeasy/gen.lock

Lines changed: 827 additions & 4 deletions
Large diffs are not rendered by default.

.speakeasy/gen.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ generation:
1616
auth:
1717
oAuth2ClientCredentialsEnabled: true
1818
oAuth2PasswordEnabled: true
19+
tests:
20+
generateNewTests: true
21+
skipResponseBodyAssertions: false
1922
java:
2023
version: 0.5.4
2124
additionalDependencies: []

.speakeasy/testfiles/example.file

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello world

.speakeasy/tests.arazzo.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164257,3 +164257,38 @@ workflows:
164257164257
{}
164258164258
type: simple
164259164259
x-speakeasy-test-group: policies
164260+
- workflowId: uploadchatfiles
164261+
steps:
164262+
- stepId: test
164263+
operationId: uploadchatfiles
164264+
requestBody:
164265+
contentType: multipart/form-data
164266+
payload:
164267+
files:
164268+
- 'x-file: example.file'
164269+
successCriteria:
164270+
- condition: $statusCode == 200
164271+
- condition: $response.header.Content-Type == application/json
164272+
- context: $response.body
164273+
condition: |
164274+
{
164275+
"files": [
164276+
{
164277+
"id": "FILE_1234",
164278+
"url": "www.google.com",
164279+
"name": "sample.pdf"
164280+
},
164281+
{
164282+
"id": "FILE_1234",
164283+
"url": "www.google.com",
164284+
"name": "sample.pdf"
164285+
},
164286+
{
164287+
"id": "FILE_1234",
164288+
"url": "www.google.com",
164289+
"name": "sample.pdf"
164290+
}
164291+
]
164292+
}
164293+
type: simple
164294+
x-speakeasy-test-group: chat

.speakeasy/workflow.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ targets:
2121
labelOverride:
2222
fixedValue: Java (API Client)
2323
blocking: false
24+
testing:
25+
enabled: true

build.gradle

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ plugins {
1515
id 'maven-publish'
1616
id 'signing'
1717
id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3'
18+
id "com.adarshr.test-logger" version "3.2.0"
1819
}
1920

2021
compileJava.options.encoding = "UTF-8"
@@ -147,6 +148,45 @@ if (!project.hasProperty('skip.signing')) {
147148
}
148149

149150

151+
tasks.named('test') {
152+
// Use JUnit Platform for unit tests.
153+
useJUnitPlatform()
154+
}
155+
156+
testlogger {
157+
showStandardStreams true
158+
}
159+
160+
test {
161+
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
162+
finalizedBy 'mergeJUnitReports'
163+
}
164+
165+
configurations {
166+
antJUnit
167+
}
168+
169+
task mergeJUnitReports {
170+
ext {
171+
resultsDir = file("$buildDir/test-results/test")
172+
targetDir = file(".speakeasy/reports")
173+
}
174+
175+
doLast {
176+
ant.taskdef(
177+
name: 'junitreport',
178+
classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
179+
classpath: configurations.antJUnit.asPath
180+
)
181+
182+
mkdir targetDir
183+
184+
ant.junitreport(todir: targetDir, tofile: 'tests.xml') {
185+
fileset(dir: resultsDir, includes: 'TEST-*.xml')
186+
}
187+
}
188+
}
189+
150190

151191
dependencies {
152192
api 'com.fasterxml.jackson.core:jackson-annotations:2.18.2'
@@ -155,6 +195,10 @@ dependencies {
155195
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2'
156196
api('org.openapitools:jackson-databind-nullable:0.2.6') {exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'}
157197
implementation 'commons-io:commons-io:2.18.0'
198+
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
199+
testImplementation 'org.mockito:mockito-core:5.14.2'
200+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.4'
201+
antJUnit 'org.apache.ant:ant-junit:1.9.7'
158202
}
159203

160204
apply from: 'build-extras.gradle'

src/main/java/com/glean/api_client/glean_api_client/SDKConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class SDKConfiguration {
2222
private static final String LANGUAGE = "java";
2323
public static final String OPENAPI_DOC_VERSION = "0.9.0";
2424
public static final String SDK_VERSION = "0.5.4";
25-
public static final String GEN_VERSION = "2.623.2";
25+
public static final String GEN_VERSION = "2.623.0";
2626
private static final String BASE_PACKAGE = "com.glean.api_client.glean_api_client";
2727
public static final String USER_AGENT =
2828
String.format("speakeasy-sdk/%s %s %s %s %s",
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3+
*/
4+
package com.glean.api_client.glean_api_client;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
8+
import com.glean.api_client.glean_api_client.models.components.Event;
9+
import com.glean.api_client.glean_api_client.models.components.Feedback;
10+
import com.glean.api_client.glean_api_client.models.operations.FeedbackResponse;
11+
import com.glean.api_client.glean_api_client.utils.Utils;
12+
import java.lang.Exception;
13+
import java.util.List;
14+
import org.junit.jupiter.api.Test;
15+
16+
public class ActivitiesTests {
17+
18+
@Test
19+
public void testActivities_Feedback() throws Exception {
20+
21+
var testHttpClient = Utils.createTestHTTPClient("feedback");
22+
Glean sdk = Glean.builder()
23+
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
24+
.client(testHttpClient)
25+
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
26+
.build();
27+
28+
FeedbackResponse res = sdk.client().activity().feedback()
29+
.feedback1(Feedback.builder()
30+
.trackingTokens(List.of(
31+
"trackingTokens"))
32+
.event(Event.VIEW)
33+
.build())
34+
.call();
35+
assertEquals(200, res.statusCode());
36+
}
37+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3+
*/
4+
package com.glean.api_client.glean_api_client;
5+
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
8+
import com.glean.api_client.glean_api_client.models.components.Activity;
9+
import com.glean.api_client.glean_api_client.models.components.ActivityEvent;
10+
import com.glean.api_client.glean_api_client.models.components.ActivityEventAction;
11+
import com.glean.api_client.glean_api_client.models.components.ActivityEventParams;
12+
import com.glean.api_client.glean_api_client.models.components.Event;
13+
import com.glean.api_client.glean_api_client.models.components.Feedback;
14+
import com.glean.api_client.glean_api_client.models.operations.ActivityResponse;
15+
import com.glean.api_client.glean_api_client.models.operations.FeedbackResponse;
16+
import com.glean.api_client.glean_api_client.utils.Utils;
17+
import java.lang.Exception;
18+
import java.time.OffsetDateTime;
19+
import java.util.List;
20+
import org.junit.jupiter.api.Test;
21+
22+
public class ActivityTests {
23+
24+
@Test
25+
public void testActivity_Activity() throws Exception {
26+
27+
var testHttpClient = Utils.createTestHTTPClient("activity");
28+
Glean sdk = Glean.builder()
29+
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
30+
.client(testHttpClient)
31+
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
32+
.build();
33+
34+
Activity req = Activity.builder()
35+
.events(List.of(
36+
ActivityEvent.builder()
37+
.action(ActivityEventAction.HISTORICAL_VIEW)
38+
.timestamp(OffsetDateTime.parse("2000-01-23T04:56:07.000Z"))
39+
.url("https://example.com/")
40+
.build(),
41+
ActivityEvent.builder()
42+
.action(ActivityEventAction.SEARCH)
43+
.timestamp(OffsetDateTime.parse("2000-01-23T04:56:07.000Z"))
44+
.url("https://example.com/search?q=query")
45+
.params(ActivityEventParams.builder()
46+
.query("query")
47+
.build())
48+
.build(),
49+
ActivityEvent.builder()
50+
.action(ActivityEventAction.VIEW)
51+
.timestamp(OffsetDateTime.parse("2000-01-23T04:56:07.000Z"))
52+
.url("https://example.com/")
53+
.params(ActivityEventParams.builder()
54+
.duration(20L)
55+
.referrer("https://example.com/document")
56+
.build())
57+
.build()))
58+
.build();
59+
60+
ActivityResponse res = sdk.client().activity().report()
61+
.request(req)
62+
.call();
63+
assertEquals(200, res.statusCode());
64+
}
65+
66+
@Test
67+
public void testActivity_Feedback() throws Exception {
68+
69+
var testHttpClient = Utils.createTestHTTPClient("feedback");
70+
Glean sdk = Glean.builder()
71+
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
72+
.client(testHttpClient)
73+
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
74+
.build();
75+
76+
FeedbackResponse res = sdk.client().activity().feedback()
77+
.feedback1(Feedback.builder()
78+
.trackingTokens(List.of(
79+
"trackingTokens"))
80+
.event(Event.VIEW)
81+
.build())
82+
.call();
83+
assertEquals(200, res.statusCode());
84+
}
85+
}

0 commit comments

Comments
 (0)