ParameterPushdownModel extends AbstractModel { public ParameterPushdownModel reset() { final ImmutableList.Builder<DefinitionAdapter> builder = ImmutableList.builder(); Iterator<ParameterPushdown.Definition> iterator = parameterPushdown.getDefinitions().iterator(); while ( iterator.hasNext() ) { ParameterPushdown.Definition definition = iterator.next(); if ( definition.isValid() ) { builder.add( createAdapter( definition ) ); } else { iterator.remove(); } } for ( int i = 0; i < 10; i++ ) { builder.add( createAdapter( parameterPushdown.createDefinition() ) ); } modify( new Runnable() { @Override public void run() { definitions = builder.build(); } } ); return this; } ParameterPushdownModel( ParameterPushdown parameterPushdown ); ParameterPushdownModel reset(); ParameterPushdown getDelegate(); ImmutableList<DefinitionAdapter> getDefinitions(); void setFieldList( ImmutableList<String> fieldList ); @Override Map<String, Object> snapshot();  }
@Test public void testReset() throws Exception { ParameterPushdown.Definition definition = parameterPushdown.createDefinition(); definition.setFieldName( "field" ); definition.setParameter( "param" ); ImmutableList<ParameterPushdownModel.DefinitionAdapter> definitions = model.reset().getDefinitions(); verify( changeSupport ).firePropertyChange( eq( "definitions" ), argThat( empty() ), eq( definitions ) ); assertThat( definitions, hasSize( greaterThan( 1 ) ) ); assertThat( definitions.get( 0 ), equalsDefinition( "field", "param", ParameterPushdown.DEFAULT_FORMAT ) ); assertThat( FluentIterable.from( definitions ).skip( 1 ), everyItem( equalsDefinition( "", "", "" ) ) ); }