JdbcIndexEngine extends JdbcService implements IndexEngine { @SuppressWarnings("unchecked") @Override public <T> JdbcIndex<T> getIndex(Class<T> model) throws IndexNotFoundException { if (!indexExists(model)) { throw new IndexNotFoundException("Index for model " + model.getSimpleName() + " does not exist"); } String name = translator.translate(model); if (registry.containsKey(name)) { JdbcIndex cached = registry.get(name); if (!cached.hasTypeInformation()) { cached.setModelClass(model); } return cached; } JdbcIndex<T> index = load(model); registry.put(name, index); return index; } JdbcIndexEngine(DataSource dataSource, SchemaMapper schemaMapper); @Override Index<T> createIndex(Class<T> model); @Override boolean indexExists(Class<?> model); @Override boolean indexExists(String name); @SuppressWarnings("unchecked") @Override JdbcIndex<T> getIndex(Class<T> model); @Override JdbcIndex<?> getIndex(String name); @Override void setClassLoader(ClassLoader classLoader); @Override void commit(IndexCommit commit); @Override List<Index<?>> getAll(); @Override void removeIndex(Index<?> index); void install();  }
@Test(expected = IndexNotFoundException.class) public void getIndex_onNonExistingClass_throwsException() throws Exception { indexEngine.getIndex(TestModel.class); }
@Test(expected = IndexNotFoundException.class) public void getIndex_onNonExistingNames_throwsException() throws Exception { indexEngine.getIndex("org.openengsb.core.edbi.models.TestModel"); }