33import io .dyspatch .client .ApiClient ;
44import io .dyspatch .client .ApiException ;
55import io .dyspatch .client .Configuration ;
6- import io .dyspatch .client .auth .* ;
7- import io .dyspatch .client .api . DraftsApi ;
8- import io .dyspatch .client .api . TemplatesApi ;
9-
6+ import io .dyspatch .client .auth .ApiKeyAuth ;
7+ import io .dyspatch .client .model . InlineObject ;
8+ import io .dyspatch .client .model . LocalizationKeyRead ;
9+ import io . dyspatch . client . model . LocalizationMetaRead ;
1010import org .junit .Test ;
11+ import static org .hamcrest .MatcherAssert .assertThat ;
12+ import static org .hamcrest .Matchers .*;
13+
14+ import java .util .HashMap ;
15+ import java .util .List ;
1116
1217/**
1318 * Integration tests.
1419 * THESE ARE HAND BUILT AND NOT GENERATED, DO NOT DELETE
1520 */
1621public class IntegrationTest {
17- String version = "application/vnd.dyspatch.2020.04 +json" ;
22+ String version = "application/vnd.dyspatch.2020.11 +json" ;
1823 ApiClient client ;
1924 DraftsApi drafts ;
2025 TemplatesApi templates ;
2126 ApiKeyAuth auth ;
2227
2328 public IntegrationTest () {
2429 client = Configuration .getDefaultApiClient ();
30+ String basePath = System .getenv ("DYSPATCH_BASE_PATH" );
31+ if (basePath != null && basePath .length () > 0 ) {
32+ client .setBasePath (basePath );
33+ }
2534 client .setApiKey (System .getenv ("DYSPATCH_API_KEY" ));
2635 client .setApiKeyPrefix ("Bearer" );
2736
@@ -33,15 +42,39 @@ public IntegrationTest() {
3342 public void getTemplates () throws ApiException {
3443 templates .getTemplates (version , "" );
3544
36- String templateId = "tem_01de5teh6k59kya8q92mb01qzq" ;
45+ String templateId = System . getenv ( "DYSPATCH_TEMPLATE_ID" ) ;
3746 templates .getTemplateById (templateId , "handlebars" , version );
3847 }
3948
4049 @ Test
4150 public void getDrafts () throws ApiException {
4251 drafts .getDrafts (version , "" , "" );
4352
44- String draftId = "tdft_01dxkwr0nevs5h2baa3n3dgktp" ;
53+ String draftId = System . getenv ( "DYSPATCH_DRAFT_ID" ) ;
4554 drafts .getDraftById (draftId , "handlebars" , version );
4655 }
56+
57+ @ Test
58+ public void localizations () throws ApiException {
59+ String draftId = System .getenv ("DYSPATCH_DRAFT_ID" );
60+ InlineObject io = new InlineObject ();
61+ io .name ("moonbeam" );
62+ drafts .saveLocalization (draftId , "en-CA" , version , io );
63+ List <LocalizationMetaRead > localizations = drafts .getLocalizationForDraft (draftId , version );
64+ assertThat (localizations , hasSize (1 ));
65+ assertThat (localizations .get (0 ).getName (), equalTo ("moonbeam" ));
66+
67+ HashMap <String , String > values = new HashMap <>();
68+ values .put ("test" , "value" );
69+ drafts .setTranslation (draftId , "en-CA" , version , values );
70+
71+ List <LocalizationKeyRead > keys = drafts .getDraftLocalizationKeys (draftId , version );
72+ assertThat (keys , hasSize (0 ));
73+
74+ drafts .deleteLocalization (draftId , "en-CA" , version );
75+ localizations = drafts .getLocalizationForDraft (draftId , version );
76+ assertThat (localizations , hasSize (0 ));
77+
78+ drafts .submitDraftForApproval (draftId , version );
79+ }
4780}
0 commit comments