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

fix(cts): make tests less verbose #453

Merged
merged 3 commits into from
Apr 29, 2022
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
2 changes: 1 addition & 1 deletion .github/.cache_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.2.0
9.2.0.0
45 changes: 33 additions & 12 deletions tests/CTS/methods/requests/templates/java/generateParams.mustache
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
{{#isString}}String {{{key}}}{{suffix}} = "{{{value}}}";{{/isString}}
{{#isInteger}}int {{{key}}}{{suffix}} = {{{value}}};{{/isInteger}}
{{#isLong}}long {{{key}}}{{suffix}} = {{{value}}}L;{{/isLong}}
{{#isDouble}}double {{{key}}}{{suffix}} = {{{value}}};{{/isDouble}}
{{#isBoolean}}boolean {{{key}}}{{suffix}} = {{{value}}};{{/isBoolean}}
{{#isEnum}}{{{objectName}}} {{{key}}}{{suffix}} = {{{objectName}}}.fromValue("{{{value}}}");{{/isEnum}}
{{#isArray}}List{{> generateGenerics}} {{{key}}}{{suffix}} = new ArrayList<>(); { {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.add({{> maybeConvertOneOf}});{{/value}} }{{/isArray}}
{{#isObject}}{{{objectName}}} {{{key}}}{{suffix}} = new {{{objectName}}}();
{ {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.set{{#lambda.titlecase}}{{{key}}}{{/lambda.titlecase}}({{> maybeConvertOneOf}});
{{/value}} }{{/isObject}}{{#isFreeFormObject}}Map{{> forceMapGenerics}} {{{key}}}{{suffix}} = new HashMap<>();
{ {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.put("{{{key}}}", {{> maybeConvertOneOf}});
{{/value}} }{{/isFreeFormObject}}
{{#isString}}
String {{{key}}}{{suffix}} = "{{{value}}}";
{{/isString}}
{{#isInteger}}
int {{{key}}}{{suffix}} = {{{value}}};
{{/isInteger}}
{{#isLong}}
long {{{key}}}{{suffix}} = {{{value}}}L;
{{/isLong}}
{{#isDouble}}
double {{{key}}}{{suffix}} = {{{value}}};
{{/isDouble}}
{{#isBoolean}}
boolean {{{key}}}{{suffix}} = {{{value}}};
{{/isBoolean}}
{{#isEnum}}
{{{objectName}}} {{{key}}}{{suffix}} = {{{objectName}}}.fromValue("{{{value}}}");
{{/isEnum}}
{{#isArray}}
List{{> generateGenerics}} {{{key}}}{{suffix}} = new ArrayList<>(); { {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.add({{> maybeConvertOneOf}});{{/value}} }
{{/isArray}}
{{#isObject}}
{{{objectName}}} {{{key}}}{{suffix}} = new {{{objectName}}}();
{
{{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.set{{#lambda.titlecase}}{{{key}}}{{/lambda.titlecase}}({{> maybeConvertOneOf}});{{/value}}
}
{{/isObject}}
{{#isFreeFormObject}}
Map{{> forceMapGenerics}} {{{key}}}{{suffix}} = new HashMap<>();
{
{{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.put("{{{key}}}", {{> maybeConvertOneOf}});{{/value}}
}
{{/isFreeFormObject}}
51 changes: 28 additions & 23 deletions tests/CTS/methods/requests/templates/php/generateParams.mustache
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
{{#isFirstLevel}}{{#isString}}"{{{value}}}"{{/isString}}
{{#isInteger}}{{{value}}}{{/isInteger}}
{{#isDouble}}{{{value}}}{{/isDouble}}
{{#isLong}}{{{value}}}{{/isLong}}
{{#isBoolean}}{{{value}}}{{/isBoolean}}
{{#isEnum}}"{{{value}}}"{{/isEnum}}
{{#isArray}}[{{#value}}{{> generateParams}}{{/value}}]{{/isArray}}
{{#isObject}}[{{#value}}{{> generateParams}}{{/value}}]{{/isObject}}
{{#isFreeFormObject}}[{{#value}}{{> generateParams}}{{/value}}]{{/isFreeFormObject}}
{{^-last}},{{/-last}}
{{/isFirstLevel}}
{{^isFirstLevel}}
{{^hasGeneratedKey}}"{{{key}}}" => {{/hasGeneratedKey}}
{{#isString}}"{{{value}}}",{{/isString}}
{{#isInteger}}{{{value}}},{{/isInteger}}
{{#isDouble}}{{{value}}},{{/isDouble}}
{{#isLong}}{{{value}}},{{/isLong}}
{{#isBoolean}}{{{value}}},{{/isBoolean}}
{{#isEnum}}"{{{value}}}",{{/isEnum}}
{{#isArray}}[{{#value}}{{> generateParams}}{{/value}}],{{/isArray}}
{{#isObject}}[{{#value}}{{> generateParams}}{{/value}}],{{/isObject}}
{{#isFreeFormObject}}[{{#value}}{{> generateParams}}{{/value}}],{{/isFreeFormObject}}
{{/isFirstLevel}}
{{^isFirstLevel}}{{^hasGeneratedKey}}"{{{key}}}" => {{/hasGeneratedKey}}{{/isFirstLevel}}
{{#isString}}
"{{{value}}}",
{{/isString}}
{{#isEnum}}
"{{{value}}}",
{{/isEnum}}
{{#isInteger}}
{{{value}}},
{{/isInteger}}
{{#isDouble}}
{{{value}}},
{{/isDouble}}
{{#isLong}}
{{{value}}},
{{/isLong}}
{{#isBoolean}}
{{{value}}},
{{/isBoolean}}
{{#isArray}}
[{{#value}}{{> generateParams}}{{/value}}],
{{/isArray}}
{{#isObject}}
[{{#value}}{{> generateParams}}{{/value}}],
{{/isObject}}
{{#isFreeFormObject}}
[{{#value}}{{> generateParams}}{{/value}}],
{{/isFreeFormObject}}
11 changes: 2 additions & 9 deletions tests/CTS/methods/requests/templates/php/requests.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,9 @@ class {{clientPrefix}}Test extends TestCase implements HttpClientInterface
public function test{{#lambda.titlecase}}{{method}}{{/lambda.titlecase}}{{testIndex}}()
{
$client = $this->getClient();

{{#hasParameters}}

$client->{{{method}}}(
$client->{{^hasParameters}}{{{method}}}();{{/hasParameters}}{{#hasParameters}}{{{method}}}(
{{#parametersWithDataType}}{{> generateParams}}{{/parametersWithDataType}}
);
{{/hasParameters}}
{{^hasParameters}}
$client->{{{method}}}();
{{/hasParameters}}
);{{/hasParameters}}

$this->assertRequests([
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,34 +33,24 @@ void addABTestsTest0() {
AddABTestsRequest addABTestsRequest0 = new AddABTestsRequest();
{
String endAt1 = "2022-12-31T00:00:00.000Z";

addABTestsRequest0.setEndAt(endAt1);
String name1 = "myABTest";

addABTestsRequest0.setName(name1);

List<AddABTestsVariant> variant1 = new ArrayList<>();
{
AbTestsVariant variant_02 = new AbTestsVariant();
{
String index3 = "AB_TEST_1";

variant_02.setIndex(index3);

int trafficPercentage3 = 30;

variant_02.setTrafficPercentage(trafficPercentage3);
}
variant1.add(AddABTestsVariant.ofAbTestsVariant(variant_02));

AbTestsVariant variant_12 = new AbTestsVariant();
{
String index3 = "AB_TEST_2";

variant_12.setIndex(index3);

int trafficPercentage3 = 50;

variant_12.setTrafficPercentage(trafficPercentage3);
}
variant1.add(AddABTestsVariant.ofAbTestsVariant(variant_12));
Expand Down Expand Up @@ -103,11 +93,9 @@ void delTest0() {
@DisplayName("allow del method for a custom path with all parameters")
void delTest1() {
String path0 = "/test/all";

Map<String, Object> parameters0 = new HashMap<>();
{
String query1 = "parameters";

parameters0.put("query", query1);
}

Expand Down Expand Up @@ -162,11 +150,9 @@ void getTest0() {
@DisplayName("allow get method for a custom path with all parameters")
void getTest1() {
String path0 = "/test/all";

Map<String, Object> parameters0 = new HashMap<>();
{
String query1 = "parameters";

parameters0.put("query", query1);
}

Expand Down Expand Up @@ -207,7 +193,6 @@ void getABTestTest0() {
@DisplayName("listABTests with minimal parameters")
void listABTestsTest0() {
int offset0 = 42;

int limit0 = 21;

EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> {
Expand Down Expand Up @@ -247,18 +232,14 @@ void postTest0() {
@DisplayName("allow post method for a custom path with all parameters")
void postTest1() {
String path0 = "/test/all";

Map<String, Object> parameters0 = new HashMap<>();
{
String query1 = "parameters";

parameters0.put("query", query1);
}

Map<String, String> body0 = new HashMap<>();
{
String body1 = "parameters";

body0.put("body", body1);
}

Expand Down Expand Up @@ -307,18 +288,14 @@ void putTest0() {
@DisplayName("allow put method for a custom path with all parameters")
void putTest1() {
String path0 = "/test/all";

Map<String, Object> parameters0 = new HashMap<>();
{
String query1 = "parameters";

parameters0.put("query", query1);
}

Map<String, String> body0 = new HashMap<>();
{
String body1 = "parameters";

body0.put("body", body1);
}

Expand Down
Loading