String uuidLink = impl.createNewImportedRule( "testLinkedAssetItemHistoryRelatedRule",
"testLinkedAssetItemHistoryRelatedPack" );
assertTrue( uuidLink.equals( uuid ) );
//create version 1.
RuleAsset assetWrapper = repositoryAssetService.loadRuleAsset( uuidLink );
assertEquals( assetWrapper.description,
"an initial desc" );
assetWrapper.description = "version 1";
String uuidLink1 = repositoryAssetService.checkinVersion( assetWrapper );
//create version 2
RuleAsset assetWrapper2 = repositoryAssetService.loadRuleAsset( uuidLink );
assetWrapper2.description = "version 2";
String uuidLink2 = repositoryAssetService.checkinVersion( assetWrapper2 );
//create version head
RuleAsset assetWrapper3 = repositoryAssetService.loadRuleAsset( uuidLink );
assetWrapper3.description = "version head";
@SuppressWarnings("unused")
String uuidLink3 = repositoryAssetService.checkinVersion( assetWrapper3 );
assertEquals( uuidLink,
uuidLink1 );
assertEquals( uuidLink,
uuidLink2 );
//verify the history info of LinkedAssetItem
TableDataResult result = repositoryAssetService.loadItemHistory( uuidLink );
assertNotNull( result );
TableDataRow[] rows = result.data;
assertEquals( 3,
rows.length );
assertFalse( rows[0].id.equals( uuidLink ) );
assertFalse( rows[1].id.equals( uuidLink ) );
assertFalse( rows[2].id.equals( uuidLink ) );
RuleAsset version1 = repositoryAssetService.loadRuleAsset( rows[0].id );
RuleAsset version2 = repositoryAssetService.loadRuleAsset( rows[1].id );
RuleAsset version3 = repositoryAssetService.loadRuleAsset( rows[2].id );
RuleAsset versionHead = repositoryAssetService.loadRuleAsset( uuidLink );
assertFalse( version1.versionNumber == version2.versionNumber );
assertFalse( version1.versionNumber == versionHead.versionNumber );
assertEquals( version1.description,
"an initial desc" );
assertEquals( version2.description,
"version 1" );
assertEquals( version3.description,
"version 2" );
assertEquals( versionHead.description,
"version head" );
//verify the history info of the original AssetItem
result = repositoryAssetService.loadItemHistory( uuid );
assertNotNull( result );
rows = result.data;
assertEquals( 3,
rows.length );
assertFalse( rows[0].id.equals( uuid ) );
assertFalse( rows[1].id.equals( uuid ) );
version1 = repositoryAssetService.loadRuleAsset( rows[0].id );
version2 = repositoryAssetService.loadRuleAsset( rows[1].id );
versionHead = repositoryAssetService.loadRuleAsset( uuid );
assertFalse( version1.versionNumber == version2.versionNumber );
assertFalse( version1.versionNumber == versionHead.versionNumber );
assertTrue( version1.description.equals( "an initial desc" ) );
assertTrue( version2.description.equals( "version 1" ) );
assertTrue( versionHead.description.equals( "version head" ) );
//test restore
repositoryAssetService.restoreVersion( version1.uuid,
versionHead.uuid,
"this was cause of a mistake" );
RuleAsset newHead = repositoryAssetService.loadRuleAsset( uuid );
assertEquals( "this was cause of a mistake",
newHead.checkinComment );
}