-
Notifications
You must be signed in to change notification settings - Fork 21
fix(cts): gen for java #360
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c00cfec
fix(cts): gen for java
millotp 522943d
format
millotp 8d8783d
try fix it with cache and partial templates
millotp da7b312
style
millotp e5623f3
fix query params issue
millotp 13c9051
finallyyyyyyyyyyyyyyyyy
millotp 23798cd
oops
millotp 1bbab4d
undo bundled
millotp 96eee16
merge with main
millotp 6ed9139
fix type for custom request
millotp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/CTS/methods/requests/templates/java/forceMapGenerics.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{#isFreeFormObject}}<String, {{#value.0}}{{#isAnyType}}Object{{/isAnyType}}{{^isAnyType}}{{#oneOfModel}}{{classname}}{{/oneOfModel}}{{^oneOfModel}}{{objectName}}{{/oneOfModel}}{{> generateGenerics}}{{/isAnyType}}{{/value.0}}>{{/isFreeFormObject}} |
2 changes: 2 additions & 0 deletions
2
tests/CTS/methods/requests/templates/java/generateGenerics.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{#isArray}}{{#value.0}}<{{#oneOfModel}}{{classname}}{{/oneOfModel}}{{^oneOfModel}}{{objectName}}{{/oneOfModel}}{{> generateGenerics}}>{{/value.0}}{{/isArray}} | ||
{{#isFreeFormObject}}{{^isSimpleObject}}<String, {{#value.0}}{{#isAnyType}}Object{{/isAnyType}}{{^isAnyType}}{{#oneOfModel}}{{classname}}{{/oneOfModel}}{{^oneOfModel}}{{objectName}}{{/oneOfModel}}{{> generateGenerics}}{{/isAnyType}}{{/value.0}}>{{/isSimpleObject}}{{/isFreeFormObject}} |
11 changes: 6 additions & 5 deletions
11
tests/CTS/methods/requests/templates/java/generateParams.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
{{#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 {{{key}}}{{suffix}} = new ArrayList(); { {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.add({{{key}}}{{suffix}});{{/value}} }{{/isArray}} | ||
{{#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}}({{{key}}}{{suffix}}); | ||
{{/value}} }{{/isObject}}{{#isFreeFormObject}}HashMap {{{key}}}{{suffix}} = new HashMap<String, Object>(); | ||
{ {{#value}}{{> generateParams}}{{parent}}{{parentSuffix}}.put("{{{key}}}", {{{key}}}{{suffix}}); | ||
{{/value}} }{{/isFreeFormObject}} | ||
{ {{#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}} |
1 change: 1 addition & 0 deletions
1
tests/CTS/methods/requests/templates/java/maybeConvertOneOf.mustache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{#oneOfModel}}{{{classname}}}.of{{{name}}}({{{key}}}{{suffix}}){{/oneOfModel}}{{^oneOfModel}}{{{key}}}{{suffix}}{{/oneOfModel}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package com.algolia.methods.requests; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
import java.util.*; | ||
|
@@ -13,8 +14,8 @@ import com.google.gson.reflect.TypeToken; | |
|
||
import com.algolia.JSON; | ||
import com.algolia.Pair; | ||
import com.algolia.model.search.*; | ||
import com.algolia.search.{{client}}; | ||
import com.algolia.model.{{import}}.*; | ||
import com.algolia.api.{{client}}; | ||
import com.algolia.utils.echo.*; | ||
import org.skyscreamer.jsonassert.JSONAssert; | ||
import org.skyscreamer.jsonassert.JSONCompareMode; | ||
|
@@ -36,7 +37,7 @@ class {{client}}Tests { | |
{{#parametersWithDataType}}{{> generateParams}}{{/parametersWithDataType}} | ||
|
||
EchoResponseInterface req = (EchoResponseInterface) assertDoesNotThrow(() -> { | ||
return client.{{method}}({{#parametersWithDataType}}{{#oneOfModel}}{{{classname}}}.of{{{name}}}({{{key}}}{{suffix}}){{/oneOfModel}}{{^oneOfModel}}{{{key}}}{{suffix}}{{/oneOfModel}}{{^-last}},{{/-last}}{{/parametersWithDataType}}); | ||
return client.{{method}}({{#parametersWithDataType}}{{> maybeConvertOneOf}}{{^-last}},{{/-last}}{{/parametersWithDataType}}); | ||
}); | ||
|
||
assertEquals(req.getPath(), "{{{request.path}}}"); | ||
|
@@ -49,10 +50,16 @@ class {{client}}Tests { | |
{{/request.data}} | ||
|
||
{{#request.searchParams}} | ||
HashMap<String, String> expectedQuery = JSON.deserialize("{{#lambda.escapequotes}}{{{request.searchParams}}}{{/lambda.escapequotes}}", new TypeToken<HashMap<String, String>>() {}.getType()); | ||
Map<String, String> expectedQuery = JSON.deserialize("{{#lambda.escapequotes}}{{{request.searchParams}}}{{/lambda.escapequotes}}", new TypeToken<HashMap<String, String>>() {}.getType()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not correct according to this ticket but will be fixed in another PR. |
||
List<Pair> actualQuery = req.getQueryParams(); | ||
for (Pair p : actualQuery) { | ||
assertEquals(expectedQuery.get(p.getName()), p.getValue()); | ||
for (Map.Entry<String, String> entry : expectedQuery.entrySet()) { | ||
boolean found = false; | ||
for (Pair p : actualQuery) { | ||
if (p.getName().equals(entry.getKey()) && p.getValue().equals(entry.getValue())) { | ||
found = true; | ||
} | ||
} | ||
assertTrue(found, "Query parameter " + entry.getKey() + " not found in the actual query"); | ||
} | ||
{{/request.searchParams}} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other solution is to leverage the
modelPackage
,apiPackage
andinvokerPackage
openapi-generator options so we only have one destination per client (...java-2/clientName
), not sure if it works but can make those paths easier to scopeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anyway this is ought to change soon, those files are not pushed and should not be relevant to the cache, we cannot have any generated files in that list.