@Test public void testCopyAsset() throws Exception { RulesRepository repo = getRepo(); repo.createModule( "testCopyAsset", "asset" ); AssetItem item = repo.loadDefaultModule().addAsset( "testCopyAssetSource", "desc" ); item.updateContent( "la" ); item.checkin( "" ); item.updateDescription( "mmm" ); item.checkin( "again" ); assertEquals( 2, item.getVersionNumber() ); String uuid = repo.copyAsset( item.getUUID(), "testCopyAsset", "testCopyAssetDestination" ); AssetItem dest = repo.loadAssetByUUID( uuid ); assertEquals( dest.getName(), dest.getTitle() ); assertEquals( "la", dest.getContent() ); assertEquals( "testCopyAsset", dest.getModuleName() ); assertFalse( uuid.equals( item.getUUID() ) ); assertEquals( 1, dest.getVersionNumber() ); }
@Test public void testSaveAndCheckinDescriptionAndTitle() throws Exception { AssetItem ruleItem1 = getRepo().loadDefaultModule().addAsset("testGetDescription", ""); ruleItem1.checkin( "version0" ); //it should be "" to begin with assertEquals("", ruleItem1.getDescription()); ruleItem1.updateDescription("test description"); assertEquals("test description", ruleItem1.getDescription()); assertTrue(getRepo().getSession().hasPendingChanges()); ruleItem1.updateTitle( "This is a title" ); assertTrue(getRepo().getSession().hasPendingChanges()); ruleItem1.checkin( "ya" ); //we can save without a checkin getRepo().getSession().save(); assertFalse(getRepo().getSession().hasPendingChanges()); try { ruleItem1.getPrecedingVersion().updateTitle( "baaad" ); fail("should not be able to do this"); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }
@Test public void testGetPackageItemHistorical() throws Exception { RulesRepository repo = getRepo(); ModuleItem pkg = repo.createModule("testGetPackageItemHistorical", ""); AssetItem asset = pkg.addAsset("whee", ""); asset.checkin(""); assertNotNull(asset.getModule()); repo.createModuleSnapshot(pkg.getName(), "SNAP"); ModuleItem pkg_ = repo.loadModuleSnapshot(pkg.getName(), "SNAP"); AssetItem asset_ = pkg_.loadAsset("whee"); ModuleItem pkg__ = asset_.getModule(); assertTrue(pkg__.isSnapshot()); assertTrue(pkg_.isSnapshot()); assertFalse(pkg.isSnapshot()); assertEquals(pkg.getName(), pkg__.getName()); asset.updateDescription("yeah !"); asset.checkin("new"); asset = pkg.loadAsset("whee"); assertNotNull(asset.getModule()); AssetHistoryIterator it = asset.getHistory(); while(it.hasNext()) { AssetItem as = it.next(); if (as.getVersionNumber() > 0) { System.err.println(as.getVersionNumber()); System.err.println(as.getModuleName()); assertNotNull(as.getModule()); assertEquals(pkg.getName(), as.getModule().getName()); } } }
@Test public void testSaveAndCheckinDescriptionAndTitleForShareableAsset() throws Exception { AssetItem asset = getRepo().loadGlobalArea().addAsset("testSaveAndCheckinDescriptionAndTitleForShareableAsset", "desc"); asset.checkin("version0"); AssetItem linkedAsset = getDefaultPackage().addAssetImportedFromGlobalArea(asset.getName()); // it should be "" to begin with assertEquals("desc", linkedAsset.getDescription()); linkedAsset.updateDescription("test description"); assertEquals("test description", linkedAsset.getDescription()); assertTrue(getRepo().getSession().hasPendingChanges()); linkedAsset.updateTitle("This is a title"); assertTrue(getRepo().getSession().hasPendingChanges()); linkedAsset.checkin("ya"); // we can save without a checkin getRepo().getSession().save(); assertFalse(getRepo().getSession().hasPendingChanges()); try { linkedAsset.getPrecedingVersion().updateTitle("baaad"); fail("should not be able to do this"); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }
ruleItem1.updateDescription( "descr2" ); Thread.sleep( 100 ); ruleItem1.checkin( "boo" );
assertEquals(getDefaultPackage().getName(), linkedPkg.getName()); linkedAsset.updateDescription("yeah !");
linkedAsset.updateDescription("descr2"); Thread.sleep(100); linkedAsset.checkin("boo");