Skip to content

Commit aedb4bf

Browse files
🪴 extensions and labels
1 parent 2b1f8ae commit aedb4bf

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

pom.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
53
<modelVersion>4.0.0</modelVersion>
64
<groupId>com.contentstack</groupId>
75
<artifactId>cms</artifactId>
@@ -96,10 +94,7 @@
9694
<nexus-staging-maven-plugin.version>1.6.7</nexus-staging-maven-plugin.version>
9795
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
9896
</properties>
99-
100-
10197
<dependencies>
102-
10398
<dependency>
10499
<groupId>com.google.code.gson</groupId>
105100
<artifactId>gson</artifactId>
@@ -334,7 +329,7 @@
334329
</goals>
335330
</pluginExecutionFilter>
336331
<action>
337-
<ignore/>
332+
<ignore />
338333
</action>
339334
</pluginExecution>
340335
</pluginExecutions>

src/main/java/com/contentstack/cms/stack/Extensions.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.contentstack.cms.stack;
22

33
import com.contentstack.cms.core.CMSRuntimeException;
4+
import com.contentstack.cms.core.Util;
5+
46
import okhttp3.RequestBody;
57
import okhttp3.ResponseBody;
68
import org.jetbrains.annotations.NotNull;
@@ -63,7 +65,7 @@ public Call<ResponseBody> getAll(@NotNull String query, boolean isIncludeBranch)
6365
public Call<ResponseBody> get(@NotNull String customFieldUid, Map<String, Object> queryParam) {
6466
if (queryParam == null) {
6567
queryParam = new HashMap<>();
66-
this.headers.put("Content-Type", "multipart/form-data");
68+
this.headers.put(Util.CONTENT_TYPE, "multipart/form-data");
6769
}
6870
return this.service.getSingle(this.headers, customFieldUid, queryParam);
6971
}
@@ -95,7 +97,7 @@ public Call<ResponseBody> uploadCustomField(Map<String, RequestBody> body, Map<S
9597
if (queryParam == null) {
9698
queryParam = new HashMap<>();
9799
}
98-
this.headers.put("Content-Type", "multipart/form-data");
100+
this.headers.put(Util.CONTENT_TYPE, "multipart/form-data");
99101
return this.service.uploadCustomField(this.headers, body, queryParam);
100102
}
101103

@@ -125,8 +127,8 @@ public Call<ResponseBody> uploadCustomField(Map<String, RequestBody> body, Map<S
125127
public Call<ResponseBody> uploadCustomField(Map<String, Object> queryParam, JSONObject body) {
126128
if (queryParam != null) {
127129
queryParam = new HashMap<>();
128-
if (!this.headers.containsKey("Content-Type")) {
129-
this.headers.put("Content-Type", "application/json");
130+
if (!this.headers.containsKey(Util.CONTENT_TYPE)) {
131+
this.headers.put(Util.CONTENT_TYPE, "application/json");
130132
}
131133
}
132134
return this.service.uploadCustomField(this.headers, queryParam, body);

src/test/java/com/contentstack/cms/stack/ExtensionUnitTest.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
class ExtensionUnitTest {
2121

22-
2322
protected static String AUTHTOKEN = Dotenv.load().get("authToken");
2423
protected static String API_KEY = Dotenv.load().get("api_key");
2524
protected static String _uid = Dotenv.load().get("auth_token");
@@ -35,7 +34,6 @@ static void setup() {
3534
extension = stack.extensions();
3635
}
3736

38-
3937
@Test
4038
void extensionGetAll() {
4139
Map<String, Object> body = new HashMap<>();
@@ -49,7 +47,9 @@ void extensionGetAll() {
4947
Assertions.assertEquals("extensions", request.url().pathSegments().get(1));
5048
Assertions.assertEquals("v3", request.url().pathSegments().get(0));
5149
Assertions.assertNotNull(request.url().encodedQuery());
52-
Assertions.assertEquals("https://api.contentstack.io/v3/extensions?query=%22type%22%3A%22field%22&include_branch=false", request.url().toString());
50+
Assertions.assertEquals(
51+
"https://api.contentstack.io/v3/extensions?query=%22type%22%3A%22field%22&include_branch=false",
52+
request.url().toString());
5353
}
5454

5555
@Test
@@ -65,7 +65,9 @@ void getSingleWithUid() {
6565
Assertions.assertEquals(3, request.url().pathSegments().size());
6666
Assertions.assertEquals("extensions", request.url().pathSegments().get(1));
6767
Assertions.assertEquals("include_count=false&include_branch=false", request.url().encodedQuery());
68-
Assertions.assertEquals("https://api.contentstack.io/v3/extensions/" + _uid + "?include_count=false&include_branch=false", request.url().toString());
68+
Assertions.assertEquals(
69+
"https://api.contentstack.io/v3/extensions/" + _uid + "?include_count=false&include_branch=false",
70+
request.url().toString());
6971
}
7072

7173
@Test
@@ -91,7 +93,9 @@ void extensionUpdate() {
9193
Assertions.assertEquals("extensions", request.url().pathSegments().get(1));
9294
Assertions.assertNotNull(request.body());
9395
Assertions.assertEquals("include_count=false&include_branch=false", request.url().encodedQuery());
94-
Assertions.assertEquals("https://api.contentstack.io/v3/extensions/" + _uid + "?include_count=false&include_branch=false", request.url().toString());
96+
Assertions.assertEquals(
97+
"https://api.contentstack.io/v3/extensions/" + _uid + "?include_count=false&include_branch=false",
98+
request.url().toString());
9599
}
96100

97101
@Test
@@ -119,7 +123,8 @@ void extensionGetSingle() {
119123
Assertions.assertEquals(3, request.url().pathSegments().size());
120124
Assertions.assertEquals("extensions", request.url().pathSegments().get(1));
121125
Assertions.assertEquals("include_branch=false", request.url().encodedQuery());
122-
Assertions.assertEquals("https://api.contentstack.io/v3/extensions/" + _uid + "?include_branch=false", request.url().toString());
126+
Assertions.assertEquals("https://api.contentstack.io/v3/extensions/" + _uid + "?include_branch=false",
127+
request.url().toString());
123128
}
124129

125130
@Test
@@ -147,10 +152,10 @@ public void writeTo(BufferedSink sink) {
147152
Assertions.assertEquals(2, request.url().pathSegments().size());
148153
Assertions.assertEquals("extensions", request.url().pathSegments().get(1));
149154
Assertions.assertEquals("include_branch=false", request.url().encodedQuery());
150-
Assertions.assertEquals("https://api.contentstack.io/v3/extensions?include_branch=false", request.url().toString());
155+
Assertions.assertEquals("https://api.contentstack.io/v3/extensions?include_branch=false",
156+
request.url().toString());
151157
}
152158

153-
154159
@Test
155160
void updateTheExtension() {
156161
JSONObject theQuery = new JSONObject();
@@ -187,5 +192,4 @@ void extensionDeleteAgain() {
187192
Assertions.assertEquals("https://api.contentstack.io/v3/extensions/" + _uid, request.url().toString());
188193
}
189194

190-
191195
}

0 commit comments

Comments
 (0)