MarketDepthBook implements IMarketDepthBook { @Override public void deleteLevel( int index ) { if( levels.size() > index ) { levels.remove(index); } } protected  MarketDepthBook(); static IMarketDepthBook newInstance(); static void setTestInstance( IMarketDepthBook book ); @Override Side getSide(); @Override void setSide(Side side); @Override void clearLevels(); @Override MarketDepthLevel[] getLevels(); @Override int getLevelCount(); @Override MarketDepthLevel getLevelAt(int index); @Override void addLevel(MarketDepthLevel level); @Override void insertLevel(int index, MarketDepthLevel level ); @Override void updateLevel(int index, MarketDepthLevel level ); @Override void deleteLevel( int index ); @Override void setLevels(MarketDepthLevel[] levelArray); @Override BigDecimal getTotalSize(); @Override BigDecimal getCumulativeSize(int level); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override void sort();  }
@Test public void testDeleteLevel() { MarketDepthBook book = new MarketDepthBook(); book.setSide(MarketDepthBook.Side.BID); MarketDepthLevel level1 = new MarketDepthLevel(MarketDepthBook.Side.BID, BigDecimal.ZERO, BigDecimal.ZERO); MarketDepthLevel level2 = new MarketDepthLevel(MarketDepthBook.Side.BID, BigDecimal.ONE, BigDecimal.ZERO); MarketDepthLevel level3 = new MarketDepthLevel(MarketDepthBook.Side.BID, BigDecimal.ZERO, BigDecimal.ONE); book.addLevel(level1); book.addLevel(level2); book.deleteLevel(2); assertEquals( 2, book.getLevelCount() ); assertEquals( level1, book.getLevelAt(0)); assertEquals( level2, book.getLevelAt(1)); book.deleteLevel(0); assertEquals(1, book.getLevelCount()); assertEquals( level2, book.getLevelAt(0)); }