Skip to content

DX | 09-06-2025 | Release #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/check-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Comment PR
if: github.base_ref == 'master' && github.head_ref != 'next'
if: github.base_ref == 'master' && github.head_ref != 'staging'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
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.
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.
- name: Check branch
if: github.base_ref == 'master' && github.head_ref != 'next'
if: github.base_ref == 'master' && github.head_ref != 'staging'
run: |
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."
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."
exit 1
13 changes: 12 additions & 1 deletion .github/workflows/sca-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup local.properties
run: |
cat << EOF >> local.properties
sdk.dir=$ANDROID_HOME
host="${{ secrets.HOST }}"
APIKey="${{ secrets.API_KEY }}"
deliveryToken="${{ secrets.DELIVERY_TOKEN }}"
environment="${{ secrets.ENVIRONMENT }}"
contentType="${{ secrets.CONTENT_TYPE }}"
assetUid="${{ secrets.ASSET_UID }}"
EOF
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/gradle@master
uses: snyk/actions/setup@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
Expand Down
8 changes: 4 additions & 4 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fileignoreconfig:
- filename: .github/workflows/secrets-scan.yml
ignore_detectors:
- filecontent
- filename: contentstack/src/main/java/com/contentstack/okhttp/internal/spdy/Spdy3.java
checksum: 5f6979f6336684787ff20dc5ccb0ea31665dcb4801845a34770d3bd30387f129
- filename: contentstack/src/main/java/com/contentstack/okhttp/internal/DiskLruCache.java
checksum: 54a52cc9b0d897e500087e7cce65bd1c7c2615a82dad8f5942d87964b3ec4ab2
- filename: contentstack/src/main/java/com/contentstack/okhttp/internal/spdy/Spdy3.java
checksum: 5f6979f6336684787ff20dc5ccb0ea31665dcb4801845a34770d3bd30387f129
- filename: contentstack/src/main/java/com/contentstack/okhttp/internal/DiskLruCache.java
checksum: 54a52cc9b0d897e500087e7cce65bd1c7c2615a82dad8f5942d87964b3ec4ab2
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# CHANGELOG

## Version 4.0.1

### Date: 06-June-2024

- Integration tests added
- Global fields support added

---
## Version 4.0.0

### Date: 12-Sept-2024

- Added support for the upcoming Feature

---

## Version 3.16.1

### Date: 21-August-2024
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2012 - 2024 Contentstack
Copyright (c) 2012 - 2025 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion contentstack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android.buildFeatures.buildConfig true
mavenPublishing {
publishToMavenCentral(SonatypeHost.DEFAULT)
signAllPublications()
coordinates("com.contentstack.sdk", "android", "4.0.0")
coordinates("com.contentstack.sdk", "android", "4.0.1")

pom {
name = "contentstack-android"
Expand Down Expand Up @@ -161,6 +161,8 @@ dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:core:1.5.0'
testImplementation 'org.robolectric:robolectric:4.6.1'

androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static junit.framework.Assert.assertTrue;
import static junit.framework.TestCase.assertEquals;
Expand All @@ -26,7 +27,6 @@ public class AssetTestCase {
private static Stack stack;
private static CountDownLatch latch;


@BeforeClass
public static void oneTimeSetUp() throws Exception {
Context appContext = ApplicationProvider.getApplicationContext();
Expand All @@ -39,125 +39,93 @@ public static void oneTimeSetUp() throws Exception {
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
}


@Test()
public void test_A_getAllAssetsToSetAssetUID() {
final AssetLibrary assetLibrary = stack.assetLibrary();
assetLibrary.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
if (error == null) {
Log.d(TAG, "response: " + assets.get(0).getAssetUid());
assetUid = assets.get(0).getAssetUid();
Log.e(assetUid, assetUid);
}
}
});

}

@Test
public void test_B_VerifyAssetUID() {
public void test_B_VerifyAssetUID() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
if (error == null) {
// Success Block.
Log.d(TAG, "response: " + asset.getAssetUid());
assertEquals(assetUid, asset.getAssetUid());
}
// Success Block.
Log.d(TAG, "response: " + asset.getAssetUid());
assertEquals(assetUid, asset.getAssetUid());
// Unlock the latch to allow the test to proceed
latch.countDown();
}
});
latch.await(5, TimeUnit.SECONDS);
assertEquals("Query was not completed in time", 0, latch.getCount());
}

@Test
public void test_C_Asset_fetch() {
public void test_C_Asset_fetch() throws Exception {
Config config = new Config();
Context appContext = ApplicationProvider.getApplicationContext();
stack = Contentstack.stack(appContext, BuildConfig.APIKey, BuildConfig.deliveryToken, BuildConfig.environment, config);
final CountDownLatch latch = new CountDownLatch(1);
final Asset asset = stack.asset(assetUid);
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
if (error == null) {
assertEquals(BuildConfig.assetUID, asset.getAssetUid());
assertEquals("image/jpeg", asset.getFileType());
assertEquals("phoenix2.jpg", asset.getFileName());
assertEquals("482141", asset.getFileSize());
} else {
assertEquals(105, error.getErrorCode());
}
assertEquals(BuildConfig.assetUID, asset.getAssetUid());
assertEquals("image/jpeg", asset.getFileType());
assertEquals("phoenix2.jpg", asset.getFileName());
latch.countDown();
}
});
latch.await(5, TimeUnit.SECONDS);
}

@Test
public void test_D_AssetLibrary_fetch() {
public void test_E_AssetLibrary_includeCount_fetch() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final AssetLibrary assetLibrary = stack.assetLibrary();
assetLibrary.includeCount();
assetLibrary.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
if (error == null) {
assets.forEach(asset -> {
Log.d(TAG, "----Test--Asset-D--Success----" + asset.toJSON());
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileType());
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getCreatedBy());
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getUpdatedBy());
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileName());
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getFileSize());
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getAssetUid());
Log.d(TAG, "----Test--Asset-D--Success----" + asset.getUrl());
});
}
assertEquals(6, assetLibrary.getCount());
latch.countDown();
}
});
latch.await(5, TimeUnit.SECONDS);
}

@Test
public void test_E_AssetLibrary_includeCount_fetch() {
final AssetLibrary assetLibrary = stack.assetLibrary();
assetLibrary.includeCount();
assetLibrary.fetchAll(new FetchAssetsCallback() {
public void test_G_Include_Dimension() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Asset asset = stack.asset(assetUid);
asset.includeDimension();
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
if (error == null) {
assertEquals(16, assetLibrary.getCount());
}
public void onCompletion(ResponseType responseType, Error error) {
assertEquals(assetUid, asset.getAssetUid());
latch.countDown();
}
});
latch.await(5, TimeUnit.SECONDS);
}

@Test
public void test_F_AssetLibrary_includeRelativeUrl_fetch() {
final AssetLibrary assetLibrary = stack.assetLibrary();
assetLibrary.includeRelativeUrl();
assetLibrary.fetchAll(new FetchAssetsCallback() {
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
if (error == null) {
assertTrue(assets.get(0).getUrl().contains("phoenix2.jpg"));
}
}
});
}

@Test
public void test_G_Include_Dimension() {
public void test_H_include_fallback() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final Asset asset = stack.asset(assetUid);
asset.includeDimension();
asset.includeFallback();
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
if (error == null) {
Log.d(TAG, asset.getAssetUid());
assertEquals(assetUid, asset.getAssetUid());
}
assertEquals(assetUid, asset.getAssetUid());
latch.countDown();
}
});
latch.await(5, TimeUnit.SECONDS);
}


@Test
public void test_H_include_fallback() {
public void test_include_branch() {
final Asset asset = stack.asset(assetUid);
asset.includeFallback();
asset.includeBranch();
asset.fetch(new FetchResultCallback() {
@Override
public void onCompletion(ResponseType responseType, Error error) {
Expand All @@ -169,6 +137,7 @@ public void onCompletion(ResponseType responseType, Error error) {
});
}


@Test
public void test_AZURE_NA() throws Exception {
Config config = new Config();
Expand Down Expand Up @@ -196,74 +165,17 @@ public void test_GCP_NA() throws Exception {
}

@Test
public void test_I_fetch_asset_by_title() {
final AssetLibrary assetLibrary = stack.assetLibrary().where("title", "iot-icon.png");
assetLibrary.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
if (error == null) {
for (Asset asset : assets) {
Log.d("RESULT:", "resp" + asset.json);
}
}
}
});
}

@Test
public void test_J_fetch_asset_by_tags() {
final AssetLibrary assetLibrary = stack.assetLibrary().where("tags","tag1");
assetLibrary.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
if (error == null) {
for( Asset asset : assets){
Log.d("RESULT:", "resp" + asset.json);
}
assertTrue(assets.size()>0);
}
}
});
}

@Test
public void test_K_fetch_asset_by_description() {
final AssetLibrary assetLibrary= stack.assetLibrary().where("description","Page1");
assetLibrary.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
for(Asset asset : assets){
Log.d("RESULT:", "resp" + asset.toJSON());
}
assertTrue(assets.size()>0);
}
});
}

@Test
public void test_L_fetch_asset_invalid() {
final AssetLibrary assetLibrary = stack.assetLibrary().where("title",null);
assetLibrary.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
Log.e("RESULT:", "ERROR:"+ error.errorMessage);
}
});

}

@Test
public void test_M_fetch_asset_empty_title() {
public void test_M_fetch_asset_empty_title() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
final AssetLibrary assetLibrary = stack.assetLibrary().where("title","");
assetLibrary.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
for(Asset asset : assets){
Log.d("RESULT:", "resp: " + asset.toJSON());
}
assertEquals(0, assets.size());
latch.countDown();
}
});
latch.await(5, TimeUnit.SECONDS);
}

}
Loading
Loading