@Override public void execute(InstallContext ctx) throws TaskExecutionException { new MoveNodeTask("", "", RepositoryConstants.CONFIG, from, to, true).execute(ctx); new SetPropertyTask(RepositoryConstants.CONFIG, to, "icon", icon).execute(ctx); }
@Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { final Session session = installContext.getConfigJCRSession(); final String newCacheFactoryName = StringUtils.substringBefore(StringUtils.lowerCase(StringUtils.substringAfterLast(session.getNode("/modules/cache/config/cacheFactory/").getProperty("class").getString(), ".")), "factory"); new RenameNodeTask("", RepositoryConstants.CONFIG, "/modules/cache/config", "cacheFactory", newCacheFactoryName, false).execute(installContext); new BootstrapSingleModuleResource("config.modules.cache.config.cacheFactory.xml").execute(installContext); new MoveNodeTask("", "/modules/cache/config/" + newCacheFactoryName, "/modules/cache/config/cacheFactory/delegateFactories/" + newCacheFactoryName, false).execute(installContext); } }
@Test public void moveWithOverwriteFalseWhenItIsExisitingAtNewLocation() throws Exception { // GIVEN root.addNode(DEST_PATH, NodeTypes.Folder.NAME); final MoveNodeTask task = new MoveNodeTask("test", "/" + SRC_PATH, "/" + DEST_PATH, false); // WHEN task.execute(ctx); // THEN assertThat("Node exists at old location", root, hasNode(SRC_PATH, NodeTypes.Content.NAME)); assertThat("Node exists at new location with previous nodeType", root, hasNode(DEST_PATH, NodeTypes.Folder.NAME)); assertThat(ctx.getMessages().values(), is(not(empty()))); } }
@Test public void moveWithOverwriteTrueWhenItIsExisitingAtNewLocation() throws Exception { // GIVEN root.addNode(DEST_PATH, NodeTypes.Folder.NAME); final MoveNodeTask task = new MoveNodeTask("test", "/" + SRC_PATH, "/" + DEST_PATH, true); // WHEN task.execute(ctx); // THEN assertThat("Node doesn't exist at old location", root, not(hasNode(SRC_PATH))); assertThat("Node exists at new location with proper nodeType", root, hasNode(DEST_PATH, NodeTypes.Content.NAME)); }
@Test public void moveToNewDestination() throws Exception { // GIVEN final MoveNodeTask task = new MoveNodeTask("test", "/" + SRC_PATH, "/" + DEST_PATH, false); // WHEN task.execute(ctx); // THEN assertThat("Node exists at new location", root, hasNode(DEST_PATH, NodeTypes.Content.NAME)); assertThat("Node doesn't exist at old location", root, not(hasNode(SRC_PATH))); }