Skip to content

Commit 6120cef

Browse files
v1.2.0
1 parent e25ae76 commit 6120cef

File tree

4 files changed

+55
-39
lines changed

4 files changed

+55
-39
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<url>https://www.***REMOVED***</url>
1515

1616
<properties>
17-
<util.version>1.1.2-SNAPSHOT</util.version>
17+
<util.version>1.2.0-SNAPSHOT</util.version>
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
<project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
2020
<maven.compiler.source>1.8</maven.compiler.source>

src/main/java/com/contentstack/utils/helper/Metadata.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ public class Metadata {
1717
/**
1818
* Instantiates a new Metadata.
1919
*
20-
* @param text the text
21-
* @param itemType the item type
22-
* @param itemUid the item uid
23-
* @param contentTypeUid the content type uid
24-
* @param styleType the style type
25-
* @param outerHTML the outer html
26-
* @param attributes the attributes
20+
* @param text
21+
* the text
22+
* @param itemType
23+
* the item type
24+
* @param itemUid
25+
* the item uid
26+
* @param contentTypeUid
27+
* the content type uid
28+
* @param styleType
29+
* the style type
30+
* @param outerHTML
31+
* the outer html
32+
* @param attributes
33+
* the attributes
2734
*/
2835
public Metadata(String text, String itemType, String itemUid, String contentTypeUid,
2936
String styleType, String outerHTML, Attributes attributes) {

src/main/java/com/contentstack/utils/interfaces/Option.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,34 @@ public interface Option {
1212
/**
1313
* Render options string.
1414
*
15-
* @param embeddedObject the embedded object
16-
* @param metadata the metadata
15+
* @param embeddedObject
16+
* the embedded object
17+
* @param metadata
18+
* the metadata
1719
* @return the string
1820
*/
1921
String renderOptions(JSONObject embeddedObject, Metadata metadata);
2022

2123
/**
2224
* Render mark string.
2325
*
24-
* @param markType the mark type
25-
* @param renderText the render text
26+
* @param markType
27+
* the mark type
28+
* @param renderText
29+
* the render text
2630
* @return the string
2731
*/
2832
String renderMark(MarkType markType, String renderText);
2933

3034
/**
3135
* Render node string.
3236
*
33-
* @param nodeType the node type
34-
* @param nodeObject the node object
35-
* @param callback the callback
37+
* @param nodeType
38+
* the node type
39+
* @param nodeObject
40+
* the node object
41+
* @param callback
42+
* the callback
3643
* @return the string
3744
*/
3845
String renderNode(String nodeType, JSONObject nodeObject, NodeCallback callback);

src/test/java/com/contentstack/utils/UtilTests.java

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
package com.contentstack.utils;
22

3+
import com.contentstack.utils.embedded.StyleType;
4+
import com.contentstack.utils.render.DefaultOption;
35
import org.json.JSONObject;
6+
import org.json.simple.JSONArray;
47
import org.junit.BeforeClass;
58
import org.junit.FixMethodOrder;
9+
import org.junit.Test;
610
import org.junit.runners.MethodSorters;
711

812
import java.io.IOException;
913
import java.util.logging.Level;
1014
import java.util.logging.Logger;
1115

16+
import static com.contentstack.utils.embedded.StyleType.*;
17+
1218
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
1319
public class UtilTests {
1420

@@ -23,30 +29,26 @@ public static void startUtilTests() throws IOException {
2329
localJsonObj = (JSONObject) localJsonObj.getJSONArray("entries").get(0);
2430
}
2531

26-
// @Test
27-
// public void testRenderFunction() {
32+
@Test
33+
public void testRenderFunction() {
2834
// DefaultOption option = (embeddedObject, metadata) -> {
2935
// StyleType styleType = metadata.getStyleType();
3036
// return null;
3137
// };
32-
// String[] keys = new String[2];
33-
// keys[0] = "global_rich_multiple.group.rich_text_editor";
34-
// keys[1] = "global_rich_multiple.group.rich_text_editor_multiple";
35-
// Utils.render(localJsonObj, keys, new DefaultOption());
36-
// }
37-
//
38-
// @Test
39-
// public void testWithoutKeyPath() {
40-
// Option option = (embeddedObject, metadata) -> {
41-
// StyleType styleType = metadata.getStyleType();
42-
// return null;
43-
// };
44-
// String[] keys = new String[2];
45-
// keys[0] = "global_rich_multiple.group.rich_text_editor";
46-
// keys[1] = "global_rich_multiple.group.rich_text_editor_multiple";
47-
// Utils.render(localJsonObj, null, new DefaultOption());
48-
// }
49-
//
38+
String[] keys = new String[2];
39+
keys[0] = "global_rich_multiple.group.rich_text_editor";
40+
keys[1] = "global_rich_multiple.group.rich_text_editor_multiple";
41+
Utils.render(localJsonObj, keys, new DefaultOption());
42+
}
43+
44+
@Test
45+
public void testWithoutKeyPath() {
46+
String[] keys = new String[2];
47+
keys[0] = "global_rich_multiple.group.rich_text_editor";
48+
keys[1] = "global_rich_multiple.group.rich_text_editor_multiple";
49+
Utils.render(localJsonObj, null, new DefaultOption());
50+
}
51+
5052
// @Test
5153
// public void testEmbeddedBlockEntry() {
5254
// JSONArray rteArray = null;
@@ -58,7 +60,7 @@ public static void startUtilTests() throws IOException {
5860
// assert rteArray != null;
5961
// Utils.renderContents(rteArray, localJsonObj, (embeddedObject, metadata) -> {
6062
// StyleType type = metadata.getStyleType();
61-
// if (type == StyleType.BLOCK) {
63+
// if (type == BLOCK) {
6264
// String title = embeddedObject.getString("title");
6365
// String multi_line = embeddedObject.getString("multi_line");
6466
// return "<p>" + title + "</p><span>" + multi_line + "</span>";
@@ -67,7 +69,7 @@ public static void startUtilTests() throws IOException {
6769
// });
6870
//
6971
// Utils.renderContents(rteArray, localJsonObj, (embeddedObject, metadata) -> {
70-
// if (metadata.getStyleType() == StyleType.BLOCK) {
72+
// if (metadata.getStyleType() == BLOCK) {
7173
// String title = embeddedObject.getString("title");
7274
// String multi_line = embeddedObject.getString("multi_line");
7375
// return "<p>" + title + "</p><span>" + multi_line + "</span>";
@@ -149,8 +151,8 @@ public static void startUtilTests() throws IOException {
149151
// String[] keyPath = {
150152
// "rich_text_editor", "global_rich_multiple.group.rich_text_editor"
151153
// };
152-
// Utils.render(rteObject, keyPath, (embeddedObject, metadata) -> {
153-
// if (metadata.getStyleType() == StyleType.BLOCK) {
154+
// Utils.renderContents(rteObject, keyPath, (embeddedObject, metadata) -> {
155+
// if (metadata.getStyleType == BLOCK) {
154156
// // Do something
155157
// }
156158
// return null;

0 commit comments

Comments
 (0)