@Test public void testCreateListParameter() { ListParameter entry = mock( ListParameter.class ); ParameterContext parameterContext = mock( ParameterContext.class ); ParameterUpdateContext updateContext = mock( ParameterUpdateContext.class ); ResourceBundleFactory resourceBundleFactory = mock( ResourceBundleFactory.class ); Locale locale = new Locale( "test_test" ); doReturn( resourceBundleFactory ).when( parameterContext ).getResourceBundleFactory(); doReturn( locale ).when( resourceBundleFactory ).getLocale(); doReturn( TimeZone.getDefault() ).when( resourceBundleFactory ).getTimeZone(); ParameterComponent comp = factory.create( entry, parameterContext, updateContext ); doReturn( null ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); assertThat( comp, is( instanceOf( TextFieldParameterComponent.class ) ) ); doReturn( "textbox" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( TextFieldParameterComponent.class ) ) ); doReturn( "dropdown" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( DropDownParameterComponent.class ) ) ); doReturn( "list" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( ListParameterComponent.class ) ) ); doReturn( "checkbox" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( CheckBoxParameterComponent.class ) ) ); doReturn( "radio" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( RadioButtonParameterComponent.class ) ) ); doReturn( "togglebutton" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( ButtonParameterComponent.class ) ) ); doReturn( "tt" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( TextFieldParameterComponent.class ) ) ); }
public ParameterComponent createListParameter( final ListParameter listParameter, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = listParameter.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( type == null || "textbox".equals( type ) ) { return createTextComponent( listParameter, parameterContext, updateContext ); } if ( "dropdown".equals( type ) ) { return new DropDownParameterComponent( listParameter, updateContext, parameterContext ); } if ( "list".equals( type ) ) { return new ListParameterComponent( listParameter, updateContext, parameterContext ); } if ( "checkbox".equals( type ) ) { return new CheckBoxParameterComponent( listParameter, updateContext, parameterContext ); } if ( "radio".equals( type ) ) { return new RadioButtonParameterComponent( listParameter, updateContext, parameterContext ); } if ( "togglebutton".equals( type ) ) { return new ButtonParameterComponent( listParameter, updateContext, parameterContext ); } return createTextComponent( listParameter, parameterContext, updateContext ); }
DefaultParameterComponentFactory implements ParameterComponentFactory { public ParameterComponent createListParameter( final ListParameter listParameter, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = listParameter.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( type == null || "textbox".equals( type ) ) { return createTextComponent( listParameter, parameterContext, updateContext ); } if ( "dropdown".equals( type ) ) { return new DropDownParameterComponent( listParameter, updateContext, parameterContext ); } if ( "list".equals( type ) ) { return new ListParameterComponent( listParameter, updateContext, parameterContext ); } if ( "checkbox".equals( type ) ) { return new CheckBoxParameterComponent( listParameter, updateContext, parameterContext ); } if ( "radio".equals( type ) ) { return new RadioButtonParameterComponent( listParameter, updateContext, parameterContext ); } if ( "togglebutton".equals( type ) ) { return new ButtonParameterComponent( listParameter, updateContext, parameterContext ); } return createTextComponent( listParameter, parameterContext, updateContext ); } }
DefaultParameterComponentFactory implements ParameterComponentFactory { public ParameterComponent createListParameter( final ListParameter listParameter, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = listParameter.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( type == null || "textbox".equals( type ) ) { return createTextComponent( listParameter, parameterContext, updateContext ); } if ( "dropdown".equals( type ) ) { return new DropDownParameterComponent( listParameter, updateContext, parameterContext ); } if ( "list".equals( type ) ) { return new ListParameterComponent( listParameter, updateContext, parameterContext ); } if ( "checkbox".equals( type ) ) { return new CheckBoxParameterComponent( listParameter, updateContext, parameterContext ); } if ( "radio".equals( type ) ) { return new RadioButtonParameterComponent( listParameter, updateContext, parameterContext ); } if ( "togglebutton".equals( type ) ) { return new ButtonParameterComponent( listParameter, updateContext, parameterContext ); } return createTextComponent( listParameter, parameterContext, updateContext ); } DefaultParameterComponentFactory(); }
DefaultParameterComponentFactory implements ParameterComponentFactory { public ParameterComponent createListParameter( final ListParameter listParameter, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = listParameter.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( type == null || "textbox".equals( type ) ) { return createTextComponent( listParameter, parameterContext, updateContext ); } if ( "dropdown".equals( type ) ) { return new DropDownParameterComponent( listParameter, updateContext, parameterContext ); } if ( "list".equals( type ) ) { return new ListParameterComponent( listParameter, updateContext, parameterContext ); } if ( "checkbox".equals( type ) ) { return new CheckBoxParameterComponent( listParameter, updateContext, parameterContext ); } if ( "radio".equals( type ) ) { return new RadioButtonParameterComponent( listParameter, updateContext, parameterContext ); } if ( "togglebutton".equals( type ) ) { return new ButtonParameterComponent( listParameter, updateContext, parameterContext ); } return createTextComponent( listParameter, parameterContext, updateContext ); } DefaultParameterComponentFactory(); ParameterComponent create( final ParameterDefinitionEntry entry, final ParameterContext parameterContext,
      final ParameterUpdateContext updateContext ); ParameterComponent createListParameter( final ListParameter listParameter,
      final ParameterContext parameterContext, final ParameterUpdateContext updateContext ); static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter,
      final ParameterContext parameterContext ); }
DefaultParameterComponentFactory implements ParameterComponentFactory { public ParameterComponent createListParameter( final ListParameter listParameter, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = listParameter.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( type == null || "textbox".equals( type ) ) { return createTextComponent( listParameter, parameterContext, updateContext ); } if ( "dropdown".equals( type ) ) { return new DropDownParameterComponent( listParameter, updateContext, parameterContext ); } if ( "list".equals( type ) ) { return new ListParameterComponent( listParameter, updateContext, parameterContext ); } if ( "checkbox".equals( type ) ) { return new CheckBoxParameterComponent( listParameter, updateContext, parameterContext ); } if ( "radio".equals( type ) ) { return new RadioButtonParameterComponent( listParameter, updateContext, parameterContext ); } if ( "togglebutton".equals( type ) ) { return new ButtonParameterComponent( listParameter, updateContext, parameterContext ); } return createTextComponent( listParameter, parameterContext, updateContext ); } DefaultParameterComponentFactory(); ParameterComponent create( final ParameterDefinitionEntry entry, final ParameterContext parameterContext,
      final ParameterUpdateContext updateContext ); ParameterComponent createListParameter( final ListParameter listParameter,
      final ParameterContext parameterContext, final ParameterUpdateContext updateContext ); static KeyedComboBoxModel<Object, Object> createModel( final ListParameter parameter,
      final ParameterContext parameterContext );  }