Skip to content

Commit 483aa48

Browse files
Merge pull request #76 from contentstack/staging
DX | 09-06-2025 | Release
2 parents a13f72a + 0b1de1c commit 483aa48

24 files changed

+1198
-712
lines changed

.github/workflows/check-branch.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Comment PR
11-
if: github.base_ref == 'master' && github.head_ref != 'next'
11+
if: github.base_ref == 'master' && github.head_ref != 'staging'
1212
uses: thollander/actions-comment-pull-request@v2
1313
with:
1414
message: |
15-
We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
15+
We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
1616
- name: Check branch
17-
if: github.base_ref == 'master' && github.head_ref != 'next'
17+
if: github.base_ref == 'master' && github.head_ref != 'staging'
1818
run: |
19-
echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
19+
echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
2020
exit 1

.github/workflows/sca-scan.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,19 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@master
10+
- name: Setup local.properties
11+
run: |
12+
cat << EOF >> local.properties
13+
sdk.dir=$ANDROID_HOME
14+
host="${{ secrets.HOST }}"
15+
APIKey="${{ secrets.API_KEY }}"
16+
deliveryToken="${{ secrets.DELIVERY_TOKEN }}"
17+
environment="${{ secrets.ENVIRONMENT }}"
18+
contentType="${{ secrets.CONTENT_TYPE }}"
19+
assetUid="${{ secrets.ASSET_UID }}"
20+
EOF
1021
- name: Run Snyk to check for vulnerabilities
11-
uses: snyk/actions/gradle@master
22+
uses: snyk/actions/setup@master
1223
env:
1324
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
1425
with:

.talismanrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fileignoreconfig:
44
- filename: .github/workflows/secrets-scan.yml
55
ignore_detectors:
66
- filecontent
7-
- filename: contentstack/src/main/java/com/contentstack/okhttp/internal/spdy/Spdy3.java
8-
checksum: 5f6979f6336684787ff20dc5ccb0ea31665dcb4801845a34770d3bd30387f129
9-
- filename: contentstack/src/main/java/com/contentstack/okhttp/internal/DiskLruCache.java
10-
checksum: 54a52cc9b0d897e500087e7cce65bd1c7c2615a82dad8f5942d87964b3ec4ab2
7+
- filename: contentstack/src/main/java/com/contentstack/okhttp/internal/spdy/Spdy3.java
8+
checksum: 5f6979f6336684787ff20dc5ccb0ea31665dcb4801845a34770d3bd30387f129
9+
- filename: contentstack/src/main/java/com/contentstack/okhttp/internal/DiskLruCache.java
10+
checksum: 54a52cc9b0d897e500087e7cce65bd1c7c2615a82dad8f5942d87964b3ec4ab2

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# CHANGELOG
22

3+
## Version 4.0.1
4+
5+
### Date: 06-June-2024
6+
7+
- Integration tests added
8+
- Global fields support added
9+
10+
---
11+
## Version 4.0.0
12+
13+
### Date: 12-Sept-2024
14+
15+
- Added support for the upcoming Feature
16+
17+
---
18+
319
## Version 3.16.1
420

521
### Date: 21-August-2024

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2012 - 2024 Contentstack
3+
Copyright (c) 2012 - 2025 Contentstack
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

contentstack/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android.buildFeatures.buildConfig true
1010
mavenPublishing {
1111
publishToMavenCentral(SonatypeHost.DEFAULT)
1212
signAllPublications()
13-
coordinates("com.contentstack.sdk", "android", "4.0.0")
13+
coordinates("com.contentstack.sdk", "android", "4.0.1")
1414

1515
pom {
1616
name = "contentstack-android"
@@ -161,6 +161,8 @@ dependencies {
161161
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
162162
testImplementation 'junit:junit:4.13.2'
163163
androidTestImplementation 'androidx.test:core:1.5.0'
164+
testImplementation 'org.robolectric:robolectric:4.6.1'
165+
164166
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
165167
exclude group: 'com.android.support', module: 'support-annotations'
166168
})

contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java

Lines changed: 48 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import java.util.List;
1212
import java.util.concurrent.CountDownLatch;
13+
import java.util.concurrent.TimeUnit;
1314

1415
import static junit.framework.Assert.assertTrue;
1516
import static junit.framework.TestCase.assertEquals;
@@ -26,7 +27,6 @@ public class AssetTestCase {
2627
private static Stack stack;
2728
private static CountDownLatch latch;
2829

29-
3030
@BeforeClass
3131
public static void oneTimeSetUp() throws Exception {
3232
Context appContext = ApplicationProvider.getApplicationContext();
@@ -39,125 +39,93 @@ public static void oneTimeSetUp() throws Exception {
3939
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
4040
}
4141

42-
43-
@Test()
44-
public void test_A_getAllAssetsToSetAssetUID() {
45-
final AssetLibrary assetLibrary = stack.assetLibrary();
46-
assetLibrary.fetchAll(new FetchAssetsCallback() {
47-
@Override
48-
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
49-
if (error == null) {
50-
Log.d(TAG, "response: " + assets.get(0).getAssetUid());
51-
assetUid = assets.get(0).getAssetUid();
52-
Log.e(assetUid, assetUid);
53-
}
54-
}
55-
});
56-
57-
}
58-
5942
@Test
60-
public void test_B_VerifyAssetUID() {
43+
public void test_B_VerifyAssetUID() throws InterruptedException {
44+
final CountDownLatch latch = new CountDownLatch(1);
6145
final Asset asset = stack.asset(assetUid);
6246
asset.fetch(new FetchResultCallback() {
6347
@Override
6448
public void onCompletion(ResponseType responseType, Error error) {
65-
if (error == null) {
66-
// Success Block.
67-
Log.d(TAG, "response: " + asset.getAssetUid());
68-
assertEquals(assetUid, asset.getAssetUid());
69-
}
49+
// Success Block.
50+
Log.d(TAG, "response: " + asset.getAssetUid());
51+
assertEquals(assetUid, asset.getAssetUid());
52+
// Unlock the latch to allow the test to proceed
53+
latch.countDown();
7054
}
7155
});
56+
latch.await(5, TimeUnit.SECONDS);
57+
assertEquals("Query was not completed in time", 0, latch.getCount());
7258
}
7359

7460
@Test
75-
public void test_C_Asset_fetch() {
61+
public void test_C_Asset_fetch() throws Exception {
62+
Config config = new Config();
63+
Context appContext = ApplicationProvider.getApplicationContext();
64+
stack = Contentstack.stack(appContext, BuildConfig.APIKey, BuildConfig.deliveryToken, BuildConfig.environment, config);
65+
final CountDownLatch latch = new CountDownLatch(1);
7666
final Asset asset = stack.asset(assetUid);
7767
asset.fetch(new FetchResultCallback() {
7868
@Override
7969
public void onCompletion(ResponseType responseType, Error error) {
80-
if (error == null) {
81-
assertEquals(BuildConfig.assetUID, asset.getAssetUid());
82-
assertEquals("image/jpeg", asset.getFileType());
83-
assertEquals("phoenix2.jpg", asset.getFileName());
84-
assertEquals("482141", asset.getFileSize());
85-
} else {
86-
assertEquals(105, error.getErrorCode());
87-
}
70+
assertEquals(BuildConfig.assetUID, asset.getAssetUid());
71+
assertEquals("image/jpeg", asset.getFileType());
72+
assertEquals("phoenix2.jpg", asset.getFileName());
73+
latch.countDown();
8874
}
8975
});
76+
latch.await(5, TimeUnit.SECONDS);
9077
}
9178

9279
@Test
93-
public void test_D_AssetLibrary_fetch() {
80+
public void test_E_AssetLibrary_includeCount_fetch() throws InterruptedException {
81+
final CountDownLatch latch = new CountDownLatch(1);
9482
final AssetLibrary assetLibrary = stack.assetLibrary();
83+
assetLibrary.includeCount();
9584
assetLibrary.fetchAll(new FetchAssetsCallback() {
9685
@Override
9786
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
98-
if (error == null) {
99-
assets.forEach(asset -> {
100-
Log.d(TAG, "----Test--Asset-D--Success----" + asset.toJSON());
101-
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileType());
102-
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getCreatedBy());
103-
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getUpdatedBy());
104-
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileName());
105-
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileSize());
106-
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getAssetUid());
107-
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getUrl());
108-
});
109-
}
87+
assertEquals(6, assetLibrary.getCount());
88+
latch.countDown();
11089
}
11190
});
91+
latch.await(5, TimeUnit.SECONDS);
11292
}
11393

11494
@Test
115-
public void test_E_AssetLibrary_includeCount_fetch() {
116-
final AssetLibrary assetLibrary = stack.assetLibrary();
117-
assetLibrary.includeCount();
118-
assetLibrary.fetchAll(new FetchAssetsCallback() {
95+
public void test_G_Include_Dimension() throws InterruptedException {
96+
final CountDownLatch latch = new CountDownLatch(1);
97+
final Asset asset = stack.asset(assetUid);
98+
asset.includeDimension();
99+
asset.fetch(new FetchResultCallback() {
119100
@Override
120-
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
121-
if (error == null) {
122-
assertEquals(16, assetLibrary.getCount());
123-
}
101+
public void onCompletion(ResponseType responseType, Error error) {
102+
assertEquals(assetUid, asset.getAssetUid());
103+
latch.countDown();
124104
}
125105
});
106+
latch.await(5, TimeUnit.SECONDS);
126107
}
127108

128-
@Test
129-
public void test_F_AssetLibrary_includeRelativeUrl_fetch() {
130-
final AssetLibrary assetLibrary = stack.assetLibrary();
131-
assetLibrary.includeRelativeUrl();
132-
assetLibrary.fetchAll(new FetchAssetsCallback() {
133-
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
134-
if (error == null) {
135-
assertTrue(assets.get(0).getUrl().contains("phoenix2.jpg"));
136-
}
137-
}
138-
});
139-
}
140109

141110
@Test
142-
public void test_G_Include_Dimension() {
111+
public void test_H_include_fallback() throws InterruptedException {
112+
final CountDownLatch latch = new CountDownLatch(1);
143113
final Asset asset = stack.asset(assetUid);
144-
asset.includeDimension();
114+
asset.includeFallback();
145115
asset.fetch(new FetchResultCallback() {
146116
@Override
147117
public void onCompletion(ResponseType responseType, Error error) {
148-
if (error == null) {
149-
Log.d(TAG, asset.getAssetUid());
150-
assertEquals(assetUid, asset.getAssetUid());
151-
}
118+
assertEquals(assetUid, asset.getAssetUid());
119+
latch.countDown();
152120
}
153121
});
122+
latch.await(5, TimeUnit.SECONDS);
154123
}
155124

156-
157125
@Test
158-
public void test_H_include_fallback() {
126+
public void test_include_branch() {
159127
final Asset asset = stack.asset(assetUid);
160-
asset.includeFallback();
128+
asset.includeBranch();
161129
asset.fetch(new FetchResultCallback() {
162130
@Override
163131
public void onCompletion(ResponseType responseType, Error error) {
@@ -169,6 +137,7 @@ public void onCompletion(ResponseType responseType, Error error) {
169137
});
170138
}
171139

140+
172141
@Test
173142
public void test_AZURE_NA() throws Exception {
174143
Config config = new Config();
@@ -196,74 +165,17 @@ public void test_GCP_NA() throws Exception {
196165
}
197166

198167
@Test
199-
public void test_I_fetch_asset_by_title() {
200-
final AssetLibrary assetLibrary = stack.assetLibrary().where("title", "iot-icon.png");
201-
assetLibrary.fetchAll(new FetchAssetsCallback() {
202-
@Override
203-
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
204-
if (error == null) {
205-
for (Asset asset : assets) {
206-
Log.d("RESULT:", "resp" + asset.json);
207-
}
208-
}
209-
}
210-
});
211-
}
212-
213-
@Test
214-
public void test_J_fetch_asset_by_tags() {
215-
final AssetLibrary assetLibrary = stack.assetLibrary().where("tags","tag1");
216-
assetLibrary.fetchAll(new FetchAssetsCallback() {
217-
@Override
218-
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
219-
if (error == null) {
220-
for( Asset asset : assets){
221-
Log.d("RESULT:", "resp" + asset.json);
222-
}
223-
assertTrue(assets.size()>0);
224-
}
225-
}
226-
});
227-
}
228-
229-
@Test
230-
public void test_K_fetch_asset_by_description() {
231-
final AssetLibrary assetLibrary= stack.assetLibrary().where("description","Page1");
232-
assetLibrary.fetchAll(new FetchAssetsCallback() {
233-
@Override
234-
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
235-
for(Asset asset : assets){
236-
Log.d("RESULT:", "resp" + asset.toJSON());
237-
}
238-
assertTrue(assets.size()>0);
239-
}
240-
});
241-
}
242-
243-
@Test
244-
public void test_L_fetch_asset_invalid() {
245-
final AssetLibrary assetLibrary = stack.assetLibrary().where("title",null);
246-
assetLibrary.fetchAll(new FetchAssetsCallback() {
247-
@Override
248-
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
249-
Log.e("RESULT:", "ERROR:"+ error.errorMessage);
250-
}
251-
});
252-
253-
}
254-
255-
@Test
256-
public void test_M_fetch_asset_empty_title() {
168+
public void test_M_fetch_asset_empty_title() throws InterruptedException {
169+
final CountDownLatch latch = new CountDownLatch(1);
257170
final AssetLibrary assetLibrary = stack.assetLibrary().where("title","");
258171
assetLibrary.fetchAll(new FetchAssetsCallback() {
259172
@Override
260173
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
261-
for(Asset asset : assets){
262-
Log.d("RESULT:", "resp: " + asset.toJSON());
263-
}
264174
assertEquals(0, assets.size());
175+
latch.countDown();
265176
}
266177
});
178+
latch.await(5, TimeUnit.SECONDS);
267179
}
268180

269181
}

0 commit comments

Comments
 (0)