@Test public void testGetValue() { ExpressionRuntime runtime = mock( ExpressionRuntime.class ); ReportElement element = mock( ReportElement.class ); Object result = pieType.getValue( runtime, element ); assertThat( result, is( nullValue() ) ); doReturn( 1.0 ).when( element ).getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE ); doReturn( 1 ).when( element ).getAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.START_ANGLE ); doReturn( 2 ).when( element ).getAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.LOW_SLICE ); doReturn( 2.5 ).when( element ).getAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.MEDIUM_SLICE ); doReturn( 5.6 ).when( element ) .getAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.HIGH_SLICE ); doReturn( true ).when( element ).getAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.COUNTER_CLOCKWISE ); result = pieType.getValue( runtime, element ); assertThat( result, is( instanceOf( PieSparklinesWrapper.class ) ) ); PieSparklinesWrapper wrap = (PieSparklinesWrapper) result; assertThat( wrap.getBackend(), is( instanceOf( PieGraphDrawable.class ) ) ); PieGraphDrawable dr = (PieGraphDrawable) wrap.getBackend(); assertThat( dr.getHighSlice(), is( equalTo( (Number) 5.6 ) ) ); assertThat( dr.getLowSlice(), is( equalTo( (Number) 2 ) ) ); assertThat( dr.getMediumSlice(), is( equalTo( (Number) 2.5 ) ) ); assertThat( dr.getStartAngle(), is( equalTo( 1 ) ) ); assertThat( dr.isCounterClockWise(), is( equalTo( true ) ) ); }
public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object retval = ElementTypeUtils.queryFieldOrValue( runtime, element ); if ( retval instanceof Number == false ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final Number numbers = (Number) retval; final int startAngle = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.START_ANGLE, 0 ); final Number lowSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.LOW_SLICE, new Double( 0.30 ) ); final Number mediumSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.MEDIUM_SLICE, new Double( 0.70 ) ); final Number highSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.HIGH_SLICE, new Double( 1 ) ); final boolean clockwise = ElementTypeUtils.getBooleanAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.COUNTER_CLOCKWISE, false ); final PieGraphDrawable drawable = new PieGraphDrawable(); drawable.setValue( numbers ); drawable.setStartAngle( startAngle ); drawable.setLowSlice( lowSlice ); drawable.setMediumSlice( mediumSlice ); drawable.setHighSlice( highSlice ); drawable.setCounterClockWise( clockwise ); return new PieSparklinesWrapper( drawable ); }
PieSparklineType extends ContentType { public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object retval = ElementTypeUtils.queryFieldOrValue( runtime, element ); if ( retval instanceof Number == false ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final Number numbers = (Number) retval; final int startAngle = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.START_ANGLE, 0 ); final Number lowSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.LOW_SLICE, new Double( 0.30 ) ); final Number mediumSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.MEDIUM_SLICE, new Double( 0.70 ) ); final Number highSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.HIGH_SLICE, new Double( 1 ) ); final boolean clockwise = ElementTypeUtils.getBooleanAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.COUNTER_CLOCKWISE, false ); final PieGraphDrawable drawable = new PieGraphDrawable(); drawable.setValue( numbers ); drawable.setStartAngle( startAngle ); drawable.setLowSlice( lowSlice ); drawable.setMediumSlice( mediumSlice ); drawable.setHighSlice( highSlice ); drawable.setCounterClockWise( clockwise ); return new PieSparklinesWrapper( drawable ); } }
PieSparklineType extends ContentType { public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object retval = ElementTypeUtils.queryFieldOrValue( runtime, element ); if ( retval instanceof Number == false ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final Number numbers = (Number) retval; final int startAngle = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.START_ANGLE, 0 ); final Number lowSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.LOW_SLICE, new Double( 0.30 ) ); final Number mediumSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.MEDIUM_SLICE, new Double( 0.70 ) ); final Number highSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.HIGH_SLICE, new Double( 1 ) ); final boolean clockwise = ElementTypeUtils.getBooleanAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.COUNTER_CLOCKWISE, false ); final PieGraphDrawable drawable = new PieGraphDrawable(); drawable.setValue( numbers ); drawable.setStartAngle( startAngle ); drawable.setLowSlice( lowSlice ); drawable.setMediumSlice( mediumSlice ); drawable.setHighSlice( highSlice ); drawable.setCounterClockWise( clockwise ); return new PieSparklinesWrapper( drawable ); } PieSparklineType(); }
PieSparklineType extends ContentType { public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object retval = ElementTypeUtils.queryFieldOrValue( runtime, element ); if ( retval instanceof Number == false ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final Number numbers = (Number) retval; final int startAngle = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.START_ANGLE, 0 ); final Number lowSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.LOW_SLICE, new Double( 0.30 ) ); final Number mediumSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.MEDIUM_SLICE, new Double( 0.70 ) ); final Number highSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.HIGH_SLICE, new Double( 1 ) ); final boolean clockwise = ElementTypeUtils.getBooleanAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.COUNTER_CLOCKWISE, false ); final PieGraphDrawable drawable = new PieGraphDrawable(); drawable.setValue( numbers ); drawable.setStartAngle( startAngle ); drawable.setLowSlice( lowSlice ); drawable.setMediumSlice( mediumSlice ); drawable.setHighSlice( highSlice ); drawable.setCounterClockWise( clockwise ); return new PieSparklinesWrapper( drawable ); } PieSparklineType(); Object getValue( final ExpressionRuntime runtime, final ReportElement element ); Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ); }
PieSparklineType extends ContentType { public Object getValue( final ExpressionRuntime runtime, final ReportElement element ) { final Object retval = ElementTypeUtils.queryFieldOrValue( runtime, element ); if ( retval instanceof Number == false ) { final Object nullValue = element.getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE ); return filter( runtime, element, nullValue ); } final Number numbers = (Number) retval; final int startAngle = ElementTypeUtils.getIntAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.START_ANGLE, 0 ); final Number lowSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.LOW_SLICE, new Double( 0.30 ) ); final Number mediumSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.MEDIUM_SLICE, new Double( 0.70 ) ); final Number highSlice = ElementTypeUtils.getNumberAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.HIGH_SLICE, new Double( 1 ) ); final boolean clockwise = ElementTypeUtils.getBooleanAttribute( element, SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.COUNTER_CLOCKWISE, false ); final PieGraphDrawable drawable = new PieGraphDrawable(); drawable.setValue( numbers ); drawable.setStartAngle( startAngle ); drawable.setLowSlice( lowSlice ); drawable.setMediumSlice( mediumSlice ); drawable.setHighSlice( highSlice ); drawable.setCounterClockWise( clockwise ); return new PieSparklinesWrapper( drawable ); } PieSparklineType(); Object getValue( final ExpressionRuntime runtime, final ReportElement element ); Object getDesignValue( final ExpressionRuntime runtime, final ReportElement element ); static final PieSparklineType INSTANCE; }