1
2
3
4
5
6
7 package org.mule.module.json.transformers;
8
9 import org.mule.tck.junit4.AbstractMuleContextTestCase;
10
11 import org.junit.Test;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertNotNull;
15
16
17 public class JsonStringTestCase extends AbstractMuleContextTestCase
18 {
19 public static final String TEST_JSON_MESSAGE = "{\"data\" : {\"value1\" : \"foo\", \"value2\" : \"bar\"}, \"replyTo\" : \"/response\"}";
20
21
22
23
24 @Test
25 public void testTryConvertJsonStringToJsonString() throws Exception
26 {
27 ObjectToJson transformer = createObject(ObjectToJson.class);
28 Object result = transformer.transform(TEST_JSON_MESSAGE);
29 assertNotNull(result);
30 assertEquals(TEST_JSON_MESSAGE, result);
31 }
32
33
34 @Test
35 public void testTryConvertJsonStringToJustString() throws Exception
36 {
37 ObjectToJson transformer = createObject(ObjectToJson.class);
38
39 assertEquals("\"Hello\"", transformer.transform("Hello"));
40 }
41 }