@Test public void test_doAction_nodeIsNull() throws PersistenceException, RepositoryException { when(resource.adaptTo(Node.class)).thenReturn(null); ChangePrimaryType changePrimaryType = new ChangePrimaryType(newPrimaryType); changePrimaryType.doAction(resource); verify(node, never()).setPrimaryType(newPrimaryType); }
@Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); try { if (null != node) { node.setPrimaryType(newPrimaryType); return "Updated jcr:primaryType to " + newPrimaryType; } } catch (RepositoryException e) { throw new PersistenceException("ERROR: could not update jcr:primaryType to " + newPrimaryType, e); } return "WARNING: could not update jcr:primaryType to " + newPrimaryType; }
ChangePrimaryType implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); try { if (null != node) { node.setPrimaryType(newPrimaryType); return "Updated jcr:primaryType to " + newPrimaryType; } } catch (RepositoryException e) { throw new PersistenceException("ERROR: could not update jcr:primaryType to " + newPrimaryType, e); } return "WARNING: could not update jcr:primaryType to " + newPrimaryType; } }
ChangePrimaryType implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); try { if (null != node) { node.setPrimaryType(newPrimaryType); return "Updated jcr:primaryType to " + newPrimaryType; } } catch (RepositoryException e) { throw new PersistenceException("ERROR: could not update jcr:primaryType to " + newPrimaryType, e); } return "WARNING: could not update jcr:primaryType to " + newPrimaryType; } ChangePrimaryType(@Nonnull String newPrimaryType); }
ChangePrimaryType implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); try { if (null != node) { node.setPrimaryType(newPrimaryType); return "Updated jcr:primaryType to " + newPrimaryType; } } catch (RepositoryException e) { throw new PersistenceException("ERROR: could not update jcr:primaryType to " + newPrimaryType, e); } return "WARNING: could not update jcr:primaryType to " + newPrimaryType; } ChangePrimaryType(@Nonnull String newPrimaryType); @Override String doAction(@Nonnull Resource resource); }
ChangePrimaryType implements Action { @Override public String doAction(@Nonnull Resource resource) throws PersistenceException { Node node = resource.adaptTo(Node.class); try { if (null != node) { node.setPrimaryType(newPrimaryType); return "Updated jcr:primaryType to " + newPrimaryType; } } catch (RepositoryException e) { throw new PersistenceException("ERROR: could not update jcr:primaryType to " + newPrimaryType, e); } return "WARNING: could not update jcr:primaryType to " + newPrimaryType; } ChangePrimaryType(@Nonnull String newPrimaryType); @Override String doAction(@Nonnull Resource resource);  }