@Test public void testCreateTextComponent() { PlainParameter entry = mock( PlainParameter.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(); doReturn( "field" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); ParameterComponent comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( TextFieldParameterComponent.class ) ) ); doReturn( "datepicker" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); doReturn( Date.class ).when( entry ).getValueType(); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( DatePickerParameterComponent.class ) ) ); doReturn( "multi-line" ).when( entry ).getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); comp = factory.create( entry, parameterContext, updateContext ); assertThat( comp, is( instanceOf( TextAreaParameterComponent.class ) ) ); }
private ParameterComponent createTextComponent( final ParameterDefinitionEntry entry, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = entry.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( "datepicker".equals( type ) && Date.class.isAssignableFrom( entry.getValueType() ) ) { return new DatePickerParameterComponent( entry, parameterContext, updateContext ); } if ( "multi-line".equals( type ) ) { return new TextAreaParameterComponent( entry, parameterContext, updateContext ); } else { return new TextFieldParameterComponent( entry, parameterContext, updateContext ); } }
DefaultParameterComponentFactory implements ParameterComponentFactory { private ParameterComponent createTextComponent( final ParameterDefinitionEntry entry, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = entry.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( "datepicker".equals( type ) && Date.class.isAssignableFrom( entry.getValueType() ) ) { return new DatePickerParameterComponent( entry, parameterContext, updateContext ); } if ( "multi-line".equals( type ) ) { return new TextAreaParameterComponent( entry, parameterContext, updateContext ); } else { return new TextFieldParameterComponent( entry, parameterContext, updateContext ); } } }
DefaultParameterComponentFactory implements ParameterComponentFactory { private ParameterComponent createTextComponent( final ParameterDefinitionEntry entry, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = entry.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( "datepicker".equals( type ) && Date.class.isAssignableFrom( entry.getValueType() ) ) { return new DatePickerParameterComponent( entry, parameterContext, updateContext ); } if ( "multi-line".equals( type ) ) { return new TextAreaParameterComponent( entry, parameterContext, updateContext ); } else { return new TextFieldParameterComponent( entry, parameterContext, updateContext ); } } DefaultParameterComponentFactory(); }
DefaultParameterComponentFactory implements ParameterComponentFactory { private ParameterComponent createTextComponent( final ParameterDefinitionEntry entry, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = entry.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( "datepicker".equals( type ) && Date.class.isAssignableFrom( entry.getValueType() ) ) { return new DatePickerParameterComponent( entry, parameterContext, updateContext ); } if ( "multi-line".equals( type ) ) { return new TextAreaParameterComponent( entry, parameterContext, updateContext ); } else { return new TextFieldParameterComponent( entry, 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 { private ParameterComponent createTextComponent( final ParameterDefinitionEntry entry, final ParameterContext parameterContext, final ParameterUpdateContext updateContext ) { final String type = entry.getParameterAttribute( ParameterAttributeNames.Core.NAMESPACE, ParameterAttributeNames.Core.TYPE, parameterContext ); if ( "datepicker".equals( type ) && Date.class.isAssignableFrom( entry.getValueType() ) ) { return new DatePickerParameterComponent( entry, parameterContext, updateContext ); } if ( "multi-line".equals( type ) ) { return new TextAreaParameterComponent( entry, parameterContext, updateContext ); } else { return new TextFieldParameterComponent( entry, 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 );  }