JDBCInterpreter extends KerberosInterpreter { public String getDBPrefix(InterpreterContext context) { Map<String, String> localProperties = context.getLocalProperties(); if (localProperties.containsKey("db")) { return localProperties.get("db"); } for (Map.Entry<String, String> entry : localProperties.entrySet()) { if (entry.getKey().equals(entry.getValue())) { return entry.getKey(); } } return DEFAULT_KEY; } JDBCInterpreter(Properties property); @Override ZeppelinContext getZeppelinContext(); @Override void open(); @Override void close(); JDBCUserConfigurations getJDBCConfiguration(String user); Connection getConnection(String dbPrefix, InterpreterContext context); InterpreterResult executePrecode(InterpreterContext interpreterContext); @Override InterpreterResult internalInterpret(String cmd, InterpreterContext context); @Override void cancel(InterpreterContext context); String getDBPrefix(InterpreterContext context); @Override FormType getFormType(); @Override int getProgress(InterpreterContext context); @Override Scheduler getScheduler(); @Override List<InterpreterCompletion> completion(String buf, int cursor,
      InterpreterContext interpreterContext); int getMaxResult();  }
@Test public void testForParsePropertyKey() { JDBCInterpreter t = new JDBCInterpreter(new Properties()); Map<String, String> localProperties = new HashMap<>(); InterpreterContext interpreterContext = InterpreterContext.builder() .setLocalProperties(localProperties) .build(); assertEquals(JDBCInterpreter.DEFAULT_KEY, t.getDBPrefix(interpreterContext)); localProperties = new HashMap<>(); localProperties.put("db", "mysql"); interpreterContext = InterpreterContext.builder() .setLocalProperties(localProperties) .build(); assertEquals("mysql", t.getDBPrefix(interpreterContext)); localProperties = new HashMap<>(); localProperties.put("hive", "hive"); interpreterContext = InterpreterContext.builder() .setLocalProperties(localProperties) .build(); assertEquals("hive", t.getDBPrefix(interpreterContext)); }