@Test public void doAction_noMatch() throws PersistenceException, ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException { ReplaceResourcePropertyValues action = new ReplaceResourcePropertyValues("nomatch", NEW_VAL, Arrays.asList(PROP1)); String result = action.doAction(resource); assertEquals("", result); verify(prop1, never()).setValue("val1_newVal_suffix"); verify(prop2, never()).setValue(Mockito.anyString()); verify(prop3, never()).setValue(Mockito.any(Value[].class)); verify(prop4, never()).setValue(Mockito.anyString()); }
@Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); if (node == null) { return StringUtils.EMPTY; } boolean updated = false; try { PropertyIterator propertyIterator = node.getProperties(); while (propertyIterator.hasNext()) { Property property = propertyIterator.nextProperty(); if (doChangeProperty(property)) { if (property.isMultiple()) { boolean propUpdated = updateMulti(property); updated = updated || propUpdated; } else { boolean propUpdated = updateSingle(property); updated = updated || propUpdated; } } } } catch (RepositoryException e) { throw new PersistenceException("Rename failed", e); } if (updated) { return "Updated values from " + oldValue + " to " + newValue + " in " + resource.getPath(); } return StringUtils.EMPTY; }
ReplaceResourcePropertyValues implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); if (node == null) { return StringUtils.EMPTY; } boolean updated = false; try { PropertyIterator propertyIterator = node.getProperties(); while (propertyIterator.hasNext()) { Property property = propertyIterator.nextProperty(); if (doChangeProperty(property)) { if (property.isMultiple()) { boolean propUpdated = updateMulti(property); updated = updated || propUpdated; } else { boolean propUpdated = updateSingle(property); updated = updated || propUpdated; } } } } catch (RepositoryException e) { throw new PersistenceException("Rename failed", e); } if (updated) { return "Updated values from " + oldValue + " to " + newValue + " in " + resource.getPath(); } return StringUtils.EMPTY; } }
ReplaceResourcePropertyValues implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); if (node == null) { return StringUtils.EMPTY; } boolean updated = false; try { PropertyIterator propertyIterator = node.getProperties(); while (propertyIterator.hasNext()) { Property property = propertyIterator.nextProperty(); if (doChangeProperty(property)) { if (property.isMultiple()) { boolean propUpdated = updateMulti(property); updated = updated || propUpdated; } else { boolean propUpdated = updateSingle(property); updated = updated || propUpdated; } } } } catch (RepositoryException e) { throw new PersistenceException("Rename failed", e); } if (updated) { return "Updated values from " + oldValue + " to " + newValue + " in " + resource.getPath(); } return StringUtils.EMPTY; } ReplaceResourcePropertyValues(@Nonnull String oldValue, @Nonnull String newValue,
            @Nonnull List<String> propertyNames); }
ReplaceResourcePropertyValues implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); if (node == null) { return StringUtils.EMPTY; } boolean updated = false; try { PropertyIterator propertyIterator = node.getProperties(); while (propertyIterator.hasNext()) { Property property = propertyIterator.nextProperty(); if (doChangeProperty(property)) { if (property.isMultiple()) { boolean propUpdated = updateMulti(property); updated = updated || propUpdated; } else { boolean propUpdated = updateSingle(property); updated = updated || propUpdated; } } } } catch (RepositoryException e) { throw new PersistenceException("Rename failed", e); } if (updated) { return "Updated values from " + oldValue + " to " + newValue + " in " + resource.getPath(); } return StringUtils.EMPTY; } ReplaceResourcePropertyValues(@Nonnull String oldValue, @Nonnull String newValue,
            @Nonnull List<String> propertyNames); @Override String doAction(@Nonnull Resource resource); }
ReplaceResourcePropertyValues implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); if (node == null) { return StringUtils.EMPTY; } boolean updated = false; try { PropertyIterator propertyIterator = node.getProperties(); while (propertyIterator.hasNext()) { Property property = propertyIterator.nextProperty(); if (doChangeProperty(property)) { if (property.isMultiple()) { boolean propUpdated = updateMulti(property); updated = updated || propUpdated; } else { boolean propUpdated = updateSingle(property); updated = updated || propUpdated; } } } } catch (RepositoryException e) { throw new PersistenceException("Rename failed", e); } if (updated) { return "Updated values from " + oldValue + " to " + newValue + " in " + resource.getPath(); } return StringUtils.EMPTY; } ReplaceResourcePropertyValues(@Nonnull String oldValue, @Nonnull String newValue,
            @Nonnull List<String> propertyNames); @Override String doAction(@Nonnull Resource resource);  }