String uuidLink = serviceImplementation.createNewImportedRule( "testLinkedAssetItemHistoryRelatedRule",
"testLinkedAssetItemHistoryRelatedPack" );
assertTrue( uuidLink.equals( uuid ) );
//create version 1.
Asset assetWrapper = repositoryAssetService.loadRuleAsset( uuidLink );
assertEquals( assetWrapper.getDescription(),
"an initial desc" );
assetWrapper.setDescription( "version 1" );
String uuidLink1 = repositoryAssetService.checkinVersion( assetWrapper );
//create version 2
Asset assetWrapper2 = repositoryAssetService.loadRuleAsset( uuidLink );
assetWrapper2.setDescription( "version 2" );
String uuidLink2 = repositoryAssetService.checkinVersion( assetWrapper2 );
//create version head
Asset assetWrapper3 = repositoryAssetService.loadRuleAsset( uuidLink );
assetWrapper3.setDescription( "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( 4,
rows.length );
assertFalse( rows[0].id.equals( uuidLink ) );
assertFalse( rows[1].id.equals( uuidLink ) );
assertFalse( rows[2].id.equals( uuidLink ) );
Asset version1 = repositoryAssetService.loadRuleAsset( rows[0].id );
Asset version2 = repositoryAssetService.loadRuleAsset( rows[1].id );
Asset version3 = repositoryAssetService.loadRuleAsset( rows[2].id );
Asset versionHead = repositoryAssetService.loadRuleAsset( uuidLink );
assertFalse( version1.getVersionNumber() == version2.getVersionNumber() );
assertFalse( version1.getVersionNumber() == versionHead.getVersionNumber() );
assertEquals( version1.getDescription(),
"an initial desc" );
assertEquals( version2.getDescription(),
"version 1" );
assertEquals( version3.getDescription(),
"version 2" );
assertEquals( versionHead.getDescription(),
"version head" );
//verify the history info of the original AssetItem
result = repositoryAssetService.loadItemHistory( uuid );
assertNotNull( result );
rows = result.data;
assertEquals( 4,
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.getVersionNumber() == version2.getVersionNumber() );
assertFalse( version1.getVersionNumber() == versionHead.getVersionNumber() );
assertTrue( version1.getDescription().equals( "an initial desc" ) );
assertTrue( version2.getDescription().equals( "version 1" ) );
assertTrue( versionHead.getDescription().equals( "version head" ) );
//test restore
repositoryAssetService.restoreVersion( version1.getUuid(),
versionHead.getUuid(),
"this was cause of a mistake" );
Asset newHead = repositoryAssetService.loadRuleAsset( uuid );
assertEquals( "this was cause of a mistake",
newHead.getCheckinComment() );
}