ParameterGenerationModel extends AbstractModel { public ImmutableList<SourceTargetAdapter> getMappings() { return ImmutableList.copyOf( mappings ); } ParameterGenerationModel( ParameterGenerationFactory factory, DataServiceModel dialogModel ); void add( PushDownOptimizationMeta meta ); void remove( PushDownOptimizationMeta meta ); ImmutableMap<String, PushDownOptimizationMeta> getParameterMap(); void setParameterMap( Map<String, PushDownOptimizationMeta> map ); String getSelectedParameter(); PushDownOptimizationMeta getSelectedOptimization(); ParameterGeneration getParameterGeneration(); void setSelectedParameter( final String selectedParameter ); @Override Map<String, Object> snapshot(); DataServiceModel getDialogModel(); String getSelectedStep(); void setSelectedStep( String stepName ); void setEnabled( boolean enabled ); boolean isEnabled(); ImmutableList<SourceTargetAdapter> getMappings();  }
@Test public void testGetMappings() throws Exception { ParameterGeneration parameterGeneration = (ParameterGeneration) createParameterGeneration( "parameter" ).getType(); parameterGeneration.createFieldMapping( "source", "target" ); model.updateParameterMap(); assertThat( model.getMappings(), empty() ); model.setSelectedParameter( "parameter" ); ImmutableList<SourceTargetAdapter> mappings = model.getMappings(); assertThat( mappings, hasSize( greaterThan( 1 ) ) ); assertThat( mappings.get( 0 ), allOf( hasProperty( "sourceFieldName", is( "source" ) ), hasProperty( "targetFieldName", is( "target" ) ) ) ); assertThat( mappings.subList( 1, mappings.size() ), everyItem( hasProperty( "defined", is( false ) ) ) ); verify( changeSupport ).firePropertyChange( "mappings", ImmutableList.of(), mappings ); SourceTargetAdapter sourceTargetAdapter = mappings.get( 1 ); sourceTargetAdapter.setSourceFieldName( "secondSource" ); sourceTargetAdapter.setTargetFieldName( "secondTarget" ); assertThat( parameterGeneration.getFieldMappings().get( 1 ).getSourceFieldName(), is( "secondSource" ) ); assertThat( parameterGeneration.getFieldMappings().get( 1 ).getTargetFieldName(), is( "secondTarget" ) ); }