Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test support for file parameters #2150

Merged
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2024-01-18 23:59:54.919875",
"spec_repo_commit": "7dba000a"
"regenerated": "2024-01-19 15:18:17.130808",
"spec_repo_commit": "b407748b"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-01-18 23:59:54.940202",
"spec_repo_commit": "7dba000a"
"regenerated": "2024-01-19 15:18:17.146445",
"spec_repo_commit": "b407748b"
}
}
}
12 changes: 11 additions & 1 deletion src/test/java/com/datadog/api/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.cucumber.java.Scenario;
import jakarta.ws.rs.client.Client;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -303,7 +304,16 @@ public void addRequestParameter(String parameterName, String value)

Object data = fromJSON(getObjectMapper(), fieldType, templated(value, context));
if (isOptional) {
requestParametersClass.getMethod(propertyName, fieldType).invoke(requestParameters, data);
if (fieldType == File.class) {
String apiVersion = getVersion();
String filePath =
"src/test/resources/com/datadog/api/client/" + apiVersion + "/api/" + data.toString();
requestParametersClass
.getMethod(propertyName, fieldType)
.invoke(requestParameters, new File(filePath));
} else {
requestParametersClass.getMethod(propertyName, fieldType).invoke(requestParameters, data);
}
} else {
parametersArray.add(data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Feature: Organizations
When the request is sent
Then the response status is 400 Bad Request

@skip-go @skip-java @skip-python @skip-ruby @skip-terraform-config @skip-typescript @skip-validation @team:DataDog/team-aaa-identity
@integration-only @skip-terraform-config @skip-validation @team:DataDog/team-aaa-identity
Scenario: Upload IdP metadata returns "OK" response
Given request contains "idp_file" parameter with value "fixtures/organizations/saml_configurations/valid_idp_metadata.xml"
When the request is sent
Expand Down
Loading