### Question:
OnDeployScriptBase implements OnDeployScript { protected final Node getOrCreateNode(String absolutePath) throws RepositoryException { return getOrCreateNode(absolutePath, JcrConstants.NT_UNSTRUCTURED, JcrConstants.NT_UNSTRUCTURED); }  final void execute(ResourceResolver resourceResolver);  }### Answer:
@Test public void testGetOrCreateNode() throws RepositoryException { Node node = onDeployScript.getOrCreateNode("/content/test1/folder/page"); assertNotNull(node); assertEquals("/content/test1/folder/page", node.getPath()); assertEquals("nt:unstructured", node.getPrimaryNodeType().getName()); Node parent = node.getParent(); assertEquals("/content/test1/folder", parent.getPath()); assertEquals("nt:unstructured", parent.getPrimaryNodeType().getName()); Node grandParent = parent.getParent(); assertEquals("/content/test1", grandParent.getPath()); assertEquals("nt:unstructured", grandParent.getPrimaryNodeType().getName()); Node base = grandParent.getParent(); assertEquals("/content", base.getPath()); assertEquals("nt:resource", base.getPrimaryNodeType().getName()); }
@Test public void testGetOrCreateNodeWithAllTypesSpecified() throws RepositoryException { Node node = onDeployScript.getOrCreateNode("/content/test2/folder/page", "nt:folder", "cq:Page"); assertNotNull(node); assertEquals("/content/test2/folder/page", node.getPath()); assertEquals("cq:Page", node.getPrimaryNodeType().getName()); Node parent = node.getParent(); assertEquals("/content/test2/folder", parent.getPath()); assertEquals("nt:folder", parent.getPrimaryNodeType().getName()); Node grandParent = parent.getParent(); assertEquals("/content/test2", grandParent.getPath()); assertEquals("nt:folder", grandParent.getPrimaryNodeType().getName()); Node base = grandParent.getParent(); assertEquals("/content", base.getPath()); assertEquals("nt:resource", base.getPrimaryNodeType().getName()); Node nodeAgain = onDeployScript.getOrCreateNode("/content/test2/folder/page", "nt:folder", "cq:Page"); assertNotNull(nodeAgain); }
@Test public void testGetOrCreateNodeWithNodeTypeSpecified() throws RepositoryException { Node node = onDeployScript.getOrCreateNode("/content/test3/folder/page", "cq:Page"); assertNotNull(node); assertEquals("/content/test3/folder/page", node.getPath()); assertEquals("cq:Page", node.getPrimaryNodeType().getName()); Node parent = node.getParent(); assertEquals("/content/test3/folder", parent.getPath()); assertEquals("nt:unstructured", parent.getPrimaryNodeType().getName()); Node grandParent = parent.getParent(); assertEquals("/content/test3", grandParent.getPath()); assertEquals("nt:unstructured", grandParent.getPrimaryNodeType().getName()); Node base = grandParent.getParent(); assertEquals("/content", base.getPath()); assertEquals("nt:resource", base.getPrimaryNodeType().getName()); }