mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
minor change
This commit is contained in:
parent
c33d4ce3da
commit
71c7edfb56
10 changed files with 83 additions and 71 deletions
|
|
@ -1515,7 +1515,7 @@ public class NotebookServer extends WebSocketServlet
|
|||
if (paragraph == null) {
|
||||
throw new IllegalArgumentException("Unknown paragraph with id : " + paragraphId);
|
||||
}
|
||||
return paragraph.getInterpreter().getInterpreterGroup();
|
||||
return paragraph.getBindedInterpreter().getInterpreterGroup();
|
||||
}
|
||||
|
||||
private void pushAngularObjectToRemoteRegistry(String noteId, String paragraphId, String varName,
|
||||
|
|
|
|||
|
|
@ -161,12 +161,9 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
}
|
||||
|
||||
private void setPythonParagraph(int num, String text) {
|
||||
LOG.info("setText**********");
|
||||
setTextOfParagraph(num, "%python\\n " + text);
|
||||
LOG.info("runParagraph***********");
|
||||
runParagraph(num);
|
||||
try {
|
||||
LOG.info("wait********");
|
||||
waitForParagraph(num, "FINISHED");
|
||||
} catch (TimeoutException e) {
|
||||
waitForParagraph(num, "ERROR");
|
||||
|
|
@ -175,7 +172,7 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void testGloballyAction() throws Exception {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
|
|
@ -365,7 +362,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
//paragraph: Check if the result is 'user1' in the second paragraph
|
||||
//System: Check if the number of python interpreter process is '1'
|
||||
//System: Check if the number of python process is '1'
|
||||
LOG.info("**********step 2");
|
||||
interpreterModeActionsIT.authenticationUser("user1", "password2");
|
||||
By locator = By.xpath("//div[contains(@class, 'col-md-4')]/div/h5/a[contains(.,'Create new" +
|
||||
" note')]");
|
||||
|
|
@ -400,7 +396,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
// paragraph: Check if the result is 'user2' in the second paragraph
|
||||
//System: Check if the number of python interpreter process is '1'
|
||||
//System: Check if the number of python process is '2'
|
||||
LOG.info("**********step 3");
|
||||
interpreterModeActionsIT.authenticationUser("user2", "password3");
|
||||
locator = By.xpath("//div[contains(@class, 'col-md-4')]/div/h5/a[contains(.,'Create new" +
|
||||
" note')]");
|
||||
|
|
@ -434,7 +429,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
//paragraph: Check if the result is 'user1' in the second paragraph
|
||||
//System: Check if the number of python interpreter process is '1'
|
||||
//System: Check if the number of python process is '1'
|
||||
LOG.info("**********step 4");
|
||||
interpreterModeActionsIT.authenticationUser("user1", "password2");
|
||||
locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]");
|
||||
element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC))
|
||||
|
|
@ -488,7 +482,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
//step 5: (user2) login, come back note user2 made, restart python interpreter in note, check process, logout
|
||||
//System: Check if the number of python interpreter process is '0'
|
||||
//System: Check if the number of python process is '0'
|
||||
LOG.info("**********step 5");
|
||||
interpreterModeActionsIT.authenticationUser("user2", "password3");
|
||||
locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user2noteId + "')]");
|
||||
element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC))
|
||||
|
|
@ -530,7 +523,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
// (user2) login, come back note user2 made, run first paragraph, check process, logout
|
||||
//System: Check if the number of python process is '2'
|
||||
//System: Check if the number of python interpreter process is '1'
|
||||
LOG.info("**********step 6");
|
||||
interpreterModeActionsIT.authenticationUser("user1", "password2");
|
||||
locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]");
|
||||
element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC))
|
||||
|
|
@ -579,7 +571,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
//step 7: (admin) login, restart python interpreter in interpreter tab, check process, logout
|
||||
//System: Check if the number of python interpreter process is 0
|
||||
//System: Check if the number of python process is 0
|
||||
LOG.info("**********step 7");
|
||||
interpreterModeActionsIT.authenticationUser("admin", "password1");
|
||||
pollingWait(By.xpath("//div/button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"),
|
||||
MAX_BROWSER_TIMEOUT_SEC).click();
|
||||
|
|
@ -618,7 +609,7 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void testPerUserIsolatedAction() throws Exception {
|
||||
if (!endToEndTestEnabled()) {
|
||||
return;
|
||||
|
|
@ -652,7 +643,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
//paragraph: Check if the result is 'user1' in the second paragraph
|
||||
//System: Check if the number of python interpreter process is '1'
|
||||
//System: Check if the number of python process is '1'
|
||||
LOG.info("**********step 2");
|
||||
interpreterModeActionsIT.authenticationUser("user1", "password2");
|
||||
By locator = By.xpath("//div[contains(@class, 'col-md-4')]/div/h5/a[contains(.,'Create new" +
|
||||
" note')]");
|
||||
|
|
@ -686,7 +676,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
// paragraph: Check if the result is 'user2' in the second paragraph
|
||||
//System: Check if the number of python interpreter process is '2'
|
||||
//System: Check if the number of python process is '2'
|
||||
LOG.info("**********step 3");
|
||||
interpreterModeActionsIT.authenticationUser("user2", "password3");
|
||||
locator = By.xpath("//div[contains(@class, 'col-md-4')]/div/h5/a[contains(.,'Create new" +
|
||||
" note')]");
|
||||
|
|
@ -721,7 +710,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
//paragraph: Check if the result is 'user1' in the second paragraph
|
||||
//System: Check if the number of python interpreter process is '1'
|
||||
//System: Check if the number of python process is '1'
|
||||
LOG.info("**********step 4");
|
||||
interpreterModeActionsIT.authenticationUser("user1", "password2");
|
||||
locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]");
|
||||
element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC))
|
||||
|
|
@ -776,7 +764,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
//step 5: (user2) login, come back note user2 made, restart python interpreter in note, check process, logout
|
||||
//System: Check if the number of python interpreter process is '0'
|
||||
//System: Check if the number of python process is '0'
|
||||
LOG.info("**********step 5");
|
||||
interpreterModeActionsIT.authenticationUser("user2", "password3");
|
||||
locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user2noteId + "')]");
|
||||
element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC))
|
||||
|
|
@ -819,7 +806,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
// (user2) login, come back note user2 made, run first paragraph, check process, logout
|
||||
//System: Check if the number of python process is '2'
|
||||
//System: Check if the number of python interpreter process is '2'
|
||||
LOG.info("**********step 6");
|
||||
interpreterModeActionsIT.authenticationUser("user1", "password2");
|
||||
locator = By.xpath("//*[@id='notebook-names']//a[contains(@href, '" + user1noteId + "')]");
|
||||
element = (new WebDriverWait(driver, MAX_BROWSER_TIMEOUT_SEC))
|
||||
|
|
@ -868,7 +854,6 @@ public class InterpreterModeActionsIT extends AbstractZeppelinIT {
|
|||
//step 7: (admin) login, restart python interpreter in interpreter tab, check process, logout
|
||||
//System: Check if the number of python interpreter process is 0
|
||||
//System: Check if the number of python process is 0
|
||||
LOG.info("**********step 7");
|
||||
interpreterModeActionsIT.authenticationUser("admin", "password1");
|
||||
pollingWait(By.xpath("//div/button[contains(@class, 'nav-btn dropdown-toggle ng-scope')]"),
|
||||
MAX_BROWSER_TIMEOUT_SEC).click();
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ public class NotebookServerTest extends AbstractTestRestApi {
|
|||
final InterpreterGroup mdGroup = new InterpreterGroup("mdGroup");
|
||||
mdGroup.setAngularObjectRegistry(mdRegistry);
|
||||
|
||||
when(paragraph.getInterpreter().getInterpreterGroup()).thenReturn(mdGroup);
|
||||
when(paragraph.getBindedInterpreter().getInterpreterGroup()).thenReturn(mdGroup);
|
||||
|
||||
final AngularObject<String> ao1 = AngularObjectBuilder.build(varName, value, "noteId", "paragraphId");
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ public class NotebookServerTest extends AbstractTestRestApi {
|
|||
final InterpreterGroup mdGroup = new InterpreterGroup("mdGroup");
|
||||
mdGroup.setAngularObjectRegistry(mdRegistry);
|
||||
|
||||
when(paragraph.getInterpreter().getInterpreterGroup()).thenReturn(mdGroup);
|
||||
when(paragraph.getBindedInterpreter().getInterpreterGroup()).thenReturn(mdGroup);
|
||||
|
||||
|
||||
final AngularObject<String> ao1 = AngularObjectBuilder.build(varName, value, "noteId", "paragraphId");
|
||||
|
|
@ -302,7 +302,7 @@ public class NotebookServerTest extends AbstractTestRestApi {
|
|||
final InterpreterGroup mdGroup = new InterpreterGroup("mdGroup");
|
||||
mdGroup.setAngularObjectRegistry(mdRegistry);
|
||||
|
||||
when(paragraph.getInterpreter().getInterpreterGroup()).thenReturn(mdGroup);
|
||||
when(paragraph.getBindedInterpreter().getInterpreterGroup()).thenReturn(mdGroup);
|
||||
|
||||
final AngularObject<String> ao1 = AngularObjectBuilder.build(varName, value, "noteId", "paragraphId");
|
||||
when(mdRegistry.removeAndNotifyRemoteProcess(varName, "noteId", "paragraphId")).thenReturn(ao1);
|
||||
|
|
@ -347,7 +347,7 @@ public class NotebookServerTest extends AbstractTestRestApi {
|
|||
final InterpreterGroup mdGroup = new InterpreterGroup("mdGroup");
|
||||
mdGroup.setAngularObjectRegistry(mdRegistry);
|
||||
|
||||
when(paragraph.getInterpreter().getInterpreterGroup()).thenReturn(mdGroup);
|
||||
when(paragraph.getBindedInterpreter().getInterpreterGroup()).thenReturn(mdGroup);
|
||||
|
||||
final AngularObject<String> ao1 = AngularObjectBuilder.build(varName, value, "noteId", "paragraphId");
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import com.google.gson.Gson;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.zeppelin.interpreter.Interpreter;
|
||||
import org.apache.zeppelin.interpreter.InterpreterGroup;
|
||||
import org.apache.zeppelin.interpreter.InterpreterSettingManager;
|
||||
import org.apache.zeppelin.interpreter.ManagedInterpreterGroup;
|
||||
import org.apache.zeppelin.interpreter.remote.RemoteInterpreterProcess;
|
||||
|
|
@ -341,7 +340,7 @@ public class Helium {
|
|||
public HeliumPackageSuggestion suggestApp(Paragraph paragraph) {
|
||||
HeliumPackageSuggestion suggestion = new HeliumPackageSuggestion();
|
||||
|
||||
Interpreter intp = paragraph.getInterpreter();
|
||||
Interpreter intp = paragraph.getBindedInterpreter();
|
||||
if (intp == null) {
|
||||
return suggestion;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class HeliumApplicationFactory implements ApplicationEventListener, Noteb
|
|||
public void run() {
|
||||
try {
|
||||
// get interpreter process
|
||||
Interpreter intp = paragraph.getInterpreter();
|
||||
Interpreter intp = paragraph.getBindedInterpreter();
|
||||
ManagedInterpreterGroup intpGroup = (ManagedInterpreterGroup) intp.getInterpreterGroup();
|
||||
RemoteInterpreterProcess intpProcess = intpGroup.getRemoteInterpreterProcess();
|
||||
if (intpProcess == null) {
|
||||
|
|
@ -200,7 +200,7 @@ public class HeliumApplicationFactory implements ApplicationEventListener, Noteb
|
|||
"Can't unload application status " + appsToUnload.getStatus());
|
||||
}
|
||||
appStatusChange(paragraph, appsToUnload.getId(), ApplicationState.Status.UNLOADING);
|
||||
Interpreter intp = paragraph.getInterpreter();
|
||||
Interpreter intp = paragraph.getBindedInterpreter();
|
||||
if (intp == null) {
|
||||
throw new ApplicationException("No interpreter found");
|
||||
}
|
||||
|
|
@ -280,7 +280,7 @@ public class HeliumApplicationFactory implements ApplicationEventListener, Noteb
|
|||
"Can't run application status " + app.getStatus());
|
||||
}
|
||||
|
||||
Interpreter intp = paragraph.getInterpreter();
|
||||
Interpreter intp = paragraph.getBindedInterpreter();
|
||||
if (intp == null) {
|
||||
throw new ApplicationException("No interpreter found");
|
||||
}
|
||||
|
|
@ -417,7 +417,7 @@ public class HeliumApplicationFactory implements ApplicationEventListener, Noteb
|
|||
@Override
|
||||
public void onUnbindInterpreter(Note note, InterpreterSetting setting) {
|
||||
for (Paragraph p : note.getParagraphs()) {
|
||||
Interpreter currentInterpreter = p.getInterpreter();
|
||||
Interpreter currentInterpreter = p.getBindedInterpreter();
|
||||
List<InterpreterInfo> infos = setting.getInterpreterInfos();
|
||||
for (InterpreterInfo info : infos) {
|
||||
if (currentInterpreter != null &&
|
||||
|
|
|
|||
|
|
@ -567,9 +567,9 @@ public class Note implements ParagraphJobListener, JsonSerializable {
|
|||
if (paragraphs.size() > 0) {
|
||||
String replName;
|
||||
if (index == 0) {
|
||||
replName = paragraphs.get(0).getReplText();
|
||||
replName = paragraphs.get(0).getIntpText();
|
||||
} else {
|
||||
replName = paragraphs.get(index - 1).getReplText();
|
||||
replName = paragraphs.get(index - 1).getIntpText();
|
||||
}
|
||||
if (p.isValidInterpreter(replName) && StringUtils.isNotEmpty(replName)) {
|
||||
p.setText("%" + replName + "\n");
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.zeppelin.common.JsonSerializable;
|
||||
import org.apache.zeppelin.display.AngularObject;
|
||||
import org.apache.zeppelin.display.AngularObjectRegistry;
|
||||
|
|
@ -72,10 +73,8 @@ import com.google.common.collect.Maps;
|
|||
*/
|
||||
public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
||||
|
||||
private static final long serialVersionUID = -6328572073497992016L;
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(Paragraph.class);
|
||||
private static Pattern REPL_PATTERN = Pattern.compile("%([\\w\\.]+).*", Pattern.DOTALL);
|
||||
private static Pattern REPL_PATTERN = Pattern.compile("(\\s*)%([\\w\\.]+).*", Pattern.DOTALL);
|
||||
|
||||
private transient InterpreterFactory interpreterFactory;
|
||||
private transient Interpreter interpreter;
|
||||
|
|
@ -84,8 +83,8 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
private transient Map<String, Paragraph> userParagraphMap = Maps.newHashMap(); // personalized
|
||||
|
||||
private String title;
|
||||
private String text; // text is composed of replText and scriptText.
|
||||
private transient String replText;
|
||||
private String text; // text is composed of intpText and scriptText.
|
||||
private transient String intpText;
|
||||
private transient String scriptText;
|
||||
private String user;
|
||||
private Date dateUpdated;
|
||||
|
|
@ -180,17 +179,19 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
}
|
||||
|
||||
public void setText(String newText) {
|
||||
// strip white space from the beginning
|
||||
this.text = newText;
|
||||
this.dateUpdated = new Date();
|
||||
// parse text to get interpreter component
|
||||
if (this.text != null) {
|
||||
Matcher matcher = REPL_PATTERN.matcher(this.text);
|
||||
if (matcher.matches()) {
|
||||
this.replText = matcher.group(1);
|
||||
this.interpreter = interpreterFactory.getInterpreter(user, note.getId(), replText);
|
||||
this.scriptText = this.text.substring(replText.length() + 1).trim();
|
||||
String headingSpace = matcher.group(1);
|
||||
this.intpText = matcher.group(2);
|
||||
this.interpreter = interpreterFactory.getInterpreter(user, note.getId(), intpText);
|
||||
this.scriptText = this.text.substring(headingSpace.length() + intpText.length() + 1).trim();
|
||||
} else {
|
||||
this.replText = "";
|
||||
this.intpText = "";
|
||||
this.interpreter = interpreterFactory.getInterpreter(user, note.getId(), "");
|
||||
this.scriptText = this.text;
|
||||
}
|
||||
|
|
@ -214,8 +215,8 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
this.title = title;
|
||||
}
|
||||
|
||||
public String getReplText() {
|
||||
return replText;
|
||||
public String getIntpText() {
|
||||
return intpText;
|
||||
}
|
||||
|
||||
public String getScriptText() {
|
||||
|
|
@ -235,8 +236,8 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
return enabled == null || enabled.booleanValue();
|
||||
}
|
||||
|
||||
public Interpreter getInterpreter() {
|
||||
return this.interpreter;
|
||||
public Interpreter getBindedInterpreter() {
|
||||
return this.interpreterFactory.getInterpreter(user, note.getId(), intpText);
|
||||
}
|
||||
|
||||
public void setInterpreter(Interpreter interpreter) {
|
||||
|
|
@ -278,7 +279,7 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
if (trimmedBuffer != null) {
|
||||
Matcher matcher = REPL_PATTERN.matcher(trimmedBuffer);
|
||||
if (matcher.matches()) {
|
||||
repl = matcher.group(1);
|
||||
repl = matcher.group(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -346,11 +347,11 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
}
|
||||
|
||||
clearRuntimeInfo(null);
|
||||
this.interpreter = interpreterFactory.getInterpreter(user, note.getId(), replText);
|
||||
this.interpreter = getBindedInterpreter();
|
||||
|
||||
if (interpreter == null) {
|
||||
String intpExceptionMsg =
|
||||
getJobName() + "'s Interpreter " + getReplText() + " not found";
|
||||
getJobName() + "'s Interpreter " + getIntpText() + " not found";
|
||||
RuntimeException intpException = new RuntimeException(intpExceptionMsg);
|
||||
InterpreterResult intpResult =
|
||||
new InterpreterResult(InterpreterResult.Code.ERROR, intpException.getMessage());
|
||||
|
|
@ -379,10 +380,11 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
|
||||
@Override
|
||||
protected Object jobRun() throws Throwable {
|
||||
logger.info("run paragraph {} using {} ", getId(), replText);
|
||||
logger.info("Run paragraph {} using {} ", getId(), intpText);
|
||||
this.interpreter = getBindedInterpreter();
|
||||
if (this.interpreter == null) {
|
||||
logger.error("Can not find interpreter name " + replText);
|
||||
throw new RuntimeException("Can not find interpreter for " + replText);
|
||||
logger.error("Can not find interpreter name " + intpText);
|
||||
throw new RuntimeException("Can not find interpreter for " + intpText);
|
||||
}
|
||||
InterpreterSetting interpreterSetting = ((ManagedInterpreterGroup)
|
||||
interpreter.getInterpreterGroup()).getInterpreterSetting();
|
||||
|
|
@ -392,9 +394,9 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
if (this.hasUser() && this.note.hasInterpreterBinded()) {
|
||||
if (interpreterSetting != null && interpreterHasUser(interpreterSetting)
|
||||
&& isUserAuthorizedToAccessInterpreter(interpreterSetting.getOption()) == false) {
|
||||
logger.error("{} has no permission for {} ", authenticationInfo.getUser(), replText);
|
||||
logger.error("{} has no permission for {} ", authenticationInfo.getUser(), intpText);
|
||||
return new InterpreterResult(Code.ERROR,
|
||||
authenticationInfo.getUser() + " has no permission for " + replText);
|
||||
authenticationInfo.getUser() + " has no permission for " + intpText);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -409,13 +411,10 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
} else if (interpreter.getFormType() == FormType.SIMPLE) {
|
||||
// inputs will be built from script scriptText
|
||||
LinkedHashMap<String, Input> inputs = Input.extractSimpleQueryForm(this.scriptText);
|
||||
|
||||
final AngularObjectRegistry angularRegistry =
|
||||
interpreter.getInterpreterGroup().getAngularObjectRegistry();
|
||||
|
||||
String scriptBody = extractVariablesFromAngularRegistry(this.scriptText, inputs,
|
||||
angularRegistry);
|
||||
|
||||
settings.setForms(inputs);
|
||||
script = Input.getSimpleQuery(settings.getParams(), scriptBody);
|
||||
}
|
||||
|
|
@ -546,7 +545,7 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
}
|
||||
|
||||
InterpreterContext interpreterContext =
|
||||
new InterpreterContext(note.getId(), getId(), replText, this.getTitle(),
|
||||
new InterpreterContext(note.getId(), getId(), intpText, this.getTitle(),
|
||||
this.getText(), this.getAuthenticationInfo(), this.getConfig(), this.settings, registry,
|
||||
resourcePool, runners, output);
|
||||
return interpreterContext;
|
||||
|
|
@ -576,7 +575,7 @@ public class Paragraph extends Job implements Cloneable, JsonSerializable {
|
|||
}
|
||||
|
||||
InterpreterContext interpreterContext =
|
||||
new InterpreterContext(note.getId(), getId(), replText, this.getTitle(),
|
||||
new InterpreterContext(note.getId(), getId(), intpText, this.getTitle(),
|
||||
this.getText(), this.getAuthenticationInfo(), this.getConfig(), this.settings, registry,
|
||||
resourcePool, runners, output);
|
||||
return interpreterContext;
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ public class HeliumApplicationFactoryTest extends AbstractInterpreterTest implem
|
|||
p1.setText("%fake ");
|
||||
|
||||
// make sure that p1's repl is null
|
||||
Interpreter intp = p1.getInterpreter();
|
||||
Interpreter intp = p1.getBindedInterpreter();
|
||||
assertEquals(intp, null);
|
||||
|
||||
// Unbind all interpreter from note
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class NotebookTest extends AbstractInterpreterTest implements JobListener
|
|||
|
||||
// then interpreter factory should be injected into all the paragraphs
|
||||
Note note = notebook.getAllNotes().get(0);
|
||||
assertNull(note.getParagraphs().get(0).getInterpreter());
|
||||
assertNull(note.getParagraphs().get(0).getBindedInterpreter());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -64,11 +64,11 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
Note note = createNote();
|
||||
Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
|
||||
paragraph.setText("%test(1234567");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("(1234567", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("%test 1234567");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("1234567", paragraph.getScriptText());
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
Note note = createNote();
|
||||
Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
|
||||
paragraph.setText("1234567");
|
||||
assertEquals("", paragraph.getReplText());
|
||||
assertEquals("", paragraph.getIntpText());
|
||||
assertEquals("1234567", paragraph.getScriptText());
|
||||
}
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
Note note = createNote();
|
||||
Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
|
||||
paragraph.setText("%test");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("", paragraph.getScriptText());
|
||||
}
|
||||
|
||||
|
|
@ -95,37 +95,66 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
Note note = createNote();
|
||||
Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
|
||||
paragraph.setText("%r a");
|
||||
assertEquals("r", paragraph.getReplText());
|
||||
assertEquals("r", paragraph.getIntpText());
|
||||
assertEquals("a", paragraph.getScriptText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replInvalid() {
|
||||
Note note = createNote();
|
||||
Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
|
||||
paragraph.setText("foo %r");
|
||||
assertEquals("", paragraph.getIntpText());
|
||||
assertEquals("foo %r", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("foo%r");
|
||||
assertEquals("", paragraph.getIntpText());
|
||||
assertEquals("foo%r", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("% foo");
|
||||
assertEquals("", paragraph.getIntpText());
|
||||
assertEquals("% foo", paragraph.getScriptText());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replNameEndsWithWhitespace() {
|
||||
Note note = createNote();
|
||||
Paragraph paragraph = new Paragraph(note, null, interpreterFactory);
|
||||
paragraph.setText("%test\r\n###Hello");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("###Hello", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("%test\t###Hello");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("###Hello", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("%test\u000b###Hello");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("###Hello", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("%test\f###Hello");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("###Hello", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("%test\n###Hello");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("###Hello", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("%test ###Hello");
|
||||
assertEquals("test", paragraph.getReplText());
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("###Hello", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText(" %test ###Hello");
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("###Hello", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("\n\r%test ###Hello");
|
||||
assertEquals("test", paragraph.getIntpText());
|
||||
assertEquals("###Hello", paragraph.getScriptText());
|
||||
|
||||
paragraph.setText("%\r\n###Hello");
|
||||
assertEquals("", paragraph.getIntpText());
|
||||
assertEquals("%\r\n###Hello", paragraph.getScriptText());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -185,7 +214,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
|
||||
Interpreter mockInterpreter = mock(Interpreter.class);
|
||||
spyParagraph.setInterpreter(mockInterpreter);
|
||||
doReturn(mockInterpreter).when(spyParagraph).getInterpreter();
|
||||
doReturn(mockInterpreter).when(spyParagraph).getBindedInterpreter();
|
||||
|
||||
ManagedInterpreterGroup mockInterpreterGroup = mock(ManagedInterpreterGroup.class);
|
||||
when(mockInterpreter.getInterpreterGroup()).thenReturn(mockInterpreterGroup);
|
||||
|
|
@ -242,7 +271,7 @@ public class ParagraphTest extends AbstractInterpreterTest {
|
|||
@Test
|
||||
public void testCursorPosition() {
|
||||
Paragraph paragraph = spy(new Paragraph());
|
||||
doReturn(null).when(paragraph).getReplText();
|
||||
doReturn(null).when(paragraph).getIntpText();
|
||||
// left = buffer, middle = cursor position into source code, right = cursor position after parse
|
||||
List<Triple<String, Integer, Integer>> dataSet = Arrays.asList(
|
||||
Triple.of("%jdbc schema.", 13, 7),
|
||||
|
|
|
|||
Loading…
Reference in a new issue