### Question:
Jsonya { public static Navigator<MutableMap<Object,Object>> at(Object ...pathSegments) { return newInstance().atArray(pathSegments); } private  Jsonya(); static Navigator<T> of(T map); static Navigator<T> of(Navigator<T> navigator); static Navigator<MutableMap<Object,Object>> newInstance(); static Navigator<MutableMap<Object,Object>> at(Object ...pathSegments); static Navigator<MutableMap<Object,Object>> newInstanceTranslating(Function<Object,Object> translator); static Navigator<MutableMap<Object,Object>> newInstanceLiteral(); static Navigator<MutableMap<Object,Object>> newInstancePrimitive(); static Object convertToJsonPrimitive(Object x); static boolean isJsonPrimitiveCompatible(Object x); static String render(Object focus);  }### Answer:
@SuppressWarnings("rawtypes") @Test public void testJsonyaWithList() { Navigator<MutableMap<Object, Object>> n = europeMap(); n.at("europe", "uk", "neighbours").list().add("ireland") .root().at("europe", "france", "neighbours").list().add("spain", "germany").add("switzerland") .root().at("europe", "france", "neighbours").add("lux"); Object l = n.root().at("europe", "france", "neighbours").get(); Assert.assertTrue(l instanceof List); Assert.assertEquals(((List)l).size(), 4); n.put("east", "germany", "south", "spain"); Assert.assertEquals(((List)l).size(), 5); Map nd = (Map) ((List)l).get(4); Assert.assertEquals(nd.size(), 2); Map nd2 = (Map) n.root().get("europe", "france", "neighbours", 4); Assert.assertEquals(nd2.size(), 2); }
@SuppressWarnings("rawtypes") @Test public void testCreateMapInList1() { MutableMap<Object, Object> map = Jsonya.at("countries").list().map().add("europe", "uk").getRootMap(); List l = (List)map.get("countries"); Assert.assertEquals( ((Map)l.get(0)).get("europe"), "uk" ); }
@SuppressWarnings("rawtypes") @Test public void testCreateMapInList2() { MutableMap<Object, Object> map = Jsonya.at("countries").list().map().add("europe", "uk") .root().at("countries").add("antarctica") .root().at("countries").map().add("asia", (Object)null) .at("asia").list().add("china", "japan").getRootMap(); List l = (List)map.get("countries"); Assert.assertEquals( ((Map)l.get(0)).get("europe"), "uk" ); }
@Test public void testJsonyaBadPathNull() { Navigator<MutableMap<Object, Object>> m = europeMap(); Assert.assertNull( m.at("europe", "spain", "barcelona").get() ); Assert.assertNull( m.root().at("europe").at("spain").at("barcelona").get() ); }
@Test public void testJsonyaPushPop() { Navigator<MutableMap<Object, Object>> m = europeMap(); Assert.assertTrue(m.getFocusMap().containsKey("europe")); Assert.assertFalse(m.getFocusMap().containsKey("edinburgh")); m.push(); m.at("europe", "uk"); Assert.assertTrue(m.getFocusMap().containsKey("edinburgh")); Assert.assertFalse(m.getFocusMap().containsKey("europe")); m.pop(); Assert.assertTrue(m.getFocusMap().containsKey("europe")); Assert.assertFalse(m.getFocusMap().containsKey("edinburgh")); m.get("europe", "uk"); Assert.assertTrue(m.getFocusMap().containsKey("europe")); Assert.assertFalse(m.getFocusMap().containsKey("edinburgh")); }