### Question:
JcrTools { public Node findOrCreateChild( Node parent, String name ) throws RepositoryException { return findOrCreateChild(parent, name, null); }  int removeAllChildren( Node node ); Node getNode( Node node,
                         String relativePath,
                         boolean required ); String getReadable( Node node ); MimeTypeDetector mimeTypeDetector( Session session ); String detectMimeType( Session session,
                                  String fileName ); String detectMimeType( Session session,
                                  File file,
                                  boolean useContent ); String detectMimeType( Session session,
                                  URL url,
                                  boolean useContent ); Node uploadFile( Session session,
                            String path,
                            InputStream stream ); Node uploadFile( Session session,
                            String path,
                            URL contentUrl ); Node uploadFile( Session session,
                            String path,
                            File file ); Node findOrCreateNode( Session session,
                                  String path ); Node findOrCreateNode( Session session,
                                  String path,
                                  String nodeType ); Node findOrCreateNode( Session session,
                                  String path,
                                  String defaultNodeType,
                                  String finalNodeType ); Node findOrCreateNode( Node parentNode,
                                  String path,
                                  String defaultNodeType,
                                  String finalNodeType ); Node findOrCreateChild( Node parent,
                                   String name ); Node findOrCreateChild( Node parent,
                                   String name,
                                   String nodeType ); void printSubgraph( Node node ); void printSubgraph( Node node,
                               int maxDepth ); void printNode( Node node ); void printSubgraph( Node node,
                               String lead,
                               int depthOfSubgraph,
                               int maxDepthOfSubgraph );  }### Answer:
@Test public void shouldCreateChildNodeWithParentName() throws RepositoryException { Node childNode = tools.findOrCreateChild(personNode, "Hobby"); assertNotNull(childNode); assertThat(childNode.getName(), is("Hobby")); }
@Test public void shouldFindChildNodeWithParentName() throws RepositoryException { Node childNode = tools.findOrCreateChild(personNode, "Address"); assertNotNull(childNode); assertThat(childNode.getName(), is("Address")); }
@Test public void shouldFailFindOrCreateChildNodeStringNullNode() { try { tools.findOrCreateChild(NULL_NODE, "childNode"); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } }
@Test public void shouldFailFindOrCreateChildNodeStringNullPath() { try { tools.findOrCreateChild(addressNode, NULL_STRING); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } }
@Test public void testCreateChildNodeWithParentNameType() throws RepositoryException { Node childNode = tools.findOrCreateChild(personNode, "Hobby", DEF_TYPE); assertNotNull(childNode); assertThat(childNode.getName(), is("Hobby")); }
@Test public void testFindChildNodeWithParentNameType() throws RepositoryException { Node childNode = tools.findOrCreateChild(personNode, "Address", DEF_TYPE); assertNotNull(childNode); assertThat(childNode.getName(), is("Address")); }
@Test public void shouldFailFindOrCreateChildWithNullParentNameType() { try { tools.findOrCreateChild(NULL_NODE, "childNode", DEF_TYPE); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } }
@Test public void shouldFailFindOrCreateChildNodeStringStringNullPath() { try { tools.findOrCreateChild(addressNode, NULL_STRING, DEF_TYPE); } catch (Exception e) { assertTrue(e instanceof IllegalArgumentException); } }