Skip to content

Commit f5d62c2

Browse files
Merge pull request #41 from contentstack/taxonomy
removed dev host
2 parents 57bce38 + ff8741d commit f5d62c2

File tree

7 files changed

+71
-53
lines changed

7 files changed

+71
-53
lines changed

.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dev-host=***REMOVED***
1+
dev-host=api.contentstack.io // use developer host here

pom.xml

+6-6
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.1.0-SNAPSHOT</version>
10+
<version>1.1.0</version>
1111
<description>Contentstack Java Management SDK for Content Management API, Contentstack is a headless CMS with an
1212
API-first approach
1313
</description>
@@ -67,11 +67,11 @@
6767
<name>Apache Maven Packages Snapshot</name>
6868
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
6969
</snapshotRepository>
70-
<!-- <snapshotRepository>
71-
<id>github</id>
72-
<name>GitHub Apache Maven Packages</name>
73-
<url>https://maven.pkg.github.com/contentstack/contentstack-management-java</url>
74-
</snapshotRepository> -->
70+
<!-- <snapshotRepository>-->
71+
<!-- <id>github</id>-->
72+
<!-- <name>GitHub Apache Maven Packages</name>-->
73+
<!-- <url>https://maven.pkg.github.com/contentstack/contentstack-management-java</url>-->
74+
<!-- </snapshotRepository> -->
7575
<repository>
7676
<id>ossrh</id>
7777
<name>Apache Maven Packages Release</name>

src/main/java/com/contentstack/cms/BaseImplementation.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface BaseImplementation<T> {
2020
* object as its value.
2121
* @return The method is returning an object of type T.
2222
*/
23-
T addParam(@NotNull String key, @NotNull Object value);
23+
T addParam(@NotNull String key, @NotNull Object value);
2424

2525
/**
2626
* The function adds a header with a key-value pair to a request.
@@ -45,7 +45,7 @@ public interface BaseImplementation<T> {
4545
* annotated with @NotNull, indicating that it cannot be null.
4646
* @return The method is returning an object of type T.
4747
*/
48-
T addParams(@NotNull HashMap<String, Object> params);
48+
T addParams(@NotNull HashMap<String, Object> params);
4949

5050
/**
5151
* The function adds headers to a HashMap.
@@ -56,5 +56,5 @@ public interface BaseImplementation<T> {
5656
* representing the header value.
5757
* @return The method is returning an object of type T.
5858
*/
59-
T addHeaders(@NotNull HashMap<String, String> headers);
59+
T addHeaders(@NotNull HashMap<String, String> headers);
6060
}

src/main/java/com/contentstack/cms/Contentstack.java

+30-24
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ public class Contentstack {
8080
* @return User
8181
* @author ***REMOVED***
8282
* @see <a href=
83-
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#users">User
84-
* </a>
83+
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#users">User
84+
* </a>
8585
* @since 2022-05-19
8686
*/
8787
public User user() {
@@ -130,8 +130,8 @@ public User user() {
130130
* @throws IOException the IOException
131131
* @author ***REMOVED***
132132
* @see <a href=
133-
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#users">User
134-
* </a>
133+
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#users">User
134+
* </a>
135135
*/
136136
public Response<LoginDetails> login(String emailId, String password) throws IOException {
137137
if (this.authtoken != null)
@@ -183,10 +183,10 @@ public Response<LoginDetails> login(String emailId, String password) throws IOEx
183183
* @throws IOException the IOException
184184
* @author ***REMOVED***
185185
* @see <a
186-
* href=
187-
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#log-in-to-your-account">Login
188-
* your account
189-
* </a>
186+
* href=
187+
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#log-in-to-your-account">Login
188+
* your account
189+
* </a>
190190
*/
191191
public Response<LoginDetails> login(String emailId, String password, String tfaToken) throws IOException {
192192
if (this.authtoken != null)
@@ -201,7 +201,7 @@ public Response<LoginDetails> login(String emailId, String password, String tfaT
201201
private void setupLoginCredentials(Response<LoginDetails> loginResponse) throws IOException {
202202
if (loginResponse.isSuccessful()) {
203203
assert loginResponse.body() != null;
204-
//logger.info(loginResponse.body().getNotice());
204+
// logger.info(loginResponse.body().getNotice());
205205
this.authtoken = loginResponse.body().getUser().getAuthtoken();
206206
this.interceptor.setAuthtoken(this.authtoken);
207207
} else {
@@ -287,10 +287,10 @@ public Organization organization() {
287287
*
288288
* @param organizationUid The UID of the organization that you want to retrieve
289289
* @return the organization
290-
* <br>
291-
* <b>Example</b>
290+
* <br>
291+
* <b>Example</b>
292292
*
293-
* <pre>
293+
* <pre>
294294
* Contentstack contentstack = new Contentstack.Builder().build();
295295
* Organization org = contentstack.organization();
296296
* </pre>
@@ -398,13 +398,12 @@ public Stack stack(@NotNull String key) {
398398
// When API_Key is available
399399
headers.put(API_KEY, key);
400400
} else {
401-
//When branch is available
401+
// When branch is available
402402
headers.put(BRANCH, key);
403403
}
404404
return new Stack(this.instance, headers);
405405
}
406406

407-
408407
/**
409408
* <a href=
410409
* "https://www.contentstack.com/docs/developers/apis/content-management-api/#stacks">stack</a>
@@ -489,11 +488,14 @@ public Builder() {
489488
* <br>
490489
* <p>
491490
* {@code
492-
* <p>
491+
*
492+
<p>
493493
* Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("hostname", 433));
494494
* Contentstack contentstack = new Contentstack.Builder().setProxy(proxy).build();
495-
* <p>
495+
*
496+
<p>
496497
* }
498+
*
497499
* @param proxy the proxy
498500
* @return the Builder instance
499501
*/
@@ -557,11 +559,13 @@ public Builder setTimeout(int timeout) {
557559
return this;
558560
}
559561

560-
561562
/**
562-
* Create a new connection pool with tuning parameters appropriate for a single-user application.
563-
* The tuning parameters in this pool are subject to change in future OkHttp releases. Currently,
564-
* this pool holds up to 5 idle connections which will be evicted after 5 minutes of inactivity.
563+
* Create a new connection pool with tuning parameters appropriate for a
564+
* single-user application.
565+
* The tuning parameters in this pool are subject to change in future OkHttp
566+
* releases. Currently,
567+
* this pool holds up to 5 idle connections which will be evicted after 5
568+
* minutes of inactivity.
565569
* <p>
566570
* <p>
567571
* public ConnectionPool() {
@@ -570,11 +574,13 @@ public Builder setTimeout(int timeout) {
570574
*
571575
* @param maxIdleConnections Maximum number of idle connections
572576
* @param keepAliveDuration The Keep Alive Duration
573-
* @param timeUnit A TimeUnit represents time durations at a given unit of granularity and provides utility methods to convert across units
577+
* @param timeUnit A TimeUnit represents time durations at a given
578+
* unit of granularity and provides utility methods to
579+
* convert across units
574580
* @return instance of Builder
575-
* <p>
576-
* Example:
577-
* {@code
581+
* <p>
582+
* Example:
583+
* {@code
578584
* Contentstack cs = new Contentstack.Builder()
579585
* .setAuthtoken(AUTHTOKEN)
580586
* .setConnectionPool(5, 400, TimeUnit.MILLISECONDS)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
2-
* This is topmost package that is used to contains all the sub-packages in itself
2+
* This is topmost package that is used to contains all the sub-packages in
3+
* itself
34
* like core, models, organisations, stacks, users and contentstack
45
*/
56
package com.contentstack.cms;

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

+8-6
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@ public class TestClient {
1111

1212
final static Dotenv env = Dotenv.load();
1313

14-
public final static String ORGANIZATION_UID = (env.get("organizationUid") != null) ? env.get("organizationUid") : "orgId999999999";
14+
public final static String ORGANIZATION_UID = (env.get("organizationUid") != null) ? env.get("organizationUid")
15+
: "orgId999999999";
1516
public final static String AUTHTOKEN = (env.get("authToken") != null) ? env.get("authToken") : "auth999999999";
1617
public final static String USER_ID = (env.get("userId") != null) ? env.get("userId") : "c11e668e0295477f";
17-
public final static String OWNERSHIP = (env.get("ownershipToken") != null) ? env.get("ownershipToken") : "ownershipTokenId";
18+
public final static String OWNERSHIP = (env.get("ownershipToken") != null) ? env.get("ownershipToken")
19+
: "ownershipTokenId";
1820
public final static String API_KEY = (env.get("apiKey") != null) ? env.get("apiKey") : "apiKey99999999";
19-
public final static String MANAGEMENT_TOKEN = (env.get("managementToken") != null) ? env.get("managementToken") : "managementToken99999999";
21+
public final static String MANAGEMENT_TOKEN = (env.get("managementToken") != null) ? env.get("managementToken")
22+
: "managementToken99999999";
2023

21-
public final static String DEV_HOST = (env.get("dev_host") != null) ? env.get("dev_host") : "***REMOVED***";
24+
public final static String DEV_HOST = "api.contentstack.io";
25+
// (env.get("dev_host") != null) ? env.get("dev_host") : "api.contentstack.io";
2226
private static Contentstack instance;
2327
private static Stack stackInstance;
2428

@@ -37,7 +41,6 @@ public static Contentstack getClient() {
3741
return instance;
3842
}
3943

40-
4144
public static Contentstack getCustomClient() {
4245
if (instance == null) {
4346
synchronized (Contentstack.class) {
@@ -71,4 +74,3 @@ public static Stack getStack() {
7174
}
7275

7376
}
74-

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

+21-12
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ void fetchTest() {
118118
Assertions.assertEquals("taxonomies", request.url().pathSegments().get(1));
119119
Assertions.assertEquals("v3", request.url().pathSegments().get(0));
120120
Assertions.assertNotNull(request.url().encodedQuery());
121-
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/taxonomyId?limit=2&skip=2&include_count=false", request.url().toString());
121+
Assertions.assertEquals(
122+
"https://api.contentstack.io/v3/taxonomies/taxonomyId?limit=2&skip=2&include_count=false",
123+
request.url().toString());
122124
}
123125

124126
@Test
@@ -149,7 +151,6 @@ void deleteTest() {
149151
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/taxonomyId", request.url().toString());
150152
}
151153

152-
153154
@Test
154155
void deleteTestWithHeaders() {
155156
taxonomy.clearParams();
@@ -174,7 +175,6 @@ void deleteTestWithHeaders() {
174175
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/taxonomyId", request.url().toString());
175176
}
176177

177-
178178
@Test
179179
void createTest() {
180180
JSONObject obj = new JSONObject();
@@ -212,7 +212,8 @@ void testCreateTerm() {
212212
Assertions.assertEquals("terms", request.url().pathSegments().get(3));
213213
Assertions.assertNotNull(request.body());
214214
Assertions.assertNull(request.url().encodedQuery());
215-
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/auth999999999/terms", request.url().toString());
215+
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/auth999999999/terms",
216+
request.url().toString());
216217
}
217218

218219
@Test
@@ -231,7 +232,8 @@ void testFindTerm() {
231232
Assertions.assertEquals("terms", request.url().pathSegments().get(3));
232233
Assertions.assertNull(request.body());
233234
Assertions.assertEquals("limit=3", request.url().encodedQuery());
234-
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/" + _uid + "/terms?limit=3", request.url().toString());
235+
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/" + _uid + "/terms?limit=3",
236+
request.url().toString());
235237
}
236238

237239
@Test
@@ -250,11 +252,13 @@ void testFetchTerm() {
250252
Assertions.assertEquals(_uid, request.url().pathSegments().get(2));
251253
Assertions.assertEquals("terms", request.url().pathSegments().get(3));
252254
Assertions.assertNull(request.body());
253-
Assertions.assertEquals("include_children_count=false&include_referenced_entries_count=true", request.url().encodedQuery());
254-
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/auth999999999/terms/auth999999999?include_children_count=false&include_referenced_entries_count=true", request.url().toString());
255+
Assertions.assertEquals("include_children_count=false&include_referenced_entries_count=true",
256+
request.url().encodedQuery());
257+
Assertions.assertEquals(
258+
"https://api.contentstack.io/v3/taxonomies/auth999999999/terms/auth999999999?include_children_count=false&include_referenced_entries_count=true",
259+
request.url().toString());
255260
}
256261

257-
258262
@Test
259263
void testTermUpdate() {
260264
terms.clearParams();
@@ -302,7 +306,9 @@ void testDescendantsTerm() {
302306
Assertions.assertEquals("terms", request.url().pathSegments().get(3));
303307
Assertions.assertNull(request.body());
304308
Assertions.assertEquals("include_count=true", request.url().encodedQuery());
305-
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/auth999999999/terms/termId45/descendants?include_count=true", request.url().toString());
309+
Assertions.assertEquals(
310+
"https://api.contentstack.io/v3/taxonomies/auth999999999/terms/termId45/descendants?include_count=true",
311+
request.url().toString());
306312
}
307313

308314
@Test
@@ -321,15 +327,18 @@ void testAncestorsTerm() {
321327
Assertions.assertEquals(_uid, request.url().pathSegments().get(2));
322328
Assertions.assertEquals("terms", request.url().pathSegments().get(3));
323329
Assertions.assertNull(request.body());
324-
Assertions.assertEquals("include_children_count=false&include_referenced_entries_count=true", request.url().encodedQuery());
325-
Assertions.assertEquals("https://api.contentstack.io/v3/taxonomies/auth999999999/terms/termId45/ancestors?include_children_count=false&include_referenced_entries_count=true", request.url().toString());
330+
Assertions.assertEquals("include_children_count=false&include_referenced_entries_count=true",
331+
request.url().encodedQuery());
332+
Assertions.assertEquals(
333+
"https://api.contentstack.io/v3/taxonomies/auth999999999/terms/termId45/ancestors?include_children_count=false&include_referenced_entries_count=true",
334+
request.url().toString());
326335
}
327336

328337
@Test
329338
void findTestAPI() throws IOException {
330339
Taxonomy taxonomy = new Contentstack.Builder()
331340
.setAuthtoken(TestClient.AUTHTOKEN)
332-
.setHost("***REMOVED***")
341+
.setHost("api.contentstack.io")
333342
.build()
334343
.stack("blt12c1ba95c1b11e88", "")
335344
.taxonomy();

0 commit comments

Comments
 (0)