Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ public boolean equals(Object o) {
if (displayName != null ? !displayName.equals(input.displayName) : input.displayName != null) {
return false;
}
if (defaultValue != null ?
if (defaultValue instanceof Object[]) {
if (defaultValue != null ?
!Arrays.equals((Object[]) defaultValue, (Object[]) input.defaultValue)
: input.defaultValue != null) {
return false;
}
} else if (defaultValue != null ?
!defaultValue.equals(input.defaultValue) : input.defaultValue != null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public Scheduler getScheduler() {
private RemoteInterpreterContext convert(InterpreterContext ic) {
return new RemoteInterpreterContext(ic.getNoteId(), ic.getParagraphId(), ic.getReplName(),
ic.getParagraphTitle(), ic.getParagraphText(), gson.toJson(ic.getAuthenticationInfo()),
gson.toJson(ic.getConfig()), gson.toJson(ic.getGui()), gson.toJson(ic.getRunners()));
gson.toJson(ic.getConfig()), ic.getGui().toJson(), gson.toJson(ic.getRunners()));
}

private InterpreterResult convert(RemoteInterpreterResult result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.apache.thrift.transport.TTransportException;
import org.apache.zeppelin.display.AngularObjectRegistry;
import org.apache.zeppelin.display.GUI;
import org.apache.zeppelin.display.Input;
import org.apache.zeppelin.display.ui.OptionInput;
import org.apache.zeppelin.interpreter.*;
import org.apache.zeppelin.interpreter.InterpreterResult.Code;
import org.apache.zeppelin.interpreter.remote.mock.GetAngularObjectSizeInterpreter;
Expand All @@ -32,11 +34,11 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;
import java.util.Map;

import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;

public class RemoteInterpreterTest {

Expand Down Expand Up @@ -413,4 +415,27 @@ public void testEnvironmentAndProperty() throws InterpreterException {
assertEquals("null", interpreter1.interpret("getProperty property_2", context1).message().get(0).getData());
}

@Test
public void testConvertDynamicForms() throws InterpreterException {
GUI gui = new GUI();
OptionInput.ParamOption[] paramOptions = {
new OptionInput.ParamOption("value1", "param1"),
new OptionInput.ParamOption("value2", "param2")
};
List<Object> defaultValues = new ArrayList();
defaultValues.add("default1");
defaultValues.add("default2");
gui.checkbox("checkbox_id", defaultValues, paramOptions);
gui.select("select_id", "default", paramOptions);
gui.textbox("textbox_id");
Map<String, Input> expected = new LinkedHashMap<>(gui.getForms());
Interpreter interpreter = interpreterSetting.getDefaultInterpreter("user1", "note1");
InterpreterContext context = new InterpreterContext("noteId", "paragraphId", "repl", null,
null, AuthenticationInfo.ANONYMOUS, new HashMap<String, Object>(), gui,
null, null, new ArrayList<InterpreterContextRunner>(), null);

interpreter.interpret("text", context);
assertArrayEquals(expected.values().toArray(), gui.getForms().values().toArray());
}

}