diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java index f713f4a9a12..8a2cd932dd8 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java @@ -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; } diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java index b479799e246..338210daddf 100644 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreter.java @@ -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) { diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java index 74bde89dfa1..c268c817616 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/remote/RemoteInterpreterTest.java @@ -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; @@ -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 { @@ -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 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 expected = new LinkedHashMap<>(gui.getForms()); + Interpreter interpreter = interpreterSetting.getDefaultInterpreter("user1", "note1"); + InterpreterContext context = new InterpreterContext("noteId", "paragraphId", "repl", null, + null, AuthenticationInfo.ANONYMOUS, new HashMap(), gui, + null, null, new ArrayList(), null); + + interpreter.interpret("text", context); + assertArrayEquals(expected.values().toArray(), gui.getForms().values().toArray()); + } + }