@Test public void testCreateElement() { Element elem = elemFactory.createElement(); assertThat( elem, is( notNullValue() ) ); assertThat( elem.getName(), is( equalTo( StringUtils.EMPTY ) ) ); assertThat( elem.getElementType(), is( instanceOf( LineSparklineType.class ) ) ); assertThat( elem.getAttribute( NAMESPACE, AttributeNames.Core.VALUE ), is( nullValue() ) ); assertThat( elem.getAttribute( NAMESPACE, AttributeNames.Core.FIELD ), is( nullValue() ) ); assertThat( elem.getAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING ), is( nullValue() ) ); assertThat( elem.getAttributeExpression( NAMESPACE, AttributeNames.Core.VALUE ), is( nullValue() ) ); elemFactory.setName( "elem_name" ); elemFactory.setContent( "elem_content" ); elemFactory.setFieldname( "field_name" ); elemFactory.setFormula( "test_formula" ); elemFactory.setSpacing( 20 ); elem = elemFactory.createElement(); assertThat( elem, is( notNullValue() ) ); assertThat( elem.getName(), is( equalTo( elemFactory.getName() ) ) ); assertThat( elem.getElementType(), is( instanceOf( LineSparklineType.class ) ) ); assertThat( elem.getAttribute( NAMESPACE, AttributeNames.Core.VALUE ), is( equalTo( elemFactory.getContent() ) ) ); assertThat( (String) elem.getAttribute( NAMESPACE, AttributeNames.Core.FIELD ), is( equalTo( elemFactory .getFieldname() ) ) ); assertThat( (Integer) elem.getAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING ), is( equalTo( elemFactory.getSpacing() ) ) ); Object expressionObj = elem.getAttributeExpression( NAMESPACE, AttributeNames.Core.VALUE ); assertThat( expressionObj, is( notNullValue() ) ); assertThat( expressionObj, is( instanceOf( FormulaExpression.class ) ) ); assertThat( ( (FormulaExpression) expressionObj ).getFormula(), is( equalTo( elemFactory.getFormula() ) ) ); }
public Element createElement() { final Element element = new Element(); applyElementName( element ); applyStyle( element.getStyle() ); element.setElementType( new LineSparklineType() ); if ( getContent() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getContent() ); } if ( getFieldname() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, getFieldname() ); } if ( getFormula() != null ) { final FormulaExpression formulaExpression = new FormulaExpression(); formulaExpression.setFormula( getFormula() ); element.setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, formulaExpression ); } if ( spacing != null ) { element.setAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, spacing ); } return element; }
LineSparklineElementFactory extends AbstractContentElementFactory { public Element createElement() { final Element element = new Element(); applyElementName( element ); applyStyle( element.getStyle() ); element.setElementType( new LineSparklineType() ); if ( getContent() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getContent() ); } if ( getFieldname() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, getFieldname() ); } if ( getFormula() != null ) { final FormulaExpression formulaExpression = new FormulaExpression(); formulaExpression.setFormula( getFormula() ); element.setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, formulaExpression ); } if ( spacing != null ) { element.setAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, spacing ); } return element; } }
LineSparklineElementFactory extends AbstractContentElementFactory { public Element createElement() { final Element element = new Element(); applyElementName( element ); applyStyle( element.getStyle() ); element.setElementType( new LineSparklineType() ); if ( getContent() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getContent() ); } if ( getFieldname() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, getFieldname() ); } if ( getFormula() != null ) { final FormulaExpression formulaExpression = new FormulaExpression(); formulaExpression.setFormula( getFormula() ); element.setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, formulaExpression ); } if ( spacing != null ) { element.setAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, spacing ); } return element; } LineSparklineElementFactory(); }
LineSparklineElementFactory extends AbstractContentElementFactory { public Element createElement() { final Element element = new Element(); applyElementName( element ); applyStyle( element.getStyle() ); element.setElementType( new LineSparklineType() ); if ( getContent() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getContent() ); } if ( getFieldname() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, getFieldname() ); } if ( getFormula() != null ) { final FormulaExpression formulaExpression = new FormulaExpression(); formulaExpression.setFormula( getFormula() ); element.setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, formulaExpression ); } if ( spacing != null ) { element.setAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, spacing ); } return element; } LineSparklineElementFactory(); Object getContent(); void setContent( final Object content ); Object getNullValue(); void setNullValue( final Object nullValue ); String getFormula(); void setFormula( final String formula ); Integer getSpacing(); void setSpacing( final Integer spacing ); String getFieldname(); void setFieldname( final String fieldname ); Element createElement(); }
LineSparklineElementFactory extends AbstractContentElementFactory { public Element createElement() { final Element element = new Element(); applyElementName( element ); applyStyle( element.getStyle() ); element.setElementType( new LineSparklineType() ); if ( getContent() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, getContent() ); } if ( getFieldname() != null ) { element.setAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.FIELD, getFieldname() ); } if ( getFormula() != null ) { final FormulaExpression formulaExpression = new FormulaExpression(); formulaExpression.setFormula( getFormula() ); element.setAttributeExpression( AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, formulaExpression ); } if ( spacing != null ) { element.setAttribute( SparklineAttributeNames.NAMESPACE, SparklineAttributeNames.SPACING, spacing ); } return element; } LineSparklineElementFactory(); Object getContent(); void setContent( final Object content ); Object getNullValue(); void setNullValue( final Object nullValue ); String getFormula(); void setFormula( final String formula ); Integer getSpacing(); void setSpacing( final Integer spacing ); String getFieldname(); void setFieldname( final String fieldname ); Element createElement();  }