Skip to content

Commit

Permalink
Merge pull request #117 from contentstack/next
Browse files Browse the repository at this point in the history
GCP support implementation
  • Loading branch information
harshithad0703 authored May 13, 2024
2 parents b1087b6 + f619458 commit 0f0807f
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 14 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# CHANGELOG

## v1.14.0

### Date: 13-May-2024

-GCP support implementation

## v1.13.1

### Date: 16-Apr-2024
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.contentstack.sdk</groupId>
<artifactId>java</artifactId>
<version>1.13.1</version>
<version>1.14.0</version>
<packaging>jar</packaging>
<name>contentstack-java</name>
<description>Java SDK for Contentstack Content Delivery API</description>
Expand All @@ -21,10 +21,10 @@
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
<dotenv-source.version>3.0.0</dotenv-source.version>
<rxjava-source.version>3.1.8</rxjava-source.version>
<retrofit-source.version>2.10.0</retrofit-source.version>
<retrofit-source.version>2.11.0</retrofit-source.version>
<loggin.version>5.0.0-alpha.11</loggin.version>
<jococo-plugin.version>0.8.5</jococo-plugin.version>
<lombok-source.version>1.18.30</lombok-source.version>
<lombok-source.version>1.18.32</lombok-source.version>
<junit-jupiter.version>5.10.1</junit-jupiter.version>
<junit-jupiter-engine.version>5.8.0-M1</junit-jupiter-engine.version>
<gson.version>2.8.8</gson.version>
Expand All @@ -36,7 +36,7 @@
<json-version>20240303</json-version>
<jacoco-maven-plugin-version>0.8.7</jacoco-maven-plugin-version>
<maven-release-plugin-version>2.5.3</maven-release-plugin-version>
<contentstack-utils-version>1.2.6</contentstack-utils-version>
<contentstack-utils-version>1.2.7</contentstack-utils-version>
</properties>

<parent>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/contentstack/sdk/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public Config setManagementToken(@NotNull String managementToken) {
* The enum Contentstack region. for now contentstack supports [US, EU, AZURE_NA]
*/
public enum ContentstackRegion {
US, EU, AZURE_NA, AZURE_EU
US, EU, AZURE_NA, AZURE_EU, GCP_NA
}

}
5 changes: 5 additions & 0 deletions src/main/java/com/contentstack/sdk/Stack.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ protected void setConfig(Config config) {
urlDomain = "cdn.contentstack.com";
}
config.host = "azure-eu" + "-" + urlDomain;
} else if (region.equalsIgnoreCase("gcp_na")) {
if (urlDomain.equalsIgnoreCase("cdn.contentstack.io")) {
urlDomain = "cdn.contentstack.com";
}
config.host = "gcp-na" + "-" + urlDomain;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/contentstack/sdk/TestAsset.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public void onCompletion(ResponseType responseType, List<Asset> assets, Error er
assetUid = model.getAssetUid();
Assertions.assertTrue(model.getAssetUid().startsWith("blt"));
Assertions.assertEquals("image/jpeg", model.getFileType());
Assertions.assertEquals("482141", model.getFileSize());
Assertions.assertEquals("1775299", model.getFileSize());
Assertions.assertEquals("phoenix2.jpg", model.getFileName());
Assertions.assertTrue(model.getUrl().endsWith("phoenix2.jpg"));
Assertions.assertTrue(model.toJSON().has("created_at"));
Assertions.assertTrue(model.getCreatedBy().startsWith("blt"));
Assertions.assertEquals("gregory", model.getUpdateAt().getCalendarType());
Assertions.assertTrue(model.getUpdatedBy().startsWith("sys"));
Assertions.assertTrue(model.getUpdatedBy().startsWith("blt"));
Assertions.assertEquals("", model.getDeletedBy());
}
});
Expand All @@ -61,13 +61,13 @@ void testNewAssetZOnlyForOrderByUid() {
public void onCompletion(ResponseType responseType, Error error) {
Assertions.assertTrue(asset.getAssetUid().startsWith("blt"));
Assertions.assertEquals("image/jpeg", asset.getFileType());
Assertions.assertEquals("482141", asset.getFileSize());
Assertions.assertEquals("1775299", asset.getFileSize());
Assertions.assertEquals("phoenix2.jpg", asset.getFileName());
Assertions.assertTrue(asset.getUrl().endsWith("phoenix2.jpg"));
Assertions.assertTrue(asset.toJSON().has("created_at"));
Assertions.assertTrue(asset.getCreatedBy().startsWith("blt"));
Assertions.assertEquals("gregory", asset.getUpdateAt().getCalendarType());
Assertions.assertTrue(asset.getUpdatedBy().startsWith("sys"));
Assertions.assertTrue(asset.getUpdatedBy().startsWith("blt"));
Assertions.assertNull(asset.getDeleteAt());
Assertions.assertEquals("gregory", asset.getCreateAt().getCalendarType());
Assertions.assertEquals("", asset.getDeletedBy());
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/contentstack/sdk/TestAssetLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public void onCompletion(ResponseType responseType, List<Asset> assets, Error er
Asset model = assets.get(0);
Assertions.assertTrue(model.getAssetUid().startsWith("blt"));
assertEquals("image/jpeg", model.getFileType());
assertEquals("482141", model.getFileSize());
assertEquals("1775299", model.getFileSize());
assertEquals("phoenix2.jpg", model.getFileName());
Assertions.assertTrue(model.getUrl().endsWith("phoenix2.jpg"));
Assertions.assertTrue(model.toJSON().has("created_at"));
Assertions.assertTrue(model.getCreatedBy().startsWith("blt"));
assertEquals("gregory", model.getUpdateAt().getCalendarType());
Assertions.assertTrue(model.getUpdatedBy().startsWith("sys"));
Assertions.assertTrue(model.getUpdatedBy().startsWith("blt"));
assertEquals("", model.getDeletedBy());
logger.info("passed...");
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/contentstack/sdk/TestEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void entryGetBoolean() {
@Test
@Order(19)
void entryGetJSONArray() {
Object image = entry.getJSONArray("image");
Object image = entry.getJSONObject("image");
Assertions.assertNotNull(image);
logger.info("passed...");
}
Expand Down
36 changes: 36 additions & 0 deletions src/test/java/com/contentstack/sdk/TestGcpRegion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.contentstack.sdk;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestGcpRegion {
@Test
void testGcpRegionBehaviourGcpNA() {
Config config = new Config();
Config.ContentstackRegion region = Config.ContentstackRegion.GCP_NA;
config.setRegion(region);
Assertions.assertFalse(config.region.name().isEmpty());
Assertions.assertEquals("GCP_NA", config.region.name());
}

@Test
void testGcpNaRegionBehaviourGcpStack() throws IllegalAccessException {
Config config = new Config();
Config.ContentstackRegion region = Config.ContentstackRegion.GCP_NA;
config.setRegion(region);
Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config);
Assertions.assertFalse(config.region.name().isEmpty());
Assertions.assertEquals("GCP_NA", stack.config.region.name());
}

@Test
void testGcpNARegionBehaviourGcpStackHost() throws IllegalAccessException {
Config config = new Config();
Config.ContentstackRegion region = Config.ContentstackRegion.GCP_NA;
config.setRegion(region);
Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config);
Assertions.assertFalse(config.region.name().isEmpty());
Assertions.assertEquals("gcp-na-cdn.contentstack.com", stack.config.host);

}
}
4 changes: 2 additions & 2 deletions src/test/java/com/contentstack/sdk/TestQueryCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ protected void doSomeBackgroundTask(Group group) {
Object titleObj = group.get("title");
String titleStr = group.getString("title");
Boolean titleBool = group.getBoolean("in_stock");
JSONArray titleJSONArray = group.getJSONArray("image");
JSONObject titleImageJSONArray = group.getJSONObject("image");
JSONObject titleJSONObject = group.getJSONObject("publish_details");
Object versionNum = group.getNumber("_version");
Object versionInt = group.getInt("_version");
Expand All @@ -568,7 +568,7 @@ protected void doSomeBackgroundTask(Group group) {
Assertions.assertNotNull(titleObj);
Assertions.assertNotNull(titleStr);
Assertions.assertNotNull(titleBool);
Assertions.assertNotNull(titleJSONArray);
Assertions.assertNotNull(titleImageJSONArray);
Assertions.assertNotNull(titleJSONObject);
Assertions.assertNotNull(versionNum);
Assertions.assertNotNull(versionInt);
Expand Down

0 comments on commit 0f0807f

Please sign in to comment.