"this is a description",
"testCheckinCategory",
RulesRepository.DEFAULT_PACKAGE,
AssetFormats.DRL );
RepositoryAssetService repositoryAssetService = getRepositoryAssetService();
RuleAsset asset = repositoryAssetService.loadRuleAsset( uuid );
assertNotNull( asset.getLastModified() );
asset.getMetaData().setCoverage( "boo" );
asset.setContent( new RuleContentText() );
((RuleContentText) asset.getContent()).content = "yeah !";
asset.setDescription( "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.getLastModified() );
assertTrue( asset2.getLastModified().after( start ) );
assertEquals( "boo",
asset2.getMetaData().getCoverage() );
assertEquals( 1,
asset2.getVersionNumber() );
assertEquals( "yeah !",
((RuleContentText) asset2.getContent()).content );
assertEquals( "Description 1",
asset2.getDescription() );
asset2.getMetaData().setCoverage( "ya" );
asset2.setCheckinComment( "checked in" );
String cat = asset2.getMetaData().getCategories()[0];
asset2.getMetaData().setCategories( new String[3] );
asset2.getMetaData().getCategories()[0] = cat;
asset2.getMetaData().getCategories()[1] = "testCheckinCategory2";
asset2.getMetaData().getCategories()[2] = "testCheckinCategory/deeper";
asset2.setDescription( "Description 2" );
repositoryAssetService.checkinVersion( asset2 );
asset2 = repositoryAssetService.loadRuleAsset( uuid );
assertEquals( "ya",
asset2.getMetaData().getCoverage() );
assertEquals( 2,
asset2.getVersionNumber() );
assertEquals( "checked in",
asset2.getCheckinComment() );
assertEquals( 3,
asset2.getMetaData().getCategories().length );
assertEquals( "testCheckinCategory",
asset2.getMetaData().getCategories()[0] );
assertEquals( "testCheckinCategory2",
asset2.getMetaData().getCategories()[1] );
assertEquals( "testCheckinCategory/deeper",
asset2.getMetaData().getCategories()[2] );
assertEquals( "Description 2",
asset2.getDescription() );
// 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.getUuid() );
asset3.getMetaData().setSubject( "new sub" );
repositoryAssetService.checkinVersion( asset3 );
asset3 = repositoryAssetService.loadRuleAsset( asset2.getUuid() );
assertFalse( asset3.getVersionNumber() == asset2.getVersionNumber() );
String result = repositoryAssetService.checkinVersion( asset2 );
assertTrue( result.startsWith( "ERR" ) );
System.err.println( result.substring( 5 ) );
} finally {