Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 26 additions & 0 deletions .github/workflows/sdk_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test
permissions:
checks: write
contents: write
pull-requests: write
statuses: write
id-token: write
"on":
pull_request:
branches:
- main
paths:
- '**'
workflow_dispatch:
inputs:
target:
description: Provided SDK target to run tests for, (all) is valid
type: string
jobs:
test:
uses: speakeasy-api/sdk-generation-action/.github/workflows/sdk-test.yaml@v15
with:
target: ${{ github.event.inputs.target || 'glean' }}
secrets:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
825 changes: 823 additions & 2 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
oAuth2PasswordEnabled: true
tests:
generateNewTests: true
skipResponseBodyAssertions: false
java:
version: 0.5.4
additionalDependencies: []
Expand Down
1 change: 1 addition & 0 deletions .speakeasy/testfiles/example.file
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world
35 changes: 35 additions & 0 deletions .speakeasy/tests.arazzo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164257,3 +164257,38 @@ workflows:
{}
type: simple
x-speakeasy-test-group: policies
- workflowId: uploadchatfiles
steps:
- stepId: test
operationId: uploadchatfiles
requestBody:
contentType: multipart/form-data
payload:
files:
- 'x-file: example.file'
successCriteria:
- condition: $statusCode == 200
- condition: $response.header.Content-Type == application/json
- context: $response.body
condition: |
{
"files": [
{
"id": "FILE_1234",
"url": "www.google.com",
"name": "sample.pdf"
},
{
"id": "FILE_1234",
"url": "www.google.com",
"name": "sample.pdf"
},
{
"id": "FILE_1234",
"url": "www.google.com",
"name": "sample.pdf"
}
]
}
type: simple
x-speakeasy-test-group: chat
5 changes: 3 additions & 2 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ sources:
sourceBlobDigest: sha256:f2a59d8beefedbda0e59b25d09a930e1b907145f784bf8961fc31b862163d964
tags:
- latest
- speakeasy-sdk-regen-1749454026
Glean-OAS:
sourceNamespace: glean-oas
sourceRevisionDigest: sha256:8841834dd58ddd4e2dcf98fc90fbd06fbf3626a29df941503cce55b9548a5317
Expand All @@ -21,7 +20,7 @@ targets:
sourceRevisionDigest: sha256:254ed74184de2e725a0dc2cf521b132b29ece9d3ba6b12fd7e7b1ceaa2e6d043
sourceBlobDigest: sha256:f2a59d8beefedbda0e59b25d09a930e1b907145f784bf8961fc31b862163d964
codeSamplesNamespace: glean-api-specs-java-code-samples
codeSamplesRevisionDigest: sha256:e6b8f88064c039aa8020b1618efbbbcd8ffb72cbc6122b8a74e3879b4545606e
codeSamplesRevisionDigest: sha256:e5b2ea5208c1dc6e24e3a32186332fee5e6235cc612e785611add744c44901fa
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand All @@ -46,3 +45,5 @@ workflow:
labelOverride:
fixedValue: Java (API Client)
blocking: false
testing:
enabled: true
2 changes: 2 additions & 0 deletions .speakeasy/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ targets:
labelOverride:
fixedValue: Java (API Client)
blocking: false
testing:
enabled: true
44 changes: 44 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins {
id 'maven-publish'
id 'signing'
id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3'
id "com.adarshr.test-logger" version "3.2.0"
}

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


tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}

testlogger {
showStandardStreams true
}

test {
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
finalizedBy 'mergeJUnitReports'
}

configurations {
antJUnit
}

task mergeJUnitReports {
ext {
resultsDir = file("$buildDir/test-results/test")
targetDir = file(".speakeasy/reports")
}

doLast {
ant.taskdef(
name: 'junitreport',
classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
classpath: configurations.antJUnit.asPath
)

mkdir targetDir

ant.junitreport(todir: targetDir, tofile: 'tests.xml') {
fileset(dir: resultsDir, includes: 'TEST-*.xml')
}
}
}


dependencies {
api 'com.fasterxml.jackson.core:jackson-annotations:2.18.2'
Expand All @@ -155,6 +195,10 @@ dependencies {
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2'
api('org.openapitools:jackson-databind-nullable:0.2.6') {exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'}
implementation 'commons-io:commons-io:2.18.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
testImplementation 'org.mockito:mockito-core:5.14.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.11.4'
antJUnit 'org.apache.ant:ant-junit:1.9.7'
}

apply from: 'build-extras.gradle'
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
package com.glean.api_client.glean_api_client;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.glean.api_client.glean_api_client.models.components.Event;
import com.glean.api_client.glean_api_client.models.components.Feedback;
import com.glean.api_client.glean_api_client.models.operations.FeedbackResponse;
import com.glean.api_client.glean_api_client.utils.Utils;
import java.lang.Exception;
import java.util.List;
import org.junit.jupiter.api.Test;

public class ActivitiesTests {

@Test
public void testActivities_Feedback() throws Exception {

var testHttpClient = Utils.createTestHTTPClient("feedback");
Glean sdk = Glean.builder()
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
.client(testHttpClient)
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
.build();

FeedbackResponse res = sdk.client().activity().feedback()
.feedback1(Feedback.builder()
.trackingTokens(List.of(
"trackingTokens"))
.event(Event.VIEW)
.build())
.call();
assertEquals(200, res.statusCode());
}
}
100 changes: 100 additions & 0 deletions src/test/java/com/glean/api_client/glean_api_client/AgentsTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
package com.glean.api_client.glean_api_client;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.glean.api_client.glean_api_client.models.components.Agent;
import com.glean.api_client.glean_api_client.models.components.AgentCapabilities;
import com.glean.api_client.glean_api_client.models.components.AgentSchemas;
import com.glean.api_client.glean_api_client.models.components.InputSchema;
import com.glean.api_client.glean_api_client.models.components.OutputSchema;
import com.glean.api_client.glean_api_client.models.operations.GetAgentResponse;
import com.glean.api_client.glean_api_client.models.operations.GetAgentSchemasResponse;
import com.glean.api_client.glean_api_client.utils.Utils;
import java.lang.Exception;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;

public class AgentsTests {

@Test
public void testAgents_Runagent() throws Exception {
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step runagent.test referencing operation runagent not found in document`]");
}

@Test
public void testAgents_Listagents() throws Exception {
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step listagents.test referencing operation listagents not found in document`]");
}

@Test
public void testAgents_Getagentinputs() throws Exception {
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step getagentinputs.test referencing operation getagentinputs not found in document`]");
}

@Test
public void testAgents_GetAgent() throws Exception {

var testHttpClient = Utils.createTestHTTPClient("getAgent");
Glean sdk = Glean.builder()
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
.client(testHttpClient)
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
.build();

GetAgentResponse res = sdk.client().agents().retrieve()
.agentId("<id>")
.call();
assertEquals(200, res.statusCode());
assertEquals(
Agent.builder()
.agentId("<id>")
.name("<value>")
.capabilities(AgentCapabilities.builder()
.build())
.build(),
res.agent().get());
}

@Test
public void testAgents_GetAgentSchemas() throws Exception {

var testHttpClient = Utils.createTestHTTPClient("getAgentSchemas");
Glean sdk = Glean.builder()
.serverURL(Utils.environmentVariable("TEST_SERVER_URL", "http://localhost:18080"))
.client(testHttpClient)
.apiToken("<YOUR_BEARER_TOKEN_HERE>")
.build();

GetAgentSchemasResponse res = sdk.client().agents().retrieveSchemas()
.agentId("<id>")
.call();
assertEquals(200, res.statusCode());
assertEquals(
AgentSchemas.builder()
.agentId("<id>")
.inputSchema(InputSchema.builder()
.build())
.outputSchema(OutputSchema.builder()
.build())
.build(),
res.agentSchemas().get());
}

@Test
public void testAgents_SearchAgents() throws Exception {
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step searchAgents.test referencing operation searchAgents is missing required request body`]");
}

@Test
public void testAgents_CreateAndStreamRun() throws Exception {
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step createAndStreamRun.test referencing operation createAndStreamRun is not currently supported`]");
}

@Test
public void testAgents_CreateAndWaitRun() throws Exception {
Assumptions.assumeTrue(false, "incomplete test found please make sure to address the following errors: [`workflow step createAndWaitRun.test referencing operation createAndWaitRun is missing required request body`]");
}
}
Loading
Loading