|
| 1 | +/* |
| 2 | + * Phrase Strings API Reference |
| 3 | + * |
| 4 | + * The version of the OpenAPI document: 2.0.0 |
| 5 | + |
| 6 | + * |
| 7 | + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 8 | + * https://openapi-generator.tech |
| 9 | + * Do not edit the class manually. |
| 10 | + */ |
| 11 | + |
| 12 | + |
| 13 | +package com.phrase.client.api; |
| 14 | + |
| 15 | +import com.phrase.client.ApiClient; |
| 16 | +import com.phrase.client.ApiException; |
| 17 | +import com.phrase.client.Configuration; |
| 18 | +import com.phrase.client.auth.HttpBasicAuth; |
| 19 | +import com.phrase.client.model.AffectedResources; |
| 20 | +import com.phrase.client.model.KeyCreateParameters; |
| 21 | +import com.phrase.client.model.KeyUpdateParameters; |
| 22 | +import com.phrase.client.model.KeysExcludeParameters; |
| 23 | +import com.phrase.client.model.KeysIncludeParameters; |
| 24 | +import com.phrase.client.model.KeysSearchParameters; |
| 25 | +import com.phrase.client.model.KeysTagParameters; |
| 26 | +import com.phrase.client.model.KeysUntagParameters; |
| 27 | +import com.phrase.client.model.TranslationKey; |
| 28 | +import com.phrase.client.model.TranslationKeyDetails; |
| 29 | +import org.junit.Test; |
| 30 | +import org.junit.Ignore; |
| 31 | +import org.junit.Before; |
| 32 | +import org.junit.After; |
| 33 | +import org.junit.Assert; |
| 34 | + |
| 35 | +import okhttp3.mockwebserver.MockResponse; |
| 36 | +import okhttp3.mockwebserver.MockWebServer; |
| 37 | +import okhttp3.mockwebserver.RecordedRequest; |
| 38 | + |
| 39 | +import java.io.IOException; |
| 40 | + |
| 41 | +import java.util.ArrayList; |
| 42 | +import java.util.HashMap; |
| 43 | +import java.util.List; |
| 44 | +import java.util.Map; |
| 45 | + |
| 46 | +/** |
| 47 | + * API tests for KeysApi |
| 48 | + */ |
| 49 | +public class KeysApiTest { |
| 50 | + |
| 51 | + MockWebServer mockBackend = new MockWebServer(); |
| 52 | + |
| 53 | + private KeysApi api; |
| 54 | + |
| 55 | + @Before |
| 56 | + public void setUp() throws IOException { |
| 57 | + mockBackend.start(); |
| 58 | + |
| 59 | + ApiClient defaultClient = Configuration.getDefaultApiClient(); |
| 60 | + defaultClient.setBasePath(mockBackend.url("/").toString()); |
| 61 | + |
| 62 | + // Configure HTTP basic authorization: Basic |
| 63 | + HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic"); |
| 64 | + Basic.setUsername("TOKEN"); |
| 65 | + Basic.setPassword(""); |
| 66 | + |
| 67 | + api = new KeysApi(defaultClient); |
| 68 | + } |
| 69 | + |
| 70 | + @After |
| 71 | + public void tearDown() throws IOException { |
| 72 | + mockBackend.shutdown(); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Create a key |
| 77 | + * |
| 78 | + * Create a new key. |
| 79 | + * |
| 80 | + * @throws ApiException |
| 81 | + * if the Api call fails |
| 82 | + */ |
| 83 | + @Test |
| 84 | + public void keyCreateTest() throws ApiException, InterruptedException { |
| 85 | + String body = "{\"id\":\"id_example\",\"name\":\"test-key-1\",\"created_at\": \"2015-01-28T09:52:53Z\"}"; |
| 86 | + |
| 87 | + MockResponse mockResponse = new MockResponse() |
| 88 | + .addHeader("Content-Type", "application/json; charset=utf-8") |
| 89 | + .setBody(body); |
| 90 | + |
| 91 | + mockBackend.enqueue(mockResponse); |
| 92 | + |
| 93 | + String projectId = "MY_PROJECT_ID"; |
| 94 | + KeyCreateParameters keyCreateParameters = new KeyCreateParameters() |
| 95 | + .name("test-key-1") |
| 96 | + .autotranslate(true) |
| 97 | + .defaultTranslationContent("some test value which should be created and automatically translated in one call") |
| 98 | + .dataType("string") |
| 99 | + .maxCharactersAllowed(Integer.MAX_VALUE) |
| 100 | + .plural(false); |
| 101 | + String xPhraseAppOTP = null; |
| 102 | + TranslationKeyDetails response = api.keyCreate(projectId, keyCreateParameters, xPhraseAppOTP); |
| 103 | + |
| 104 | + Assert.assertEquals("valid id returned", "id_example", response.getId()); |
| 105 | + RecordedRequest recordedRequest = mockBackend.takeRequest(); |
| 106 | + Assert.assertEquals("Request path", "//projects/MY_PROJECT_ID/keys", recordedRequest.getPath()); |
| 107 | + String requestBody = recordedRequest.getBody().readUtf8(); |
| 108 | + Assert.assertEquals("Request body", "{\"name\":\"test-key-1\",\"plural\":false,\"data_type\":\"string\",\"max_characters_allowed\":2147483647,\"default_translation_content\":\"some test value which should be created and automatically translated in one call\",\"autotranslate\":true}", requestBody); |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Delete a key |
| 113 | + * |
| 114 | + * Delete an existing key. |
| 115 | + * |
| 116 | + * @throws ApiException |
| 117 | + * if the Api call fails |
| 118 | + */ |
| 119 | + @Ignore |
| 120 | + public void keyDeleteTest() throws ApiException { |
| 121 | + String projectId = null; |
| 122 | + String id = null; |
| 123 | + String xPhraseAppOTP = null; |
| 124 | + String branch = null; |
| 125 | + api.keyDelete(projectId, id, xPhraseAppOTP, branch); |
| 126 | + |
| 127 | + // TODO: test validations |
| 128 | + } |
| 129 | + |
| 130 | + /** |
| 131 | + * Get a single key |
| 132 | + * |
| 133 | + * Get details on a single key for a given project. |
| 134 | + * |
| 135 | + * @throws ApiException |
| 136 | + * if the Api call fails |
| 137 | + */ |
| 138 | + @Ignore |
| 139 | + public void keyShowTest() throws ApiException { |
| 140 | + String projectId = null; |
| 141 | + String id = null; |
| 142 | + String xPhraseAppOTP = null; |
| 143 | + String branch = null; |
| 144 | + TranslationKeyDetails response = api.keyShow(projectId, id, xPhraseAppOTP, branch); |
| 145 | + |
| 146 | + // TODO: test validations |
| 147 | + } |
| 148 | + |
| 149 | + /** |
| 150 | + * Update a key |
| 151 | + * |
| 152 | + * Update an existing key. |
| 153 | + * |
| 154 | + * @throws ApiException |
| 155 | + * if the Api call fails |
| 156 | + */ |
| 157 | + @Ignore |
| 158 | + public void keyUpdateTest() throws ApiException { |
| 159 | + String projectId = null; |
| 160 | + String id = null; |
| 161 | + KeyUpdateParameters keyUpdateParameters = null; |
| 162 | + String xPhraseAppOTP = null; |
| 163 | + TranslationKeyDetails response = api.keyUpdate(projectId, id, keyUpdateParameters, xPhraseAppOTP); |
| 164 | + |
| 165 | + // TODO: test validations |
| 166 | + } |
| 167 | + |
| 168 | + /** |
| 169 | + * Delete collection of keys |
| 170 | + * |
| 171 | + * Delete all keys matching query. Same constraints as list. Please limit the number of affected keys to about 1,000 as you might experience timeouts otherwise. |
| 172 | + * |
| 173 | + * @throws ApiException |
| 174 | + * if the Api call fails |
| 175 | + */ |
| 176 | + @Ignore |
| 177 | + public void keysDeleteCollectionTest() throws ApiException { |
| 178 | + String projectId = null; |
| 179 | + String xPhraseAppOTP = null; |
| 180 | + String branch = null; |
| 181 | + String q = null; |
| 182 | + String localeId = null; |
| 183 | + AffectedResources response = api.keysDeleteCollection(projectId, xPhraseAppOTP, branch, q, localeId); |
| 184 | + |
| 185 | + // TODO: test validations |
| 186 | + } |
| 187 | + |
| 188 | + /** |
| 189 | + * Exclude a locale on a collection of keys |
| 190 | + * |
| 191 | + * Exclude a locale on keys matching query. Same constraints as list. |
| 192 | + * |
| 193 | + * @throws ApiException |
| 194 | + * if the Api call fails |
| 195 | + */ |
| 196 | + @Ignore |
| 197 | + public void keysExcludeTest() throws ApiException { |
| 198 | + String projectId = null; |
| 199 | + KeysExcludeParameters keysExcludeParameters = null; |
| 200 | + String xPhraseAppOTP = null; |
| 201 | + AffectedResources response = api.keysExclude(projectId, keysExcludeParameters, xPhraseAppOTP); |
| 202 | + |
| 203 | + // TODO: test validations |
| 204 | + } |
| 205 | + |
| 206 | + /** |
| 207 | + * Include a locale on a collection of keys |
| 208 | + * |
| 209 | + * Include a locale on keys matching query. Same constraints as list. |
| 210 | + * |
| 211 | + * @throws ApiException |
| 212 | + * if the Api call fails |
| 213 | + */ |
| 214 | + @Ignore |
| 215 | + public void keysIncludeTest() throws ApiException { |
| 216 | + String projectId = null; |
| 217 | + KeysIncludeParameters keysIncludeParameters = null; |
| 218 | + String xPhraseAppOTP = null; |
| 219 | + AffectedResources response = api.keysInclude(projectId, keysIncludeParameters, xPhraseAppOTP); |
| 220 | + |
| 221 | + // TODO: test validations |
| 222 | + } |
| 223 | + |
| 224 | + /** |
| 225 | + * List keys |
| 226 | + * |
| 227 | + * List all keys for the given project. Alternatively you can POST requests to /search. |
| 228 | + * |
| 229 | + * @throws ApiException |
| 230 | + * if the Api call fails |
| 231 | + */ |
| 232 | + @Ignore |
| 233 | + public void keysListTest() throws ApiException { |
| 234 | + String projectId = null; |
| 235 | + String xPhraseAppOTP = null; |
| 236 | + Integer page = null; |
| 237 | + Integer perPage = null; |
| 238 | + String branch = null; |
| 239 | + String sort = null; |
| 240 | + String order = null; |
| 241 | + String q = null; |
| 242 | + String localeId = null; |
| 243 | + List<TranslationKey> response = api.keysList(projectId, xPhraseAppOTP, page, perPage, branch, sort, order, q, localeId); |
| 244 | + |
| 245 | + // TODO: test validations |
| 246 | + } |
| 247 | + |
| 248 | + /** |
| 249 | + * Search keys |
| 250 | + * |
| 251 | + * Search keys for the given project matching query. |
| 252 | + * |
| 253 | + * @throws ApiException |
| 254 | + * if the Api call fails |
| 255 | + */ |
| 256 | + @Ignore |
| 257 | + public void keysSearchTest() throws ApiException { |
| 258 | + String projectId = null; |
| 259 | + KeysSearchParameters keysSearchParameters = null; |
| 260 | + String xPhraseAppOTP = null; |
| 261 | + Integer page = null; |
| 262 | + Integer perPage = null; |
| 263 | + List<TranslationKey> response = api.keysSearch(projectId, keysSearchParameters, xPhraseAppOTP, page, perPage); |
| 264 | + |
| 265 | + // TODO: test validations |
| 266 | + } |
| 267 | + |
| 268 | + /** |
| 269 | + * Add tags to collection of keys |
| 270 | + * |
| 271 | + * Tags all keys matching query. Same constraints as list. |
| 272 | + * |
| 273 | + * @throws ApiException |
| 274 | + * if the Api call fails |
| 275 | + */ |
| 276 | + @Ignore |
| 277 | + public void keysTagTest() throws ApiException { |
| 278 | + String projectId = null; |
| 279 | + KeysTagParameters keysTagParameters = null; |
| 280 | + String xPhraseAppOTP = null; |
| 281 | + AffectedResources response = api.keysTag(projectId, keysTagParameters, xPhraseAppOTP); |
| 282 | + |
| 283 | + // TODO: test validations |
| 284 | + } |
| 285 | + |
| 286 | + /** |
| 287 | + * Remove tags from collection of keys |
| 288 | + * |
| 289 | + * Removes specified tags from keys matching query. |
| 290 | + * |
| 291 | + * @throws ApiException |
| 292 | + * if the Api call fails |
| 293 | + */ |
| 294 | + @Ignore |
| 295 | + public void keysUntagTest() throws ApiException { |
| 296 | + String projectId = null; |
| 297 | + KeysUntagParameters keysUntagParameters = null; |
| 298 | + String xPhraseAppOTP = null; |
| 299 | + AffectedResources response = api.keysUntag(projectId, keysUntagParameters, xPhraseAppOTP); |
| 300 | + |
| 301 | + // TODO: test validations |
| 302 | + } |
| 303 | + |
| 304 | +} |
0 commit comments