@Test public void testConvertSuccess() throws Throwable { String[] trueValues = new String[] { "true ", " on", "yes", "1" }; for ( String value : trueValues ) { myLog.debug( "testing 'true' success for built in value " + value ); Boolean received = myClassUnderTest.convert( value ); Assert.assertTrue( received ); received = myClassUnderTest.convert( value.toUpperCase() ); Assert.assertTrue( received ); } String[] falseValues = new String[] { "false", "off", " no", "0 " }; for ( String value : falseValues ) { myLog.debug( "testing 'false' success for built in value " + value ); Boolean received = myClassUnderTest.convert( value ); Assert.assertFalse( received ); received = myClassUnderTest.convert( value.toUpperCase() ); Assert.assertFalse( received ); } }
@Override public Boolean convert( String aValue ) throws SdiException { if ( !StringUtils.hasText( aValue ) ) { myLog.debug( "Given value is null" ); return null; } String value = aValue.trim().toLowerCase(); if ( trueValues.contains( value ) ) { return Boolean.TRUE; } if ( falseValues.contains( value ) ) { return Boolean.FALSE; } try { return myConversionService.convert( value, Boolean.class ); } catch ( Throwable t ) { throw new SdiException( "Problems converting boolean value " + aValue, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } }
ConverterBoolean implements FieldConverter<Boolean> { @Override public Boolean convert( String aValue ) throws SdiException { if ( !StringUtils.hasText( aValue ) ) { myLog.debug( "Given value is null" ); return null; } String value = aValue.trim().toLowerCase(); if ( trueValues.contains( value ) ) { return Boolean.TRUE; } if ( falseValues.contains( value ) ) { return Boolean.FALSE; } try { return myConversionService.convert( value, Boolean.class ); } catch ( Throwable t ) { throw new SdiException( "Problems converting boolean value " + aValue, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } } }
ConverterBoolean implements FieldConverter<Boolean> { @Override public Boolean convert( String aValue ) throws SdiException { if ( !StringUtils.hasText( aValue ) ) { myLog.debug( "Given value is null" ); return null; } String value = aValue.trim().toLowerCase(); if ( trueValues.contains( value ) ) { return Boolean.TRUE; } if ( falseValues.contains( value ) ) { return Boolean.FALSE; } try { return myConversionService.convert( value, Boolean.class ); } catch ( Throwable t ) { throw new SdiException( "Problems converting boolean value " + aValue, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } }  }
ConverterBoolean implements FieldConverter<Boolean> { @Override public Boolean convert( String aValue ) throws SdiException { if ( !StringUtils.hasText( aValue ) ) { myLog.debug( "Given value is null" ); return null; } String value = aValue.trim().toLowerCase(); if ( trueValues.contains( value ) ) { return Boolean.TRUE; } if ( falseValues.contains( value ) ) { return Boolean.FALSE; } try { return myConversionService.convert( value, Boolean.class ); } catch ( Throwable t ) { throw new SdiException( "Problems converting boolean value " + aValue, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } }  @Override FieldConverter<Boolean> init( Environment aEnv, String aFieldname ); @Override Boolean convert( String aValue ); }
ConverterBoolean implements FieldConverter<Boolean> { @Override public Boolean convert( String aValue ) throws SdiException { if ( !StringUtils.hasText( aValue ) ) { myLog.debug( "Given value is null" ); return null; } String value = aValue.trim().toLowerCase(); if ( trueValues.contains( value ) ) { return Boolean.TRUE; } if ( falseValues.contains( value ) ) { return Boolean.FALSE; } try { return myConversionService.convert( value, Boolean.class ); } catch ( Throwable t ) { throw new SdiException( "Problems converting boolean value " + aValue, t, SdiException.EXIT_CODE_CONFIG_ERROR ); } }  @Override FieldConverter<Boolean> init( Environment aEnv, String aFieldname ); @Override Boolean convert( String aValue ); static final String CONVERTER_NAME; static final String KEY_TRUE_VALUES; static final String KEY_FALSE_VALUES; }