public class RepositoryPackageServiceTest extends GuvnorTestBase {
@Test
public void testSnapshotDiff() throws Exception {
RepositoryService impl = getServiceImplementation();
RepositoryPackageService repositoryPackageService = getRepositoryPackageService();
RepositoryCategoryService repositoryCategoryService = getRepositoryCategoryService();
// Lets make a package and a rule into tit.
repositoryCategoryService.createCategory( "/",
"snapshotDiffTesting",
"y" );
String packageUuid = repositoryPackageService.createPackage( "testSnapshotDiff",
"d",
"package" );
assertNotNull( packageUuid );
// Create two rules
String archiveRuleUuid = impl.createNewRule( "testRuleArchived",
"",
"snapshotDiffTesting",
"testSnapshotDiff",
AssetFormats.DRL );
String modifiedRuleUuid = impl.createNewRule( "testRuleModified",
"",
"snapshotDiffTesting",
"testSnapshotDiff",
AssetFormats.DRL );
String deletedRuleUuid = impl.createNewRule( "testRuleDeleted",
"",
"snapshotDiffTesting",
"testSnapshotDiff",
AssetFormats.DRL );
String restoredRuleUuid = impl.createNewRule( "testRuleRestored",
"",
"snapshotDiffTesting",
"testSnapshotDiff",
AssetFormats.DRL );
@SuppressWarnings("unused")
String noChangesRuleUuid = impl.createNewRule( "testRuleNoChanges",
"",
"snapshotDiffTesting",
"testSnapshotDiff",
AssetFormats.DRL );
RepositoryAssetService repositoryAssetService = getRepositoryAssetService();
repositoryAssetService.archiveAsset( restoredRuleUuid );
// Create a snapshot called FIRST for the package
repositoryPackageService.createPackageSnapshot( "testSnapshotDiff",
"FIRST",
false,
"ya" );
assertEquals( 1,
repositoryPackageService.listSnapshots( "testSnapshotDiff" ).length );
assertEquals( 4,
repositoryPackageService.listRulesInPackage( "testSnapshotDiff" ).length );
// Change the rule, archive one, delete one and create a new one
RuleAsset asset = repositoryAssetService.loadRuleAsset( modifiedRuleUuid );
String uuid = repositoryAssetService.checkinVersion( asset );
assertNotNull( uuid );
repositoryAssetService.removeAsset( deletedRuleUuid );
repositoryAssetService.archiveAsset( archiveRuleUuid );
@SuppressWarnings("unused")
String addedRuleUuid = impl.createNewRule( "testRuleAdded",
"",
"snapshotDiffTesting",
"testSnapshotDiff",
AssetFormats.DRL );