@Test public void testSerializeAsRuby() throws Exception { final List<Object> collection1 = new ArrayList<>(); collection1.add(123); final List<Object> collection2 = new ArrayList<>(); collection2.add(645); collection2.add(collection1); collection2.add("dog's"); // LinkedHashMap preserves order for testability final Map<Object, Object> map1 = new LinkedHashMap<>(); map1.put("key1", 123); final Map<Object, Object> map2 = new LinkedHashMap<>(); map2.put("key1", 645); map2.put(152, map1); map2.put("cat's", "dog's"); map2.put(new File("/dev/null"), "bla"); // object as key final List<Object> args = new ArrayList<>(); args.add(null); // null args.add("it's"); // string args.add(5362); // int args.add(53.62f); // float args.add(true); // boolean args.add(false); // boolean args.add(new ArrayList<>()); // empty collection args.add(collection2); // collection args.add(new HashMap<>()); // empty map args.add(map2); // map args.add(new File("/dev/null")); // Object assertEquals( "[nil, 'it\\'s', 5362, 53.62, true, false, " + "[], [645, [123], 'dog\\'s'], " + "{}, {'key1' => 645, '152' => {'key1' => 123}, 'cat\\'s' => 'dog\\'s', '/dev/null' => 'bla'}, " + "'/dev/null']", instance.serializeAsRuby(args)); }