@Test public void doAction_success() throws PersistenceException, ReplicationException { String result = action.doAction(resource); assertTrue(result.contains("Replicated page")); verify(replicator, times(1)).replicate(session, ReplicationActionType.ACTIVATE, "path"); }
@Override public String doAction(Resource resource) throws PersistenceException { Page page = context.getPageManager().getContainingPage(resource); if (page == null) { return "Unable to find a page for resource " + resource.getPath(); } String action = activate ? "activate" : "deactivate"; String successMessage = "Replicated page " + page.getPath() + " with action " + action; if (context.isDryRun()) { return successMessage; } try { ReplicationActionType type = activate ? ReplicationActionType.ACTIVATE : ReplicationActionType.DEACTIVATE; context.getReplicator().replicate(context.getResolver().adaptTo(Session.class), type, page.getPath()); } catch (ReplicationException e) { throw new PersistenceException("Unable to replicate " + page.getPath()); } return successMessage; }
ReplicatePageAction implements Action { @Override public String doAction(Resource resource) throws PersistenceException { Page page = context.getPageManager().getContainingPage(resource); if (page == null) { return "Unable to find a page for resource " + resource.getPath(); } String action = activate ? "activate" : "deactivate"; String successMessage = "Replicated page " + page.getPath() + " with action " + action; if (context.isDryRun()) { return successMessage; } try { ReplicationActionType type = activate ? ReplicationActionType.ACTIVATE : ReplicationActionType.DEACTIVATE; context.getReplicator().replicate(context.getResolver().adaptTo(Session.class), type, page.getPath()); } catch (ReplicationException e) { throw new PersistenceException("Unable to replicate " + page.getPath()); } return successMessage; } }
ReplicatePageAction implements Action { @Override public String doAction(Resource resource) throws PersistenceException { Page page = context.getPageManager().getContainingPage(resource); if (page == null) { return "Unable to find a page for resource " + resource.getPath(); } String action = activate ? "activate" : "deactivate"; String successMessage = "Replicated page " + page.getPath() + " with action " + action; if (context.isDryRun()) { return successMessage; } try { ReplicationActionType type = activate ? ReplicationActionType.ACTIVATE : ReplicationActionType.DEACTIVATE; context.getReplicator().replicate(context.getResolver().adaptTo(Session.class), type, page.getPath()); } catch (ReplicationException e) { throw new PersistenceException("Unable to replicate " + page.getPath()); } return successMessage; } ReplicatePageAction(boolean activate, BindingContext context); }
ReplicatePageAction implements Action { @Override public String doAction(Resource resource) throws PersistenceException { Page page = context.getPageManager().getContainingPage(resource); if (page == null) { return "Unable to find a page for resource " + resource.getPath(); } String action = activate ? "activate" : "deactivate"; String successMessage = "Replicated page " + page.getPath() + " with action " + action; if (context.isDryRun()) { return successMessage; } try { ReplicationActionType type = activate ? ReplicationActionType.ACTIVATE : ReplicationActionType.DEACTIVATE; context.getReplicator().replicate(context.getResolver().adaptTo(Session.class), type, page.getPath()); } catch (ReplicationException e) { throw new PersistenceException("Unable to replicate " + page.getPath()); } return successMessage; } ReplicatePageAction(boolean activate, BindingContext context); @Override String doAction(Resource resource); }
ReplicatePageAction implements Action { @Override public String doAction(Resource resource) throws PersistenceException { Page page = context.getPageManager().getContainingPage(resource); if (page == null) { return "Unable to find a page for resource " + resource.getPath(); } String action = activate ? "activate" : "deactivate"; String successMessage = "Replicated page " + page.getPath() + " with action " + action; if (context.isDryRun()) { return successMessage; } try { ReplicationActionType type = activate ? ReplicationActionType.ACTIVATE : ReplicationActionType.DEACTIVATE; context.getReplicator().replicate(context.getResolver().adaptTo(Session.class), type, page.getPath()); } catch (ReplicationException e) { throw new PersistenceException("Unable to replicate " + page.getPath()); } return successMessage; } ReplicatePageAction(boolean activate, BindingContext context); @Override String doAction(Resource resource);  }