public void testArchiveAndUnarchivePackageAndHeader() throws Exception {
ServiceImplementation impl = getServiceImplementation();
RepositoryPackageService repositoryPackageService = getRepositoryPackageService();
String uuid = repositoryPackageService.createPackage( "testArchiveAndUnarchivePackageAndHeader",
"a desc" );
PackageConfigData data = repositoryPackageService.loadPackageConfig( uuid );
PackageItem it = impl.getRulesRepository().loadPackageByUUID( uuid );
data.setArchived( true );
AssetItem rule1 = it.addAsset( "rule_1",
"" );
rule1.updateFormat( AssetFormats.DRL );
rule1.updateContent( "rule 'rule1' \n when \np : Person() \n then \np.setAge(42); \n end" );
rule1.archiveItem( true );
rule1.checkin( "" );
impl.getRulesRepository().save();
repositoryPackageService.savePackage( data );
data = repositoryPackageService.loadPackageConfig( uuid );
it = impl.getRulesRepository().loadPackage( data.getName() );
assertTrue( data.isArchived() );
assertTrue( it.loadAsset( "drools" ).isArchived() );
assertTrue( it.loadAsset( "rule_1" ).isArchived() );
data.setArchived( false );
repositoryPackageService.savePackage( data );
data = repositoryPackageService.loadPackageConfig( uuid );
it = impl.getRulesRepository().loadPackage( data.getName() );
assertFalse( data.isArchived() );
assertFalse( it.loadAsset( "drools" ).isArchived() );
assertTrue( it.loadAsset( "rule_1" ).isArchived() );
data.setArchived( true );
repositoryPackageService.savePackage( data );
data = repositoryPackageService.loadPackageConfig( uuid );
it = impl.getRulesRepository().loadPackage( data.getName() );
assertTrue( data.isArchived() );
assertTrue( it.loadAsset( "drools" ).isArchived() );
assertTrue( it.loadAsset( "rule_1" ).isArchived() );
}