### Question:
ArrayTree { public K remove( K key ) { int pos = getPosition( key ); if ( pos != -1 ) { if ( pos != size - 1 ) { System.arraycopy( array, pos + 1, array, pos, size - pos - 1 ); reduceArray(); } size--; return key; } else { return null; } } ArrayTree( Comparator<K> comparator );  ArrayTree( Comparator<K> comparator, K[] array ); Comparator<K> getComparator(); K insert( K key ); K remove( K key ); boolean isEmpty(); int size(); List<K> getKeys(); void printTree(); K get( int position ); K getFirst(); K getLast(); K findGreater( K key ); K findGreaterOrEqual( K key ); K findLess( K key ); K findLessOrEqual( K key ); K find( K key ); int getPosition( K key ); int getAfterPosition( K key ); int getBeforePosition( K key ); boolean contains( K key ); String toString();  }### Answer:
@Test public void testRemove() { ArrayTree<Integer> tree = createTree(); tree.insert( 3 ); tree.insert( 2 ); tree.insert( 1 ); LOG.debug( getLinkedText( tree ) ); tree.remove( 2 ); LOG.debug( getLinkedText( tree ) ); assertEquals( "1, 3", tree.toString() ); tree.remove( 1 ); assertEquals( "3", tree.toString() ); assertEquals( THREE, tree.getFirst() ); assertNull( tree.remove( 777 ) ); assertEquals( THREE, tree.remove( 3 ) ); assertTrue( tree.isEmpty() ); tree.insert( 37 ); tree.insert( 39 ); tree.insert( 27 ); tree.insert( 38 ); tree.insert( 21 ); tree.insert( 26 ); tree.insert( 43 ); assertEquals( "21, 26, 27, 37, 38, 39, 43", tree.toString() ); tree.remove( 26 ); assertEquals( "21, 27, 37, 38, 39, 43", tree.toString() ); tree.remove( 43 ); assertEquals( "21, 27, 37, 38, 39", tree.toString() ); tree.remove( 39 ); assertEquals( "21, 27, 37, 38", tree.toString() ); tree.remove( 38 ); assertEquals( "21, 27, 37", tree.toString() ); if ( LOG.isDebugEnabled() ) { tree.printTree(); } }