1
1
package com .contentstack .utils ;
2
2
3
+ import com .contentstack .utils .embedded .StyleType ;
4
+ import com .contentstack .utils .render .DefaultOption ;
3
5
import org .json .JSONObject ;
6
+ import org .json .simple .JSONArray ;
4
7
import org .junit .BeforeClass ;
5
8
import org .junit .FixMethodOrder ;
9
+ import org .junit .Test ;
6
10
import org .junit .runners .MethodSorters ;
7
11
8
12
import java .io .IOException ;
9
13
import java .util .logging .Level ;
10
14
import java .util .logging .Logger ;
11
15
16
+ import static com .contentstack .utils .embedded .StyleType .*;
17
+
12
18
@ FixMethodOrder (MethodSorters .NAME_ASCENDING )
13
19
public class UtilTests {
14
20
@@ -23,30 +29,26 @@ public static void startUtilTests() throws IOException {
23
29
localJsonObj = (JSONObject ) localJsonObj .getJSONArray ("entries" ).get (0 );
24
30
}
25
31
26
- // @Test
27
- // public void testRenderFunction() {
32
+ @ Test
33
+ public void testRenderFunction () {
28
34
// DefaultOption option = (embeddedObject, metadata) -> {
29
35
// StyleType styleType = metadata.getStyleType();
30
36
// return null;
31
37
// };
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
+
50
52
// @Test
51
53
// public void testEmbeddedBlockEntry() {
52
54
// JSONArray rteArray = null;
@@ -58,7 +60,7 @@ public static void startUtilTests() throws IOException {
58
60
// assert rteArray != null;
59
61
// Utils.renderContents(rteArray, localJsonObj, (embeddedObject, metadata) -> {
60
62
// StyleType type = metadata.getStyleType();
61
- // if (type == StyleType. BLOCK) {
63
+ // if (type == BLOCK) {
62
64
// String title = embeddedObject.getString("title");
63
65
// String multi_line = embeddedObject.getString("multi_line");
64
66
// return "<p>" + title + "</p><span>" + multi_line + "</span>";
@@ -67,7 +69,7 @@ public static void startUtilTests() throws IOException {
67
69
// });
68
70
//
69
71
// Utils.renderContents(rteArray, localJsonObj, (embeddedObject, metadata) -> {
70
- // if (metadata.getStyleType() == StyleType. BLOCK) {
72
+ // if (metadata.getStyleType() == BLOCK) {
71
73
// String title = embeddedObject.getString("title");
72
74
// String multi_line = embeddedObject.getString("multi_line");
73
75
// return "<p>" + title + "</p><span>" + multi_line + "</span>";
@@ -149,8 +151,8 @@ public static void startUtilTests() throws IOException {
149
151
// String[] keyPath = {
150
152
// "rich_text_editor", "global_rich_multiple.group.rich_text_editor"
151
153
// };
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) {
154
156
// // Do something
155
157
// }
156
158
// return null;
0 commit comments