### Question:
OnDeployScriptBase implements OnDeployScript { protected final void updateResourceType(Node node, String resourceType) throws RepositoryException { boolean hasResourceType = node.hasProperty(SLING_RESOURCE_TYPE); if (!hasResourceType || !resourceType.equals(node.getProperty(SLING_RESOURCE_TYPE).getString())) { logger.info("Updating node at {} to resource type: {}", node.getPath(), resourceType); node.setProperty(SLING_RESOURCE_TYPE, resourceType); } else { logger.info("Node at {} is already resource type: {}", node.getPath(), resourceType); } }  final void execute(ResourceResolver resourceResolver);  }### Answer:
@Test public void testUpdateResourceType() throws RepositoryException { Resource resourceToUpdate = resourceResolver.getResource("/content/resource-type-update1"); assertEquals("test/component/comp1", resourceToUpdate.getResourceType()); onDeployScript.updateResourceType(resourceToUpdate.adaptTo(Node.class), "test/component/comp2"); resourceToUpdate = resourceResolver.getResource("/content/resource-type-update1"); assertEquals("test/component/comp2", resourceToUpdate.getResourceType()); }
@Test public void testUpdateResourceTypeWhenTypeMissing() throws RepositoryException { Resource resourceToUpdate = resourceResolver.getResource("/content/resource-type-missing"); assertEquals(JcrConstants.NT_UNSTRUCTURED, resourceToUpdate.getResourceType()); onDeployScript.updateResourceType(resourceToUpdate.adaptTo(Node.class), "test/component/comp2"); resourceToUpdate = resourceResolver.getResource("/content/resource-type-missing"); assertEquals("test/component/comp2", resourceToUpdate.getResourceType()); }
@Test public void testUpdateResourceTypeWhenAlreadyUpdated() throws RepositoryException { Resource resourceToUpdate = resourceResolver.getResource("/content/resource-type-update2"); assertEquals("test/component/comp2", resourceToUpdate.getResourceType()); onDeployScript.updateResourceType(resourceToUpdate.adaptTo(Node.class), "test/component/comp2"); assertLogText("Node at /content/resource-type-update2 is already resource type: test/component/comp2"); }