@Test(expected=SdiException.class) public void testConvertFail() throws Throwable { myLog.debug( "testing 'ja' fail" ); Boolean received = myClassUnderTest.convert( "ja" ); Assert.assertTrue( received ); myLog.debug( "testing 'nein' fail" ); received = myClassUnderTest.convert( "nein" ); 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; }