@Test public void testGetValue() { ExpressionRuntime runtime = mock( ExpressionRuntime.class ); ReportElement element = mock( ReportElement.class ); Object result = lineType.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 = lineType.getValue( runtime, element ); assertThat( result, is( instanceOf( LineSparklinesWrapper.class ) ) ); LineSparklinesWrapper wrap = (LineSparklinesWrapper) result; assertThat( wrap.getBackend(), is( instanceOf( LineGraphDrawable.class ) ) ); LineGraphDrawable dr = (LineGraphDrawable) 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 LineGraphDrawable drawable = new LineGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new LineSparklinesWrapper( drawable ); }
LineSparklineType 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 LineGraphDrawable drawable = new LineGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new LineSparklinesWrapper( drawable ); } }
LineSparklineType 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 LineGraphDrawable drawable = new LineGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new LineSparklinesWrapper( drawable ); } LineSparklineType(); }
LineSparklineType 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 LineGraphDrawable drawable = new LineGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new LineSparklinesWrapper( drawable ); } LineSparklineType(); Object getValue( final ExpressionRuntime runtime, final ReportElement element ); Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ); }
LineSparklineType 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 LineGraphDrawable drawable = new LineGraphDrawable(); drawable.setData( numbers ); drawable.setSpacing( spacing ); return new LineSparklinesWrapper( drawable ); } LineSparklineType(); Object getValue( final ExpressionRuntime runtime, final ReportElement element ); Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ); static final LineSparklineType INSTANCE; }