@Test public void testGetValue() { ExpressionRuntime runtime = mock( ExpressionRuntime.class ); ReportElement element = mock( ReportElement.class ); Object result = barType.getValue( runtime, element ); assertThat( result, is( nullValue() ) ); Number[] data = new Number[] { 1.0 }; doReturn( data ).when( element ).getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE ); doReturn( 5 ).when( element ).getAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING ); result = barType.getValue( runtime, element ); assertThat( result, is( instanceOf( BarSparklinesWrapper.class ) ) ); BarSparklinesWrapper wrap = (BarSparklinesWrapper) result; assertThat( wrap.getBackend(), is( instanceOf( BarGraphDrawable.class ) ) ); BarGraphDrawable dr = (BarGraphDrawable) wrap.getBackend(); assertThat( dr.getData(), is( equalTo( data ) ) ); assertThat( dr.getSpacing(), is( equalTo( 5 ) ) ); }
public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryFieldOrValue( runtime, element ); final Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); }
BarSparklineType extends ContentType { public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryFieldOrValue( runtime, element ); final Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); } }
BarSparklineType extends ContentType { public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryFieldOrValue( runtime, element ); final Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); } BarSparklineType(); }
BarSparklineType extends ContentType { public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryFieldOrValue( runtime, element ); final Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); } BarSparklineType(); Object getValue( final ExpressionRuntime runtime, final ReportElement element ); Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ); void configureDesignTimeDefaults( final ReportElement element, final Locale locale ); }
BarSparklineType extends ContentType { public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object value = ElementTypeUtils.queryFieldOrValue( runtime, element ); final Number[] numbers = ElementTypeUtils.getData( value ); if ( numbers == null ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final int spacing = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, 2 ); final BarGraphDrawable drawable = new BarGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new BarSparklinesWrapper( drawable ); } BarSparklineType(); Object getValue( final ExpressionRuntime runtime, final ReportElement element ); Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ); void configureDesignTimeDefaults( final ReportElement element, final Locale locale ); static final BarSparklineType INSTANCE; }