JsonResourceSerializer { public String serialize(final Resource resource) { try { return new JsonNodeSerializer().serialize(resource.adaptTo(Node.class)); } catch (RepositoryException e) { throw new RuntimeException("Can not serialize resource: " + resource.getPath(), e); } }  String serialize(final Resource resource);  }
@Test public void shouldReturnNonEmptyString() { String result = new JsonResourceSerializer().serialize(resource); assertThat(result) .as("Result of node's serialization should not be empty") .isNotEmpty(); }
@Test public void shouldSerializeNodeName() { String result = new JsonResourceSerializer().serialize(resource); assertThat(result) .as("Node's name should be serialized") .contains(RESOURCE_NAME); }
@Test public void shouldSerializeNodeProperties() { String result = new JsonResourceSerializer().serialize(resource); assertThat(result) .as("Node's properties should be serialized") .contains(PARENT_PROP) .contains(PARENT_VALUE); }
@Test public void shouldSerializeChildNodeName() { String result = new JsonResourceSerializer().serialize(resource); assertThat(result) .as("Child node's name should be serialized") .contains(CHILD_RESOURCE_NAME); }
@Test public void shouldSerializeChildNodeProperties() { String result = new JsonResourceSerializer().serialize(resource); assertThat(result) .as("Child node's properties should be serialized") .contains(CHILD_PROP) .contains(CHILD_VALUE); }
@Test public void shouldOmitProperties() { String result = new JsonResourceSerializer().serialize(resource); assertThat(result) .as("Auto created properties should not be used for serialization") .doesNotContain("jcr:created"); }