CreateResource implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Resource destinationResource = resource; if (StringUtils.isNotBlank(relativePath)) { destinationResource = resourceResolver.getResource(resource, relativePath); } if (destinationResource != null) { Resource newResource = resourceResolver.create(destinationResource, name, properties); return "Created " + newResource.getPath(); } return "WARNING: could not read destination resource at " + relativePath; } CreateResource(@Nonnull String name, @Nonnull Map<String, Object> properties, String relativePath,
            @Nonnull ResourceResolver resourceResolver); @Override String doAction(@Nonnull Resource resource);  }
@Test public void doAction_noRelative() throws PersistenceException, ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException { CreateResource action = new CreateResource(NEW_NAME, properties, null, resolver); action.doAction(resource); verify(resolver, times(1)).create(resource, NEW_NAME, properties); }
@Test public void doAction_Relative() throws PersistenceException, ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException { CreateResource action = new CreateResource(NEW_NAME, properties, INTERMEDIATE, resolver); action.doAction(resource); verify(resolver, times(1)).create(intermediateResource, NEW_NAME, properties); }