JsonDeserializer { public NodeState deserialize(String json){ JsopReader reader = new JsopTokenizer(json); reader.read('{'); NodeState state = deserialize(reader); reader.read(JsopReader.END); return state; } private  JsonDeserializer(BlobDeserializer blobHandler, NodeBuilder builder, DeserializationSupport support);  JsonDeserializer(BlobDeserializer blobHandler);  JsonDeserializer(BlobDeserializer blobHandler, NodeBuilder builder); NodeState deserialize(String json); NodeState deserialize(JsopReader reader); static final String OAK_CHILD_ORDER; }
@Test public void primaryType() throws Exception{ String json = "{\"jcr:primaryType\":\"oak:Unstructured\"}"; NodeState nodeState2 = deserialize(json); assertEquals(Type.NAME, nodeState2.getProperty(JcrConstants.JCR_PRIMARYTYPE).getType()); }
@Test public void stringPropertyWithNamespace() throws Exception{ String json = "{\"name\":\"jcr:content/metadata\"}"; NodeState nodeState = deserialize(json); PropertyState name = nodeState.getProperty("name"); assertEquals("jcr:content/metadata", name.getValue(Type.STRING)); assertEquals(Type.STRING, name.getType()); }
@Test public void stringArrayPropertyWithNamespace() throws Exception{ String json = "{\"name\": [\"jcr:content/metadata\"] }"; NodeState nodeState = deserialize(json); PropertyState name = nodeState.getProperty("name"); assertEquals("jcr:content/metadata", name.getValue(Type.STRING, 0)); assertEquals(Type.STRINGS, name.getType()); }
@Test public void mixins() throws Exception{ String json = "{\"jcr:mixinTypes\": [\"oak:Unstructured\", \"mixin:title\"]}"; NodeState nodeState = deserialize(json); assertEquals(Type.NAMES, nodeState.getProperty(JcrConstants.JCR_MIXINTYPES).getType()); assertEquals(asList("oak:Unstructured", "mixin:title"), nodeState.getProperty(JcrConstants.JCR_MIXINTYPES).getValue(Type.NAMES)); }
@Test public void childOrder() throws Exception{ String json = "{\"jcr:primaryType\":\"nam:nt:unstructured\",\"a\":{},\"c\":{},\"b\":{}}"; NodeState nodeState = deserialize(json); PropertyState childOrder = nodeState.getProperty(":childOrder"); assertNotNull(childOrder); assertEquals(asList("a", "c", "b"), childOrder.getValue(Type.NAMES)); }