Skip to content

Commit f56652e

Browse files
authored
Merge pull request #25 from getdyspatch/more-testing
2 parents e55c033 + 57a5e0f commit f56652e

4 files changed

Lines changed: 57 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
token: ${{ secrets.MACHINES_SWU_TOKEN }}
2020
ref: master
2121
- name: Run api setup action
22+
id: setup_action
2223
uses: ./
2324
with:
2425
email: ${{ secrets.QA_USERNAME }}
@@ -37,7 +38,9 @@ jobs:
3738
with:
3839
java-version: 13
3940

40-
- name: Build with Gradle
41+
- name: Build and Test with Gradle
4142
run: ./gradlew build
4243
env:
4344
DYSPATCH_API_KEY: ${{ secrets.DYSPATCH_API_KEY }}
45+
DYSPATCH_TEMPLATE_ID: ${{ steps.setup_action.outputs.templateId }}
46+
DYSPATCH_DRAFT_ID: ${{ steps.setup_action.outputs.draftId }}

build.gradle

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,16 @@ if(hasProperty('target') && target == 'android') {
107107
}
108108

109109
dependencies {
110-
compile 'io.swagger:swagger-annotations:1.5.24'
111-
compile "com.google.code.findbugs:jsr305:3.0.2"
112-
compile 'com.squareup.okhttp3:okhttp:4.7.2'
113-
compile 'com.squareup.okhttp3:logging-interceptor:4.7.2'
114-
compile 'com.google.code.gson:gson:2.8.6'
115-
compile 'io.gsonfire:gson-fire:1.8.4'
116-
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
117-
compile 'javax.annotation:javax.annotation-api:1.3.2'
118-
testCompile 'junit:junit:4.13'
110+
implementation 'io.swagger:swagger-annotations:1.5.24'
111+
implementation "com.google.code.findbugs:jsr305:3.0.2"
112+
implementation 'com.squareup.okhttp3:okhttp:4.7.2'
113+
implementation 'com.squareup.okhttp3:logging-interceptor:4.7.2'
114+
implementation 'com.google.code.gson:gson:2.8.6'
115+
implementation 'io.gsonfire:gson-fire:1.8.4'
116+
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.10'
117+
implementation 'javax.annotation:javax.annotation-api:1.3.2'
118+
testImplementation 'junit:junit:4.13.1'
119+
testImplementation 'org.hamcrest:hamcrest-library:1.3'
119120
}
120121

121122
javadoc {
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Fri Dec 11 12:53:21 PST 2020
2+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
13
distributionBase=GRADLE_USER_HOME
24
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-bin.zip
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
zipStoreBase=GRADLE_USER_HOME

src/test/java/io/dyspatch/client/api/IntegrationTest.java

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,34 @@
33
import io.dyspatch.client.ApiClient;
44
import io.dyspatch.client.ApiException;
55
import 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;
1010
import 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
*/
1621
public 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

Comments
 (0)