CachingTableTypeRepository implements TableTypeRepository { @Override public TableType get(final TableTypeReference tableRef) { final TableType tableType = cache.getIfPresent(tableRef); if (tableType != null) { return tableType; } final TableType resolved = doGet(tableRef); cache.put(tableRef, resolved); return resolved; } CachingTableTypeRepository(); @Override TableType get(final TableTypeReference tableRef);  }
@Test public void get_should_returnATableType() { final TableType table = repository.get(ClassBasedTableTypeReference.of(Table.class)); assertThat(table.getName(), is("MY_TABLE")); }
@Test public void getATableTwice_should_returnSameInstance() { final TableType first = repository.get(ClassBasedTableTypeReference.of(Table.class)); final TableType second = repository.get(ClassBasedTableTypeReference.of(Table.class)); assertThat(first, is(sameInstance(second))); }
@Test(expected = DaleqBuildException.class) public void noResolverForReference_should_throw() { repository.get(new NamedTableTypeReference("foo")); }