### Question:
VolatileLookUpTable implements LookUpTable<T> { @Override public List<T> get(LookUpKey key) { if (key == null) { throw new IllegalArgumentException("key must not be null"); } List<T> list = entity.get(key.getDirectView()); if (list == null) { return Collections.emptyList(); } return list; } VolatileLookUpTable(Map<LookUpKey.View, List<T>> entity); @Override List<T> get(LookUpKey key);  }### Answer:
@Test public void empty() throws Exception { VolatileLookUpTable.Builder<IntOption> builder = new VolatileLookUpTable.Builder<>(); LookUpTable<IntOption> table = builder.build(); assertThat(sort(table.get(key(100))), is(values())); }
@Test public void simple() throws Exception { VolatileLookUpTable.Builder<IntOption> builder = new VolatileLookUpTable.Builder<>(); builder.add(key(100), new IntOption(100)); LookUpTable<IntOption> table = builder.build(); assertThat(sort(table.get(key(100))), is(values(100))); assertThat(sort(table.get(key(101))), is(values())); }
@Test public void duplicate() throws Exception { VolatileLookUpTable.Builder<IntOption> builder = new VolatileLookUpTable.Builder<>(); builder.add(key(100), new IntOption(100)); builder.add(key(100), new IntOption(101)); builder.add(key(100), new IntOption(102)); LookUpTable<IntOption> table = builder.build(); assertThat(sort(table.get(key(100))), is(values(100, 101, 102))); assertThat(sort(table.get(key(101))), is(values())); }
@Test public void reuseKeys() throws Exception { VolatileLookUpTable.Builder<IntOption> builder = new VolatileLookUpTable.Builder<>(); LookUpKey key = key(); key.add(new IntOption(100)); builder.add(key, new IntOption(100)); key.reset(); key.add(new IntOption(101)); builder.add(key, new IntOption(101)); key.reset(); key.add(new IntOption(102)); builder.add(key, new IntOption(102)); key.reset(); LookUpTable<IntOption> table = builder.build(); assertThat(sort(table.get(key(100))), is(values(100))); assertThat(sort(table.get(key(101))), is(values(101))); assertThat(sort(table.get(key(102))), is(values(102))); }