Skip to content

Commit

Permalink
Fixed for #58 #57 #52
Browse files Browse the repository at this point in the history
Fixed for #58 #57 #52
  • Loading branch information
ishaileshmishra committed Jun 16, 2022
1 parent 04a046b commit 1edc146
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.contentstack.sdk</groupId>
<artifactId>java</artifactId>
<version>${sdk.version.release}</version>
<version>1.10.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>contentstack-java</name>
<description>Java SDK for Contentstack Content Delivery API</description>
Expand Down
13 changes: 4 additions & 9 deletions src/main/java/com/contentstack/sdk/ContentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import java.util.logging.Logger;

/**
* <a
* href="https://www.contentstack.com/docs/developers/apis/content-delivery-api/#single-content-type">ContentType</a>
* <a href="https://www.contentstack.com/docs/developers/apis/content-delivery-api/#single-content-type">ContentType</a>
* This call returns information of a specific content type. It returns the content type schema, but does not include
* its entries.
*
Expand Down Expand Up @@ -125,7 +124,7 @@ public Query query() {
* @param callback
* the callback of type {@link ContentTypesCallback}
*/
public void fetch(@NotNull JSONObject params, final ContentTypesCallback callback) {
public void fetch(@NotNull JSONObject params, final ContentTypesCallback callback) throws IllegalAccessException {
String urlString = "content_types/" + contentTypeUid;
Iterator<String> keys = params.keys();
while (keys.hasNext()) {
Expand All @@ -134,12 +133,8 @@ public void fetch(@NotNull JSONObject params, final ContentTypesCallback callbac
params.put(key, value);
}
params.put("environment", headers.get("environment"));
if (contentTypeUid != null && !contentTypeUid.isEmpty()) {
try {
throw new IllegalAccessException("contentTypeUid is required");
} catch (Exception e) {
logger.warning("contentTypeUid is required");
}
if (contentTypeUid == null || contentTypeUid.isEmpty()) {
throw new IllegalAccessException("contentTypeUid is required");
}
fetchContentTypes(urlString, params, headers, callback);
}
Expand Down
10 changes: 2 additions & 8 deletions src/test/java/com/contentstack/sdk/TestContentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void testQueryInstance() {
}

@Test
void testContentTypeFetch() {
void testContentTypeFetch() throws IllegalAccessException {
ContentType contentType = stack.contentType("product");
JSONObject paramObj = new JSONObject();
paramObj.put("ctKeyOne", "ctKeyValue1");
Expand All @@ -98,7 +98,7 @@ public void onCompletion(ContentTypesModel model, Error error) {
}

@Test
void testContentTypesFetch() {
void testContentTypesFetch() throws IllegalAccessException {
ContentType contentType = stack.contentType("product");
JSONObject paramObj = new JSONObject();
paramObj.put("ctKeyOne", "ctKeyValue1");
Expand All @@ -112,11 +112,5 @@ public void onCompletion(ContentTypesModel model, Error error) {
});
}

@Test
void toCoverageCheckHeader() {
Map<String, Object> mapHeader = new HashMap<>();
CSBackgroundTask backgroundTask = new CSBackgroundTask();
backgroundTask.checkHeader(mapHeader);
}

}

0 comments on commit 1edc146

Please sign in to comment.