@Test public void doAction() throws PersistenceException { when(valueMap.remove(ATTR_OLD)).thenReturn(VAL1); RenameProperty action = new RenameProperty(ATTR_OLD, ATTR_NEW); action.doAction(resource); verify(valueMap, times(1)).remove(ATTR_OLD); verify(valueMap, times(1)).put(ATTR_NEW, VAL1); }
@Override public String doAction(@Nonnull Resource resource) { ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class); if (properties != null) { Object value = properties.remove(oldName); properties.put(newName, value); return "Renaming property " + oldName + " to " + newName + " for resource " + resource.getPath(); } return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath(); }
RenameProperty implements Action { @Override public String doAction(@Nonnull Resource resource) { ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class); if (properties != null) { Object value = properties.remove(oldName); properties.put(newName, value); return "Renaming property " + oldName + " to " + newName + " for resource " + resource.getPath(); } return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath(); } }
RenameProperty implements Action { @Override public String doAction(@Nonnull Resource resource) { ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class); if (properties != null) { Object value = properties.remove(oldName); properties.put(newName, value); return "Renaming property " + oldName + " to " + newName + " for resource " + resource.getPath(); } return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath(); } RenameProperty(@Nonnull String oldName, @Nonnull String newName); }
RenameProperty implements Action { @Override public String doAction(@Nonnull Resource resource) { ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class); if (properties != null) { Object value = properties.remove(oldName); properties.put(newName, value); return "Renaming property " + oldName + " to " + newName + " for resource " + resource.getPath(); } return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath(); } RenameProperty(@Nonnull String oldName, @Nonnull String newName); @Override String doAction(@Nonnull Resource resource); }
RenameProperty implements Action { @Override public String doAction(@Nonnull Resource resource) { ModifiableValueMap properties = resource.adaptTo(ModifiableValueMap.class); if (properties != null) { Object value = properties.remove(oldName); properties.put(newName, value); return "Renaming property " + oldName + " to " + newName + " for resource " + resource.getPath(); } return "WARNING: could not get ModifiableValueMap for resource " + resource.getPath(); } RenameProperty(@Nonnull String oldName, @Nonnull String newName); @Override String doAction(@Nonnull Resource resource);  }