public void removeElement( int index ) { removeElement( getElement( index ) ); }
public void testGetElement() { Band band = new Band(); try { band.getElement( null ); fail( "should throw exception" ); } catch ( NullPointerException e ) { // expected } Element elem = mock( Element.class ); doReturn( "test_name" ).when( elem ).getName(); band.addElement( elem ); assertEquals( 1, band.getElementCount() ); assertEquals( elem, band.getElement( "test_name" ) ); }
public void testAddElements() { Band band = new Band(); try { band.addElements( null ); fail( "should throw exception" ); } catch ( NullPointerException e ) { // expected } Element elem = mock( Element.class ); List<Element> elements = new ArrayList<Element>(); elements.add( elem ); band.addElements( elements ); assertEquals( 1, band.getElementCount() ); assertEquals( elem, band.getElement( 0 ) ); }
public void testElementClone() throws CloneNotSupportedException { final Band band = new Band(); final Element e = new Element(); band.addElement( e ); assertNotNull( e.getParent() ); assertNotNull( e.getDataSource() ); assertNotNull( e.getStyle() ); assertNotNull( e.getName() ); assertTrue( e.isVisible() ); final Element clone = (Element) e.clone(); assertNull( clone.getParent() ); assertNotNull( clone.getDataSource() ); assertNotNull( clone.getStyle() ); assertNotNull( clone.getName() ); assertTrue( clone.isVisible() ); final Band clonedBand = (Band) band.clone(); assertNull( clonedBand.getParent() ); assertNotNull( clonedBand.getDataSource() ); assertNotNull( clonedBand.getStyle() ); assertNotNull( clonedBand.getName() ); assertTrue( clonedBand.isVisible() ); final Element clientElement = clonedBand.getElement( 0 ); assertNotNull( clientElement.getParent() ); assertNotNull( clientElement.getDataSource() ); assertNotNull( clientElement.getStyle() ); assertNotNull( clientElement.getName() ); assertTrue( clientElement.isVisible() ); assertEquals( clonedBand, clientElement.getParent() ); }
public void testSetElementAt() { Band band = new Band(); band.addElement( mock( Element.class ) ); Element elem = mock( Element.class ); try { band.setElementAt( -1, elem ); fail( "should throw exception" ); } catch ( IllegalArgumentException e ) { // expected } try { band.setElementAt( 10, elem ); fail( "should throw exception" ); } catch ( IllegalArgumentException e ) { // expected } try { band.setElementAt( 0, null ); fail( "should throw exception" ); } catch ( NullPointerException e ) { // expected } band.setElementAt( 0, elem ); assertEquals( 1, band.getElementCount() ); assertEquals( elem, band.getElement( 0 ) ); assertEquals( band, elem.getParentSection() ); }
final Element maybeInlineContainer = (Element) band.getElement( band.getElementCount() - 1 ); if ( maybeInlineContainer == inlineContainer ) {