Skip to content

Commit

Permalink
🐞 pom and version
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaileshmishra committed Jun 1, 2022
1 parent 63379ed commit 0952831
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 38 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<jacoco-maven-plugin-version>0.8.7</jacoco-maven-plugin-version>
<maven-release-plugin-version>2.5.3</maven-release-plugin-version>
<nexus-staging-maven-plugin-version>1.6.7</nexus-staging-maven-plugin-version>
<contentstack-utils-version>1.1.0</contentstack-utils-version>
<contentstack-utils-version>1.1.1</contentstack-utils-version>
</properties>

<parent>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/contentstack/sdk/CSHttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ public void send() {
}

private void getService(String requestUrl) throws IOException {
this.headers.put(X_USER_AGENT, CLIENT_USER_AGENT);
this.headers.put(X_USER_AGENT_KEY, "contentstack-java/" + SDK_VERSION);
this.headers.put(USER_AGENT_KEY, USER_AGENT);
this.headers.put(CONTENT_TYPE, APPLICATION_JSON);
Response<ResponseBody> response = this.service.getRequest(requestUrl, this.headers).execute();
if (response.isSuccessful()) {
Expand Down
16 changes: 6 additions & 10 deletions src/main/java/com/contentstack/sdk/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -24,11 +21,12 @@ public class Constants {
protected static final String ERROR_MESSAGE = "error_message";
protected static final String ERRORS = "errors";
// User-Agents
protected static final String X_USER_AGENT = "X-User-Agent";
protected static final String X_USER_AGENT_KEY = "X-User-Agent";
protected static final String USER_AGENT_KEY = "User-Agent";
protected static final String USER_AGENT = userAgent();
protected static final String CONTENT_TYPE = "Content-Type";
protected static final String APPLICATION_JSON = "application/json";
protected static final String CLIENT_USER_AGENT = userAgent();
// Query

protected static final String QUERY = "query";
protected static final String EXCEPT = "except";
protected static final String EXISTS = "$exists";
Expand Down Expand Up @@ -58,10 +56,7 @@ public enum REQUEST_CONTROLLER {
public static final String FETCHSYNC = "getSync";
public static final String FETCHCONTENTTYPES = "getContentTypes";

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

/**
Expand Down Expand Up @@ -137,4 +132,5 @@ protected static String userAgent() {
agentStr = agentStr + "/" + SDK_VERSION;
return agentStr;
}

}
1 change: 0 additions & 1 deletion src/test/java/com/contentstack/sdk/TestAssetLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public void onCompletion(ResponseType responseType, List<Asset> assets, Error er
Assertions.assertTrue(model.getCreatedBy().startsWith("blt"));
assertEquals("gregory", model.getUpdateAt().getCalendarType());
Assertions.assertTrue(model.getUpdatedBy().startsWith("sys"));
Assertions.assertNull(model.getDeleteAt());
assertEquals("", model.getDeletedBy());
logger.info("passed...");
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/contentstack/sdk/TestContentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void testEntryInstance() {
Entry entry = contentType.entry("just-fake-it");
Assertions.assertEquals("product", entry.getContentType());
Assertions.assertEquals("just-fake-it", entry.uid);
Assertions.assertEquals(5, entry.headers.size());
Assertions.assertEquals(6, entry.headers.size());
logger.info("passed...");
}

Expand All @@ -78,7 +78,7 @@ void testQueryInstance() {
ContentType contentType = stack.contentType("product");
Query query = contentType.query();
Assertions.assertEquals("product", query.getContentType());
Assertions.assertEquals(5, query.headers.size());
Assertions.assertEquals(6, query.headers.size());
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 @@ -84,7 +84,7 @@ public void onCompletion(ResponseType responseType, Error error) {
@Test
@Order(4)
void entryCalling() {
Assertions.assertEquals(5, entry.headers.size());
Assertions.assertEquals(6, entry.headers.size());
logger.info("passed...");
}

Expand Down
31 changes: 9 additions & 22 deletions src/test/java/com/contentstack/sdk/TestQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
@Test
@Order(5)
void testNotContainedInField() {
String[] containArray = new String[] { "Roti Maker", "kids dress" };
String[] containArray = new String[]{"Roti Maker", "kids dress"};
query.notContainedIn("title", containArray);
query.find(new QueryResultsCallBack() {
@Override
Expand All @@ -151,7 +151,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
@Test
@Order(6)
void testContainedInField() {
String[] containArray = new String[] { "Roti Maker", "kids dress" };
String[] containArray = new String[]{"Roti Maker", "kids dress"};
query.containedIn("title", containArray);
query.find(new QueryResultsCallBack() {
@Override
Expand Down Expand Up @@ -262,7 +262,7 @@ void testEntriesWithOr() {
query.lessThan("price", 90);

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

ArrayList<Query> array = new ArrayList<>();
array.add(query);
Expand Down Expand Up @@ -294,7 +294,7 @@ void testEntriesWithAnd() {
query.lessThan("price", 90);

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

ArrayList<Query> array = new ArrayList<>();
array.add(query);
Expand Down Expand Up @@ -404,7 +404,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
String previous = entries.get(i).getTitle(); // get first string
String next = entries.get(i + 1).getTitle(); // get second string
if (previous.compareTo(next) < 0) { // compare both if less than Zero then Ascending else
// descending
// descending
Assertions.assertTrue(true);
} else {
Assertions.fail("expected descending, found ascending");
Expand All @@ -430,7 +430,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
String previous = entries.get(i).getTitle(); // get first string
String next = entries.get(i + 1).getTitle(); // get second string
if (previous.compareTo(next) < 0) { // compare both if less than Zero then Ascending else
// descending
// descending
Assertions.fail("expected descending, found ascending");
} else {
Assertions.assertTrue(true);
Expand Down Expand Up @@ -480,7 +480,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
@Test
@Order(22)
void testOnly() {
query.only(new String[] { "price" });
query.only(new String[]{"price"});
query.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) {
Expand All @@ -497,7 +497,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
@Test
@Order(23)
void testExcept() {
query.except(new String[] { "price" });
query.except(new String[]{"price"});
query.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) {
Expand Down Expand Up @@ -583,7 +583,7 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
@Test
@Order(28)
void testTags() {
query.tags(new String[] { "pink" });
query.tags(new String[]{"pink"});
query.find(new QueryResultsCallBack() {
@Override
public void onCompletion(ResponseType responseType, QueryResult queryresult, Error error) {
Expand Down Expand Up @@ -877,17 +877,4 @@ public void onCompletion(ResponseType responseType, QueryResult queryresult, Err
logger.info("passed...");
}

// @Test @Order(53)
// void testIncludeBranchAPI() throws IllegalAccessException {
// Dotenv dotenv = Dotenv.load();
// String apiKey = dotenv.get("apiKey");
// String deliveryToken = dotenv.get("deliveryToken");
// String env = dotenv.get("env");
// Config config = new Config();
// config.setHost("development");
// Stack stack = Contentstack.stack(apiKey, deliveryToken, env, config);
// query = stack.contentType("menu").query();
// query.includeBranch().find(null);
// }

}

0 comments on commit 0952831

Please sign in to comment.