StreamingController extends AbstractController { public void initBindings( DataServiceModel model ) throws InvocationTargetException, XulException, KettleException { BindingFactory bindingFactory = getBindingFactory(); XulRadio streamingRadioButton = getElementById( "streaming-type-radio" ); XulRadio normalModeRadio = getElementById( "regular-type-radio" ); XulTab streamingTab = getElementById( "streaming-tab" ); XulTextbox streamingMaxRows = getElementById( "streaming-max-rows" ); XulTextbox streamingMaxTime = getElementById( "streaming-max-time" ); bindingFactory.setBindingType( Binding.Type.BI_DIRECTIONAL ); int modelStreamingMaxRows = model.getServiceMaxRows() > 0 ? model.getServiceMaxRows() : Integer.valueOf( kettleUtils.getKettleProperty( "KETTLE_STREAMING_ROW_LIMIT", Integer.toString( DataServiceConstants.KETTLE_STREAMING_ROW_LIMIT ) ) ); streamingMaxRows.setValue( Integer.toString( modelStreamingMaxRows ) ); model.setServiceMaxRows( modelStreamingMaxRows ); long modelStreamingMaxTime = model.getServiceMaxTime() > 0 ? model.getServiceMaxTime() : Long.parseLong( kettleUtils.getKettleProperty( "KETTLE_STREAMING_TIME_LIMIT", Integer.toString( DataServiceConstants.KETTLE_STREAMING_TIME_LIMIT ) ) ); streamingMaxTime.setValue( Long.toString( modelStreamingMaxTime ) ); model.setServiceMaxTime( modelStreamingMaxTime ); streamingTab.setVisible( model.isStreaming() ); bindingFactory.createBinding( model, "serviceMaxRows", streamingMaxRows, "value", BindingConvertor.integer2String() ); bindingFactory.createBinding( model, "serviceMaxTime", streamingMaxTime, "value", BindingConvertor.long2String() ); bindingFactory.createBinding( streamingRadioButton, "selected", streamingTab, "visible" ); bindingFactory.createBinding( normalModeRadio, "!selected", streamingTab, "visible" ); } StreamingController(); void initBindings( DataServiceModel model );  }
@Test public void testInitBindings() throws InvocationTargetException, XulException, KettleException { controller.initBindings( model ); verify( streamingTab ).setVisible( true ); verify( bindingFactory ).createBinding( model, "serviceMaxRows", maxRows, "value", BindingConvertor.integer2String() ); verify( bindingFactory ).createBinding( model, "serviceMaxTime", maxTime, "value", BindingConvertor.long2String() ); verify( bindingFactory ).createBinding( streamingRadioButton, "selected", streamingTab, "visible" ); verify( bindingFactory ).createBinding( regularRadioButton, "!selected", streamingTab, "visible" ); }
@Test public void testInitBindingsUsingKettleProperties() throws InvocationTargetException, XulException, KettleException { int maxRowsValue = 5000; long maxTimeValue = 1000; when( model.getServiceMaxRows() ).thenReturn( maxRowsValue ); when( model.getServiceMaxTime() ).thenReturn( maxTimeValue ); System.setProperty( "KETTLE_STREAMING_ROW_LIMIT", "5000" ); System.setProperty( "KETTLE_STREAMING_TIME_LIMIT", "10000" ); controller.initBindings( model ); verify( streamingTab ).setVisible( true ); verify( maxRows ).setValue( Integer.toString( maxRowsValue ) ); verify( maxTime ).setValue( Long.toString( maxTimeValue ) ); verify( bindingFactory ).createBinding( model, "serviceMaxRows", maxRows, "value", BindingConvertor.integer2String() ); verify( bindingFactory ).createBinding( model, "serviceMaxTime", maxTime, "value", BindingConvertor.long2String() ); verify( bindingFactory ).createBinding( streamingRadioButton, "selected", streamingTab, "visible" ); verify( bindingFactory ).createBinding( regularRadioButton, "!selected", streamingTab, "visible" ); }