11package com .contentstack .utils ;
22
3+ import com .contentstack .utils .embedded .StyleType ;
4+ import com .contentstack .utils .render .DefaultOption ;
35import org .json .JSONObject ;
6+ import org .json .simple .JSONArray ;
47import org .junit .BeforeClass ;
58import org .junit .FixMethodOrder ;
9+ import org .junit .Test ;
610import org .junit .runners .MethodSorters ;
711
812import java .io .IOException ;
913import java .util .logging .Level ;
1014import java .util .logging .Logger ;
1115
16+ import static com .contentstack .utils .embedded .StyleType .*;
17+
1218@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
1319public 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