Skip to content

Commit 0952831

Browse files
🐞 pom and version
1 parent 63379ed commit 0952831

File tree

7 files changed

+21
-38
lines changed

7 files changed

+21
-38
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<jacoco-maven-plugin-version>0.8.7</jacoco-maven-plugin-version>
4242
<maven-release-plugin-version>2.5.3</maven-release-plugin-version>
4343
<nexus-staging-maven-plugin-version>1.6.7</nexus-staging-maven-plugin-version>
44-
<contentstack-utils-version>1.1.0</contentstack-utils-version>
44+
<contentstack-utils-version>1.1.1</contentstack-utils-version>
4545
</properties>
4646

4747
<parent>

src/main/java/com/contentstack/sdk/CSHttpConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ public void send() {
181181
}
182182

183183
private void getService(String requestUrl) throws IOException {
184-
this.headers.put(X_USER_AGENT, CLIENT_USER_AGENT);
184+
this.headers.put(X_USER_AGENT_KEY, "contentstack-java/" + SDK_VERSION);
185+
this.headers.put(USER_AGENT_KEY, USER_AGENT);
185186
this.headers.put(CONTENT_TYPE, APPLICATION_JSON);
186187
Response<ResponseBody> response = this.service.getRequest(requestUrl, this.headers).execute();
187188
if (response.isSuccessful()) {

src/main/java/com/contentstack/sdk/Constants.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import java.text.ParseException;
44
import java.text.SimpleDateFormat;
5-
import java.util.ArrayList;
6-
import java.util.Calendar;
7-
import java.util.Date;
8-
import java.util.TimeZone;
5+
import java.util.*;
96
import java.util.logging.Level;
107
import java.util.logging.Logger;
118

@@ -24,11 +21,12 @@ public class Constants {
2421
protected static final String ERROR_MESSAGE = "error_message";
2522
protected static final String ERRORS = "errors";
2623
// User-Agents
27-
protected static final String X_USER_AGENT = "X-User-Agent";
24+
protected static final String X_USER_AGENT_KEY = "X-User-Agent";
25+
protected static final String USER_AGENT_KEY = "User-Agent";
26+
protected static final String USER_AGENT = userAgent();
2827
protected static final String CONTENT_TYPE = "Content-Type";
2928
protected static final String APPLICATION_JSON = "application/json";
30-
protected static final String CLIENT_USER_AGENT = userAgent();
31-
// Query
29+
3230
protected static final String QUERY = "query";
3331
protected static final String EXCEPT = "except";
3432
protected static final String EXISTS = "$exists";
@@ -58,10 +56,7 @@ public enum REQUEST_CONTROLLER {
5856
public static final String FETCHSYNC = "getSync";
5957
public static final String FETCHCONTENTTYPES = "getContentTypes";
6058

61-
// ERROR MESSAGE BLOCK
62-
public static final String JSON_NOT_PROPER = "Please provide valid JSON.";
6359
public static final String CONTENT_TYPE_NAME = "Please set contentType name.";
64-
public static final String HEADER_IS_MISSING_TO_PROCESS_THE_DATA = "Header is missing to process the data";
6560
public static final String QUERY_EXCEPTION = "Please provide valid params.";
6661

6762
/**
@@ -137,4 +132,5 @@ protected static String userAgent() {
137132
agentStr = agentStr + "/" + SDK_VERSION;
138133
return agentStr;
139134
}
135+
140136
}

src/test/java/com/contentstack/sdk/TestAssetLibrary.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ public void onCompletion(ResponseType responseType, List<Asset> assets, Error er
4242
Assertions.assertTrue(model.getCreatedBy().startsWith("blt"));
4343
assertEquals("gregory", model.getUpdateAt().getCalendarType());
4444
Assertions.assertTrue(model.getUpdatedBy().startsWith("sys"));
45-
Assertions.assertNull(model.getDeleteAt());
4645
assertEquals("", model.getDeletedBy());
4746
logger.info("passed...");
4847
}

src/test/java/com/contentstack/sdk/TestContentType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void testEntryInstance() {
6969
Entry entry = contentType.entry("just-fake-it");
7070
Assertions.assertEquals("product", entry.getContentType());
7171
Assertions.assertEquals("just-fake-it", entry.uid);
72-
Assertions.assertEquals(5, entry.headers.size());
72+
Assertions.assertEquals(6, entry.headers.size());
7373
logger.info("passed...");
7474
}
7575

@@ -78,7 +78,7 @@ void testQueryInstance() {
7878
ContentType contentType = stack.contentType("product");
7979
Query query = contentType.query();
8080
Assertions.assertEquals("product", query.getContentType());
81-
Assertions.assertEquals(5, query.headers.size());
81+
Assertions.assertEquals(6, query.headers.size());
8282
logger.info("passed...");
8383
}
8484

src/test/java/com/contentstack/sdk/TestEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void onCompletion(ResponseType responseType, Error error) {
8484
@Test
8585
@Order(4)
8686
void entryCalling() {
87-
Assertions.assertEquals(5, entry.headers.size());
87+
Assertions.assertEquals(6, entry.headers.size());
8888
logger.info("passed...");
8989
}
9090

src/test/java/com/contentstack/sdk/TestQuery.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
133133
@Test
134134
@Order(5)
135135
void testNotContainedInField() {
136-
String[] containArray = new String[] { "Roti Maker", "kids dress" };
136+
String[] containArray = new String[]{"Roti Maker", "kids dress"};
137137
query.notContainedIn("title", containArray);
138138
query.find(new QueryResultsCallBack() {
139139
@Override
@@ -151,7 +151,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
151151
@Test
152152
@Order(6)
153153
void testContainedInField() {
154-
String[] containArray = new String[] { "Roti Maker", "kids dress" };
154+
String[] containArray = new String[]{"Roti Maker", "kids dress"};
155155
query.containedIn("title", containArray);
156156
query.find(new QueryResultsCallBack() {
157157
@Override
@@ -262,7 +262,7 @@ void testEntriesWithOr() {
262262
query.lessThan("price", 90);
263263

264264
Query subQuery = ct.query();
265-
subQuery.containedIn("discount", new Integer[] { 20, 45 });
265+
subQuery.containedIn("discount", new Integer[]{20, 45});
266266

267267
ArrayList<Query> array = new ArrayList<>();
268268
array.add(query);
@@ -294,7 +294,7 @@ void testEntriesWithAnd() {
294294
query.lessThan("price", 90);
295295

296296
Query subQuery = ct.query();
297-
subQuery.containedIn("discount", new Integer[] { 20, 45 });
297+
subQuery.containedIn("discount", new Integer[]{20, 45});
298298

299299
ArrayList<Query> array = new ArrayList<>();
300300
array.add(query);
@@ -404,7 +404,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
404404
String previous = entries.get(i).getTitle(); // get first string
405405
String next = entries.get(i + 1).getTitle(); // get second string
406406
if (previous.compareTo(next) < 0) { // compare both if less than Zero then Ascending else
407-
// descending
407+
// descending
408408
Assertions.assertTrue(true);
409409
} else {
410410
Assertions.fail("expected descending, found ascending");
@@ -430,7 +430,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
430430
String previous = entries.get(i).getTitle(); // get first string
431431
String next = entries.get(i + 1).getTitle(); // get second string
432432
if (previous.compareTo(next) < 0) { // compare both if less than Zero then Ascending else
433-
// descending
433+
// descending
434434
Assertions.fail("expected descending, found ascending");
435435
} else {
436436
Assertions.assertTrue(true);
@@ -480,7 +480,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
480480
@Test
481481
@Order(22)
482482
void testOnly() {
483-
query.only(new String[] { "price" });
483+
query.only(new String[]{"price"});
484484
query.find(new QueryResultsCallBack() {
485485
@Override
486486
public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) {
@@ -497,7 +497,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
497497
@Test
498498
@Order(23)
499499
void testExcept() {
500-
query.except(new String[] { "price" });
500+
query.except(new String[]{"price"});
501501
query.find(new QueryResultsCallBack() {
502502
@Override
503503
public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) {
@@ -583,7 +583,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
583583
@Test
584584
@Order(28)
585585
void testTags() {
586-
query.tags(new String[] { "pink" });
586+
query.tags(new String[]{"pink"});
587587
query.find(new QueryResultsCallBack() {
588588
@Override
589589
public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) {
@@ -877,17 +877,4 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
877877
logger.info("passed...");
878878
}
879879

880-
// @Test @Order(53)
881-
// void testIncludeBranchAPI() throws IllegalAccessException {
882-
// Dotenv dotenv = Dotenv.load();
883-
// String apiKey = dotenv.get("apiKey");
884-
// String deliveryToken = dotenv.get("deliveryToken");
885-
// String env = dotenv.get("env");
886-
// Config config = new Config();
887-
// config.setHost("development");
888-
// Stack stack = Contentstack.stack(apiKey, deliveryToken, env, config);
889-
// query = stack.contentType("menu").query();
890-
// query.includeBranch().find(null);
891-
// }
892-
893880
}

0 commit comments

Comments
 (0)