"this is a description",
"testCheckinCategory",
RulesRepository.DEFAULT_PACKAGE,
AssetFormats.DRL );
RepositoryAssetService repositoryAssetService = getRepositoryAssetService();
RuleAsset asset = repositoryAssetService.loadRuleAsset( uuid );
assertNotNull( asset.lastModified );
asset.metaData.coverage= "boo";
asset.content= new RuleContentText();
((RuleContentText) asset.content).content = "yeah !";
asset.description= "Description 1";
Date start = new Date();
Thread.sleep( 100 );
String uuid2 = repositoryAssetService.checkinVersion( asset );
assertEquals( uuid,
uuid2 );
assertTrue( ib.loadRecentEdited().size() > inbox.size() );
RuleAsset asset2 = repositoryAssetService.loadRuleAsset( uuid );
assertNotNull( asset2.lastModified );
assertTrue( asset2.lastModified.after(start) );
assertEquals( "boo",
asset2.metaData.coverage );
assertEquals( 1,
asset2.versionNumber );
assertEquals( "yeah !",
((RuleContentText) asset2.content).content );
assertEquals( "Description 1",
asset2.description );
asset2.metaData.coverage = "ya";
asset2.checkinComment = "checked in";
String cat = asset2.metaData.categories[0];
asset2.metaData.categories = new String[3];
asset2.metaData.categories[0] = cat;
asset2.metaData.categories[1] = "testCheckinCategory2";
asset2.metaData.categories[2] = "testCheckinCategory/deeper";
asset2.description = "Description 2";
repositoryAssetService.checkinVersion( asset2 );
asset2 = repositoryAssetService.loadRuleAsset( uuid );
assertEquals( "ya",
asset2.metaData.coverage );
assertEquals( 2,
asset2.versionNumber );
assertEquals( "checked in",
asset2.checkinComment );
assertEquals( 3,
asset2.metaData.categories.length );
assertEquals( "testCheckinCategory",
asset2.metaData.categories[0] );
assertEquals( "testCheckinCategory2",
asset2.metaData.categories[1] );
assertEquals( "testCheckinCategory/deeper",
asset2.metaData.categories[2] );
assertEquals( "Description 2",
asset2.description );
// now lets try a concurrent edit of an asset.
// asset3 will be loaded and edited, and then asset2 will try to
// clobber, it, which should fail.
// as it is optimistically locked.
RuleAsset asset3 = repositoryAssetService.loadRuleAsset( asset2.uuid );
asset3.metaData.subject = "new sub";
repositoryAssetService.checkinVersion( asset3 );
asset3 = repositoryAssetService.loadRuleAsset( asset2.uuid );
assertFalse( asset3.versionNumber == asset2.versionNumber );