|
2 | 2 |
|
3 | 3 | import com.algolia.codegen.Utils;
|
4 | 4 | import com.fasterxml.jackson.core.JsonParseException;
|
| 5 | +import com.fasterxml.jackson.core.JsonProcessingException; |
5 | 6 | import com.fasterxml.jackson.databind.JsonMappingException;
|
6 | 7 | import com.fasterxml.jackson.databind.JsonNode;
|
7 | 8 | import com.google.common.collect.ImmutableMap.Builder;
|
@@ -64,36 +65,36 @@ public void processOpts() {
|
64 | 65 | client = (String) additionalProperties.get("client");
|
65 | 66 | packageName = (String) additionalProperties.get("packageName");
|
66 | 67 |
|
| 68 | + JsonNode config = Utils.readJsonFile("config/clients.config.json"); |
| 69 | + TestConfig testConfig = null; |
67 | 70 | try {
|
68 |
| - JsonNode config = Json |
69 |
| - .mapper() |
70 |
| - .readTree(new File("config/clients.config.json")); |
71 |
| - TestConfig testConfig = Json |
72 |
| - .mapper() |
73 |
| - .treeToValue(config.get(language).get("tests"), TestConfig.class); |
74 |
| - |
75 |
| - setTemplateDir("tests/CTS/methods/requests/templates/" + language); |
76 |
| - setOutputDir("tests/output/" + language); |
77 |
| - String clientName = language.equals("php") |
78 |
| - ? Utils.createClientName(client, language) |
79 |
| - : client; |
80 |
| - supportingFiles.add( |
81 |
| - new SupportingFile( |
82 |
| - "requests.mustache", |
83 |
| - testConfig.outputFolder + "/methods/requests", |
84 |
| - clientName + testConfig.extension |
85 |
| - ) |
86 |
| - ); |
87 |
| - |
88 |
| - if (language.equals("javascript")) { |
89 |
| - supportingFiles.add( |
90 |
| - new SupportingFile("package.mustache", ".", "package.json") |
91 |
| - ); |
92 |
| - } |
93 |
| - } catch (IOException e) { |
| 71 | + testConfig = |
| 72 | + Json |
| 73 | + .mapper() |
| 74 | + .treeToValue(config.get(language).get("tests"), TestConfig.class); |
| 75 | + } catch (JsonProcessingException e) { |
94 | 76 | e.printStackTrace();
|
95 | 77 | System.exit(1);
|
96 | 78 | }
|
| 79 | + |
| 80 | + setTemplateDir("tests/CTS/methods/requests/templates/" + language); |
| 81 | + setOutputDir("tests/output/" + language); |
| 82 | + String clientName = language.equals("php") |
| 83 | + ? Utils.createClientName(client, language) |
| 84 | + : client; |
| 85 | + supportingFiles.add( |
| 86 | + new SupportingFile( |
| 87 | + "requests.mustache", |
| 88 | + testConfig.outputFolder + "/methods/requests", |
| 89 | + clientName + testConfig.extension |
| 90 | + ) |
| 91 | + ); |
| 92 | + |
| 93 | + if (language.equals("javascript")) { |
| 94 | + supportingFiles.add( |
| 95 | + new SupportingFile("package.mustache", ".", "package.json") |
| 96 | + ); |
| 97 | + } |
97 | 98 | }
|
98 | 99 |
|
99 | 100 | @Override
|
|
0 commit comments