### Question:
HashKeyIndex implements KeyIndex, Serializable { public int internId(long key) { int idx = tryGetIndex(key); if (idx < 0) { idx = keyList.size(); keyList.add(key); indexMap.put(key, idx); } return idx; } HashKeyIndex(); static HashKeyIndex create(); static HashKeyIndex create(LongList keys); static FrozenHashKeyIndex createFrozen(LongList keys); @Override int getIndex(long id); @Override boolean containsKey(long id); @Override long getKey(int idx); @Override LongList getKeyList(); @Override int tryGetIndex(long id); @Override int size(); @Override int getLowerBound(); @Override int getUpperBound(); int internId(long key); FrozenHashKeyIndex frozenCopy();  }### Answer:
@Test public void testInternId() { HashKeyIndex idx = new HashKeyIndex(); assertThat(idx.size(), equalTo(0)); assertThat(idx.tryGetIndex(42), lessThan(0)); assertThat(idx.internId(42), equalTo(0)); assertThat(idx.getKey(0), equalTo(42L)); assertThat(idx.tryGetIndex(42), equalTo(0)); }
@Test public void testReinternId() { HashKeyIndex idx = new HashKeyIndex(); assertThat(idx.internId(42), equalTo(0)); assertThat(idx.internId(39), equalTo(1)); assertThat(idx.internId(42), equalTo(0)); }