### Question:
LongEntityIndex implements EntityIndex { @Nonnull @Override public List<Entity> getEntities(@Nonnull Object value) { if (!(value instanceof Long)) { return Collections.emptyList(); } long key = (Long) value; return getEntities(key); } LongEntityIndex(KeyedObjectMap<IdBox<ImmutableList<Entity>>> lists); @Nonnull @Override List<Entity> getEntities(@Nonnull Object value); @Nonnull List<Entity> getEntities(long key); @Override Set<?> getValues();  }### Answer:
@Test public void testEmpty() { LongEntityIndexBuilder bld = new LongEntityIndexBuilder("user"); EntityIndex index = bld.build(); assertThat(index, notNullValue()); assertThat(index.getEntities(20L), hasSize(0)); }
@Test public void testAddEntity() { LongEntityIndexBuilder bld = new LongEntityIndexBuilder("user"); Entity rating = factory.rating(10, 100, 3.5); bld.add(rating); EntityIndex index = bld.build(); assertThat(index, notNullValue()); assertThat(index.getEntities(10L), contains(rating)); assertThat(index.getEntities(11L), hasSize(0)); }
@Test public void testNonLongValueEntity() { LongEntityIndexBuilder bld = new LongEntityIndexBuilder("user"); Entity rating = factory.rating(10, 100, 3.5); bld.add(rating); EntityIndex index = bld.build(); assertThat(index, notNullValue()); assertThat(index.getEntities("10"), hasSize(0)); }
@Test public void testAddEntities() { LongEntityIndexBuilder bld = new LongEntityIndexBuilder("user"); Entity r1 = factory.rating(10, 100, 3.5); Entity r2 = factory.rating(10, 50, 4.5); Entity r3 = factory.rating(15, 100, 2.5); bld.add(r1); bld.add(r3); bld.add(r2); EntityIndex index = bld.build(); assertThat(index, notNullValue()); assertThat(index.getEntities(10L), containsInAnyOrder(r1, r2)); assertThat(index.getEntities(11L), hasSize(0)); assertThat(index.getEntities(15L), contains(r3)); }