public void renameState(String oldName, String newName) { try { StateItem state = loadState(oldName); Node node = state.getNode(); String sourcePath = node.getPath(); String destPath = node.getParent().getPath() + "/" + newName; this.session.move(sourcePath, destPath); save(); } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
public void renameState(String oldName, String newName) { try { StateItem state = loadState(oldName); Node node = state.getNode(); String sourcePath = node.getPath(); String destPath = node.getParent().getPath() + "/" + newName; this.session.move(sourcePath, destPath); save(); } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
@Test public void testRemoveState() { RulesRepository repo = getRepo(); StateItem[] items = repo.listStates(); assertTrue( items.length > 0 ); final String name = "stateThatHasALongNameAndWillBeRenamed"; repo.createState( name ); StateItem[] items2 = repo.listStates(); assertEquals( items.length + 1, items2.length ); repo.loadState( name ).remove(); repo.save(); StateItem[] items3 = repo.listStates(); assertEquals( items2.length -1, items3.length ); try { repo.loadState( name ); fail( "Should never be here. Removed state still exists." ); } catch ( RulesRepositoryException e ) { // Works } } /*
@Test public void testRenameState() { RulesRepository repo = getRepo(); StateItem[] items = repo.listStates(); assertTrue( items.length > 0 ); final String oldName = "stateThatHasALongNameAndWillBeRenamed"; repo.createState( oldName ); StateItem[] items2 = repo.listStates(); assertEquals( items.length + 1, items2.length ); final String newName = "stateThatHasALongNameAndWillBeRenamedNameAfterTheRenaming"; repo.renameState( oldName, newName ); StateItem[] items3 = repo.listStates(); assertEquals( items2.length, items3.length ); try { repo.loadState( oldName ); fail( "Should never be here. Old name is still used." ); } catch ( RulesRepositoryException e ) { // Works } assertNotNull( repo.loadState( newName ) ); }