Search in sources :

Example 21 with JacksonDataCodec

use of com.linkedin.data.codec.JacksonDataCodec in project rest.li by linkedin.

the class TestData method testNonCyclicMapWithClone.

@Test
public void testNonCyclicMapWithClone() throws Exception {
    DataMap root = new DataMap();
    root.put("key", "a");
    root.put("map", root.clone());
    new JacksonDataCodec().mapToString(root);
}
Also used : JacksonDataCodec(com.linkedin.data.codec.JacksonDataCodec) Test(org.testng.annotations.Test)

Example 22 with JacksonDataCodec

use of com.linkedin.data.codec.JacksonDataCodec in project rest.li by linkedin.

the class TestData method testListCycleDetection.

@Test(expectedExceptions = IOException.class)
public void testListCycleDetection() throws Exception {
    DataList root = new DataList();
    root.getUnderlying().add(root);
    new JacksonDataCodec().listToString(root);
}
Also used : JacksonDataCodec(com.linkedin.data.codec.JacksonDataCodec) Test(org.testng.annotations.Test)

Example 23 with JacksonDataCodec

use of com.linkedin.data.codec.JacksonDataCodec in project rest.li by linkedin.

the class TestData method testMapCycleDetection.

@Test(expectedExceptions = IOException.class)
public void testMapCycleDetection() throws Exception {
    DataMap root = new DataMap();
    root.getUnderlying().put("child", root);
    new JacksonDataCodec().mapToString(root);
}
Also used : JacksonDataCodec(com.linkedin.data.codec.JacksonDataCodec) Test(org.testng.annotations.Test)

Example 24 with JacksonDataCodec

use of com.linkedin.data.codec.JacksonDataCodec in project rest.li by linkedin.

the class TestData method testNonCyclicListWithClone.

@Test
public void testNonCyclicListWithClone() throws Exception {
    DataList list = new DataList();
    list.add("a");
    list.add(list.clone());
    new JacksonDataCodec().listToString(list);
}
Also used : JacksonDataCodec(com.linkedin.data.codec.JacksonDataCodec) Test(org.testng.annotations.Test)

Example 25 with JacksonDataCodec

use of com.linkedin.data.codec.JacksonDataCodec in project rest.li by linkedin.

the class TestRestClientRequestBuilder method assertEqualsJsonString.

/**
 * Asserts that two JSON strings are semantically equivalent.
 * TODO: This seems to be common among unit tests, we should create some framework-wide test utils
 *
 * @param actual actual JSON string
 * @param expected expected JSON string
 * @throws IOException in the case of a parsing failure
 */
private void assertEqualsJsonString(String actual, String expected) throws IOException {
    JacksonDataCodec codec = new JacksonDataCodec();
    Assert.assertEquals(codec.stringToMap(actual), codec.stringToMap(expected));
}
Also used : JacksonDataCodec(com.linkedin.data.codec.JacksonDataCodec)

Aggregations

JacksonDataCodec (com.linkedin.data.codec.JacksonDataCodec)27 Test (org.testng.annotations.Test)16 IOException (java.io.IOException)7 DataMap (com.linkedin.data.DataMap)6 BeforeTest (org.testng.annotations.BeforeTest)5 BackupRequestsConfiguration (com.linkedin.d2.BackupRequestsConfiguration)3 BoundedCostBackupRequests (com.linkedin.d2.BoundedCostBackupRequests)3 DataCodec (com.linkedin.data.codec.DataCodec)3 ByteString (com.linkedin.data.ByteString)2 BsonDataCodec (com.linkedin.data.codec.BsonDataCodec)2 PsonDataCodec (com.linkedin.data.codec.PsonDataCodec)2 EmptyRecord (com.linkedin.restli.common.EmptyRecord)2 BufferedReader (java.io.BufferedReader)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileOutputStream (java.io.FileOutputStream)2 InputStreamReader (java.io.InputStreamReader)2 PrintStream (java.io.PrintStream)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 TestUtil.dataMapFromString (com.linkedin.data.TestUtil.dataMapFromString)1