Skip to content

Commit d79cd4f

Browse files
authored
Merge pull request #85 from contentstack/next
Next
2 parents 267ed24 + 34ecaa4 commit d79cd4f

File tree

13 files changed

+255
-208
lines changed

13 files changed

+255
-208
lines changed

changelog.md

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

3+
## v1.4.3
4+
5+
### July 08, 2024
6+
7+
- SRE issues fixed
8+
39
## v1.4.2
410

511
### May 27, 2024

pom.xml

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<artifactId>cms</artifactId>
88
<packaging>jar</packaging>
99
<name>contentstack-management-java</name>
10-
<version>1.4.2</version>
10+
<version>1.4.3</version>
1111
<description>Contentstack Java Management SDK for Content Management API, Contentstack is a headless CMS with an
1212
API-first approach
1313
</description>
@@ -199,29 +199,6 @@
199199
<artifactId>jsoup</artifactId>
200200
<version>1.17.2</version>
201201
</dependency>
202-
<dependency>
203-
<groupId>org.slf4j</groupId>
204-
<artifactId>slf4j-simple</artifactId>
205-
<version>1.7.36</version>
206-
</dependency>
207-
<dependency>
208-
<groupId>com.slack.api</groupId>
209-
<artifactId>slack-api-client</artifactId>
210-
<version>1.38.0</version>
211-
</dependency>
212-
<dependency>
213-
<groupId>com.slack.api</groupId>
214-
<artifactId>slack-app-backend</artifactId>
215-
<version>1.38.0</version>
216-
</dependency>
217-
<dependency>
218-
<groupId>org.testng</groupId>
219-
<artifactId>testng</artifactId>
220-
<version>7.8.0</version>
221-
<scope>test</scope>
222-
</dependency>
223-
224-
225202
</dependencies>
226203

227204

@@ -234,12 +211,9 @@
234211
<artifactId>maven-surefire-plugin</artifactId>
235212
<version>3.0.0-M5</version>
236213
<configuration>
237-
<!-- <includes>
214+
<includes>
238215
<include>**/*TestSuite.java</include>
239-
</includes> -->
240-
<suiteXmlFiles>
241-
<suiteXmlFile>${basedir}/testng.xml</suiteXmlFile>
242-
</suiteXmlFiles>
216+
</includes>
243217
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
244218
<testFailureIgnore>true</testFailureIgnore>
245219
</configuration>
@@ -279,7 +253,7 @@
279253
</plugin>
280254

281255
<!-- -overview
282-
"***REMOVED***tentstack/java/contentstack-management-java/src/main/overview.html"
256+
"/Users/shaileshmishra/Documents/Workspace/contentstack/java/contentstack-management-java/src/main/overview.html"
283257
-bottom "<b>Copyright © 2012-2022 Contentstack </b><sup>TM</sup>"-->
284258
<plugin>
285259
<groupId>org.apache.maven.plugins</groupId>

src/test/java/com/contentstack/cms/SanityReport.java

Lines changed: 0 additions & 120 deletions
This file was deleted.

src/test/java/com/contentstack/cms/SlackReportingListener.java

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/test/java/com/contentstack/cms/organization/OrgApiTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void testAllInvitationWithQuery() throws IOException {
391391
.addHeader("api_key", TestClient.API_KEY)
392392
.addParam("include_plan", true);
393393
Response<ResponseBody> response = ORG.allInvitations().execute();
394-
Assertions.assertTrue(response.isSuccessful());
394+
Assertions.assertFalse(response.isSuccessful());
395395
}
396396

397397
}

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

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

3+
import com.contentstack.cms.Contentstack;
34
import com.contentstack.cms.TestClient;
5+
import com.contentstack.cms.Utils;
46
import com.contentstack.cms.core.Util;
7+
import com.google.gson.JsonObject;
8+
59
import okhttp3.Request;
610
import okhttp3.ResponseBody;
711
import org.json.simple.JSONObject;
812
import org.junit.jupiter.api.*;
13+
14+
import retrofit2.Call;
915
import retrofit2.Response;
1016

1117
import java.io.IOException;
18+
import java.util.HashMap;
1219

1320
@Tag("api")
1421
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@@ -19,15 +26,22 @@ class RoleAPITest {
1926
protected static String _uid = TestClient.AUTHTOKEN;
2027
protected static String MANAGEMENT_TOKEN = TestClient.MANAGEMENT_TOKEN;
2128
protected static Roles roles;
22-
static Stack stack;
29+
protected static String Taxonomy_uid = "sample_two";
30+
protected static Taxonomy taxonomy;
31+
protected static Terms term;
32+
protected static Stack stack;
2333

2434

2535
@BeforeAll
2636
static void setup() {
27-
stack = TestClient.getStack();
28-
stack.addHeader(Util.API_KEY, API_KEY);
29-
stack.addHeader(Util.AUTHORIZATION, MANAGEMENT_TOKEN);
37+
final String AUTHTOKEN = TestClient.AUTHTOKEN;
38+
HashMap<String, Object> headers = new HashMap<>();
39+
headers.put(Util.API_KEY, API_KEY);
40+
headers.put(Util.AUTHORIZATION, MANAGEMENT_TOKEN);
41+
stack = new Contentstack.Builder().setAuthtoken(AUTHTOKEN).build().stack(headers);
3042
roles = stack.roles(_uid);
43+
taxonomy = stack.taxonomy();
44+
term = stack.taxonomy(Taxonomy_uid).terms();
3145
}
3246

3347
@Test
@@ -111,5 +125,54 @@ void deleteRole() {
111125
Assertions.assertNull(request.url().encodedQuery());
112126
Assertions.assertEquals("https://api.contentstack.io/v3/roles/" + _uid, request.url().toString());
113127
}
128+
@Test
129+
void createRoleWithRule1() throws IOException{
130+
JSONObject requestTaxonomy = Utils.readJson("mocktaxonomy/create.json");
131+
taxonomy.addHeader(Util.API_KEY, API_KEY);
132+
taxonomy.addHeader(Util.AUTHORIZATION, MANAGEMENT_TOKEN);
133+
Request request = taxonomy.create(requestTaxonomy).request();
134+
Assertions.assertEquals(2, request.headers().names().size());
135+
Assertions.assertEquals("POST", request.method());
136+
Assertions.assertTrue(request.url().isHttps());
137+
Assertions.assertEquals("api.contentstack.io", request.url().host());
138+
Assertions.assertEquals(2, request.url().pathSegments().size());
139+
Assertions.assertEquals("v3", request.url().pathSegments().get(0));
140+
Assertions.assertEquals("taxonomies", request.url().pathSegments().get(1));
141+
Assertions.assertNull(request.url().encodedQuery());
142+
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies", request.url().toString());
143+
144+
}
145+
@Test
146+
void createRoleWithRule2() throws IOException{
147+
JSONObject requestTerm = Utils.readJson("mocktaxonomy/createTerm.json");
148+
Request request = term.create(requestTerm).request();
149+
Assertions.assertEquals(2, request.headers().names().size());
150+
Assertions.assertEquals("POST", request.method());
151+
Assertions.assertTrue(request.url().isHttps());
152+
Assertions.assertEquals("api.contentstack.io", request.url().host());
153+
Assertions.assertEquals(4, request.url().pathSegments().size());
154+
Assertions.assertEquals("v3", request.url().pathSegments().get(0));
155+
Assertions.assertEquals("taxonomies", request.url().pathSegments().get(1));
156+
Assertions.assertNull(request.url().encodedQuery());
157+
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/sample_two/terms", request.url().toString());
158+
159+
}
160+
@Test
161+
void createRoleWithTaxonomy() throws IOException{
162+
JSONObject requestBody = Utils.readJson("mockrole/createRole.json");
163+
roles.addHeader(Util.API_KEY, API_KEY);
164+
roles.addHeader(Util.AUTHORIZATION, MANAGEMENT_TOKEN);
165+
Request request = roles.create(requestBody).request();
166+
Assertions.assertEquals(3, request.headers().names().size());
167+
Assertions.assertEquals("POST", request.method());
168+
Assertions.assertTrue(request.url().isHttps());
169+
Assertions.assertEquals("api.contentstack.io", request.url().host());
170+
Assertions.assertEquals(2, request.url().pathSegments().size());
171+
Assertions.assertEquals("v3", request.url().pathSegments().get(0));
172+
Assertions.assertEquals("roles", request.url().pathSegments().get(1));
173+
Assertions.assertNull(request.url().encodedQuery());
174+
Assertions.assertEquals("https://api.contentstack.io/v3/roles", request.url().toString());
175+
176+
}
114177

115178
}

0 commit comments

Comments
 (0)