/** * This will return a list of assets for a given state. It works through the * assets that belong to this module, and if they are not in the correct * state, walks backwards until it finds one in the correct state. * <p/> * If it walks all the way back up the versions looking for the "latest" * version with the appropriate state, and can't find one, that asset is not * included in the result. */ public Iterator<AssetItem> getAssetsWithStatus(final StateItem state) { return getAssetsWithStatus(state, null); }
/** * This will return a list of assets for a given state. It works through the * assets that belong to this module, and if they are not in the correct * state, walks backwards until it finds one in the correct state. * <p/> * If it walks all the way back up the versions looking for the "latest" * version with the appropriate state, and can't find one, that asset is not * included in the result. */ public Iterator<AssetItem> getAssetsWithStatus(final StateItem state) { return getAssetsWithStatus(state, null); }
rules = iteratorToList( pack.getAssetsWithStatus(state) ); rules = iteratorToList( pack.getAssetsWithStatus( getRepo().getState( "whee" ) ) ); assertEquals(0, rules.size()); rules = iteratorToList( pack.getAssetsWithStatus(getRepo().getState( StateItem.DRAFT_STATE_NAME )) ); assertEquals(3, rules.size()); rule1.checkin( "latest" ); rules = iteratorToList( pack.getAssetsWithStatus(getRepo().getState( "extractorState" )) ); assertEquals(1, rules.size()); AssetItem rule = (AssetItem) rules.get( 0 ); rules = iteratorToList( pack.getAssetsWithStatus(getRepo().getState( "foobar" )) ); assertEquals(1, rules.size()); AssetItem prior = (AssetItem) rules.get( 0 );
@Test public void testIgnoreState() throws Exception { ModuleItem pack = getRepo().createModule( "package testIgnoreState", "foo" ); getRepo().createState( "x" ); AssetItem rule1 = pack.addAsset( "rule number 1", "yeah man" ); rule1.updateState( "x" ); rule1.checkin( "version0" ); AssetItem rule2 = pack.addAsset( "rule number 2", "no way" ); rule2.updateState( "x" ); rule2.checkin( "version0" ); AssetItem rule3 = pack.addAsset( "rule number 3", "yes way" ); getRepo().createState( "disabled" ); rule3.updateState( "disabled" ); rule3.checkin( "version0" ); getRepo().save(); Iterator result = pack.getAssetsWithStatus( getRepo().getState( "x" ), getRepo().getState( "disabled" ) ); List l = iteratorToList( result ); assertEquals(2, l.size()); }