mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Add test
This commit is contained in:
parent
565d9d0d9a
commit
75543b3ecf
2 changed files with 43 additions and 3 deletions
|
|
@ -74,10 +74,15 @@ public class NotebookTest implements JobListenerFactory{
|
|||
new File(tmpDir, "conf").mkdirs();
|
||||
notebookDir = new File(tmpDir + "/notebook");
|
||||
notebookDir.mkdirs();
|
||||
FileUtils.copyDirectory(new File("src/test/resources/interpreter"), new File(tmpDir, "interpreter"));
|
||||
|
||||
System.setProperty(ConfVars.ZEPPELIN_CONF_DIR.getVarName(), tmpDir.toString() + "/conf");
|
||||
System.setProperty(ConfVars.ZEPPELIN_HOME.getVarName(), tmpDir.getAbsolutePath());
|
||||
System.setProperty(ConfVars.ZEPPELIN_NOTEBOOK_DIR.getVarName(), notebookDir.getAbsolutePath());
|
||||
System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(), "org.apache.zeppelin.interpreter.mock.MockInterpreter1,org.apache.zeppelin.interpreter.mock.MockInterpreter2");
|
||||
System.setProperty(ConfVars.ZEPPELIN_INTERPRETERS.getVarName(),
|
||||
"org.apache.zeppelin.interpreter.mock.MockInterpreter1," +
|
||||
"org.apache.zeppelin.interpreter.mock.MockInterpreter2," +
|
||||
"org.apache.zeppelin.interpreter.mock.MockInterpreter11");
|
||||
|
||||
conf = ZeppelinConfiguration.create();
|
||||
|
||||
|
|
@ -95,8 +100,7 @@ public class NotebookTest implements JobListenerFactory{
|
|||
credentials = new Credentials(conf.credentialsPersist(), conf.getCredentialsPath());
|
||||
|
||||
notebook = new Notebook(conf, notebookRepo, schedulerFactory, factory, this, search,
|
||||
notebookAuthorization, credentials);
|
||||
|
||||
notebookAuthorization, credentials);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
@ -886,6 +890,30 @@ public class NotebookTest implements JobListenerFactory{
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEditorSetting() throws IOException, RepositoryException, SchedulerException {
|
||||
List<String> intpIds = new ArrayList<>();
|
||||
for(InterpreterSetting intpSetting: factory.get()) {
|
||||
if (intpSetting.getName().startsWith("mock1")) {
|
||||
intpIds.add(intpSetting.getId());
|
||||
}
|
||||
}
|
||||
Note note = notebook.createNote(intpIds, null);
|
||||
|
||||
// get editor setting from interpreter-setting.json
|
||||
Map<String, Object> editor = note.getEditorSetting("mock11");
|
||||
assertEquals("java", editor.get("language"));
|
||||
|
||||
// when interpreter is not loaded via interpreter-setting.json
|
||||
// or editor setting doesn't exit
|
||||
editor = note.getEditorSetting("mock1");
|
||||
assertEquals(null, editor.get("language"));
|
||||
|
||||
// when interpreter is not bound to note
|
||||
editor = note.getEditorSetting("mock2");
|
||||
assertEquals("text", editor.get("language"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParagraphJobListener getParagraphJobListener(Note note) {
|
||||
return new ParagraphJobListener(){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
[
|
||||
{
|
||||
"group": "mock11",
|
||||
"name": "mock11",
|
||||
"className": "org.apache.zeppelin.interpreter.mock.MockInterpreter11",
|
||||
"properties": {
|
||||
},
|
||||
"editor": {
|
||||
"language": "java"
|
||||
}
|
||||
}
|
||||
]
|
||||
Loading…
Reference in a new issue