### Question:
LongKeyIndexer implements Serializable { public LongKeyIndexer() { this(DEFAULT_CAPACITY); } LongKeyIndexer();  LongKeyIndexer(int capacity); int put(long key); int get(long key); int remove(long key); int getSize(); int getCapacity(); void clear(); long[] getKeys();  }### Answer:
@Test public void testLongKeyIndexer() { LongKeyIndexer indexer = new LongKeyIndexer(13); System.out.println("Test put method"); int index; index = indexer.put(1000l); if (index != 0) { Assert.fail("Put: expected 0, got "+index); } index = indexer.put(2000l); if (index != 1) { Assert.fail("Put: expected 1, got "+index); } index = indexer.put(3000l); if (index != 2) { Assert.fail("Put: expected 2, got "+index); } index = indexer.put(4000l); if (index != 3) { Assert.fail("Put: expected 3, got "+index); } index = indexer.put(123l); if (index != 4) { Assert.fail("Put: expected 4, got "+index); } index = indexer.put(456l); if (index != 5) { Assert.fail("Put: expected 5, got "+index); } index = indexer.put(1789l); if (index != 6) { Assert.fail("Put: expected 6, got "+index); } index = indexer.put(2000l); if (index != 1) { Assert.fail("Put: expected 1, got "+index); } System.out.println("Test remove method"); indexer.remove(4000l); index = indexer.get(4000l); if (index != -1) { Assert.fail("Expected to get -1 on remove of " + "non-existent index and instead got "+index); } index = indexer.put(9999l); if (index != 3) { Assert.fail("Remove: expected 3, got "+index); } System.out.println("Test grow"); for(int i=0;i<20;i++) { indexer.put(i); } index = indexer.get(1000l); if (index != 0) { Assert.fail("Grow: expected 0, got "+index); } index = indexer.get(2000l); if (index != 1) { Assert.fail("Grow: expected 1, got "+index); } index = indexer.get(3000l); if (index != 2) { Assert.fail("Grow: expected 2, got "+index); } index = indexer.get(4000l); if (index != -1) { Assert.fail("Grow: expected 3, got "+index); } index = indexer.get(123l); if (index != 4) { Assert.fail("Grow: expected 4, got "+index); } index = indexer.get(456l); if (index != 5) { Assert.fail("Grow: expected 5, got "+index); } index = indexer.get(1789l); if (index != 6) { Assert.fail("Grow: expected 6, got "+index); } index = indexer.get(0l); if (index != 7) { Assert.fail("Grow: expected 7, got "+index); } index = indexer.get(500l); if (index != -1) { Assert.fail("Grow: expected -1, got "+index); } System.out.println("Test capacity"); if (indexer.getCapacity() != 37) { Assert.fail("Capacity should be 37, but it is "+indexer.getCapacity()); } indexer.clear(); for(int i=0;i<100;i++) { indexer.put(i); } for(int i=0;i<100;i++) { if (indexer.get(i) != (long)i) { Assert.fail("Sequence: expected "+i+", and got"+indexer.get(i)); } } }