InMemoryMetaStore implements MetaStore { @Override public void registerProvider(TableProvider provider) { if (providers.containsKey(provider.getTableType())) { throw new IllegalArgumentException( "Provider is already registered for table type: " + provider.getTableType()); } initTablesFromProvider(provider); this.providers.put(provider.getTableType(), provider); }  @Override String getTableType(); @Override void createTable(Table table); @Override void dropTable(String tableName); @Override Map<String, Table> getTables(); @Override BeamSqlTable buildBeamSqlTable(Table table); @Override void registerProvider(TableProvider provider);  }
@Test public void testRegisterProvider() throws Exception { store.registerProvider(new MockTableProvider("mock", "hello", "world")); assertNotNull(store.getProviders()); assertEquals(2, store.getProviders().size()); assertEquals("text", store.getProviders().get("text").getTableType()); assertEquals("mock", store.getProviders().get("mock").getTableType()); assertEquals(2, store.getTables().size()); }
@Test(expected = IllegalArgumentException.class) public void testRegisterProvider_duplicatedTableType() throws Exception { store.registerProvider(new MockTableProvider("mock")); store.registerProvider(new MockTableProvider("mock")); }
@Test(expected = IllegalStateException.class) public void testRegisterProvider_duplicatedTableName() throws Exception { store.registerProvider(new MockTableProvider("mock", "hello", "world")); store.registerProvider(new MockTableProvider("mock1", "hello", "world")); }