http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/AuthenticationInfo.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/AuthenticationInfo.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/AuthenticationInfo.java index 455fd8b..027f4c8 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/AuthenticationInfo.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/AuthenticationInfo.java @@ -15,23 +15,17 @@ * limitations under the License. */ - package org.apache.zeppelin.user; - +import com.google.gson.Gson; import java.util.ArrayList; import java.util.List; - import org.apache.commons.lang.StringUtils; import org.apache.zeppelin.common.JsonSerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.gson.Gson; - -/*** - * - */ +/** * */ public class AuthenticationInfo implements JsonSerializable { private static final Logger LOG = LoggerFactory.getLogger(AuthenticationInfo.class); private static final Gson gson = new Gson(); @@ -40,8 +34,8 @@ public class AuthenticationInfo implements JsonSerializable { List<String> roles; String ticket; UserCredentials userCredentials; - public static final AuthenticationInfo ANONYMOUS = new AuthenticationInfo("anonymous", null, - "anonymous"); + public static final AuthenticationInfo ANONYMOUS = + new AuthenticationInfo("anonymous", null, "anonymous"); public AuthenticationInfo() {} @@ -49,7 +43,8 @@ public class AuthenticationInfo implements JsonSerializable { this.user = user; } - /*** + /** + * * * * @param user * @param ticket @@ -110,15 +105,17 @@ public class AuthenticationInfo implements JsonSerializable { public static boolean isAnonymous(AuthenticationInfo subject) { if (subject == null) { - LOG.warn("Subject is null, assuming anonymous. " - + "Not recommended to use subject as null except in tests"); + LOG.warn( + "Subject is null, assuming anonymous. " + + "Not recommended to use subject as null except in tests"); return true; } return subject.isAnonymous(); } public boolean isAnonymous() { - return ANONYMOUS.equals(this) || "anonymous".equalsIgnoreCase(this.getUser()) + return ANONYMOUS.equals(this) + || "anonymous".equalsIgnoreCase(this.getUser()) || StringUtils.isEmpty(this.getUser()); }
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UserCredentials.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UserCredentials.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UserCredentials.java index f952866..7379793 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UserCredentials.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UserCredentials.java @@ -20,9 +20,7 @@ package org.apache.zeppelin.user; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -/** - * User Credentials POJO - */ +/** User Credentials POJO */ public class UserCredentials { private Map<String, UsernamePassword> userCredentials = new ConcurrentHashMap<>(); @@ -44,8 +42,6 @@ public class UserCredentials { @Override public String toString() { - return "UserCredentials{" + - "userCredentials=" + userCredentials + - '}'; + return "UserCredentials{" + "userCredentials=" + userCredentials + '}'; } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UsernamePassword.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UsernamePassword.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UsernamePassword.java index 00116a9..9be8200 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UsernamePassword.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/UsernamePassword.java @@ -1,25 +1,23 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.zeppelin.user; -/** - * Username and Password POJO - */ +/** Username and Password POJO */ public class UsernamePassword { private String username; private String password; @@ -47,9 +45,13 @@ public class UsernamePassword { @Override public String toString() { - return "UsernamePassword{" + - "username='" + username + '\'' + - ", password='" + password + '\'' + - '}'; + return "UsernamePassword{" + + "username='" + + username + + '\'' + + ", password='" + + password + + '\'' + + '}'; } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java index 9d4e10f..9a34380 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/IdHashes.java @@ -18,17 +18,17 @@ package org.apache.zeppelin.util; import java.math.BigInteger; +import java.security.SecureRandom; import java.util.ArrayList; import java.util.List; -import java.security.SecureRandom; -/** - * Generate Tiny ID. - */ +/** Generate Tiny ID. */ public class IdHashes { - private static final char[] DICTIONARY = new char[] {'1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', - 'W', 'X', 'Y', 'Z'}; + private static final char[] DICTIONARY = + new char[] { + '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', + 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' + }; /** * encodes the given string into the base of the dictionary provided in the constructor. http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/Util.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/Util.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/Util.java index 6153f49..2e189d5 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/Util.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/util/Util.java @@ -17,14 +17,11 @@ package org.apache.zeppelin.util; -import org.apache.commons.lang.StringUtils; - import java.io.IOException; import java.util.Properties; +import org.apache.commons.lang.StringUtils; -/** - * TODO(moon) : add description. - */ +/** TODO(moon) : add description. */ public class Util { private static final String PROJECT_PROPERTIES_VERSION_KEY = "version"; private static final String GIT_PROPERTIES_COMMIT_ID_KEY = "git.commit.id.abbrev"; @@ -40,7 +37,7 @@ public class Util { projectProperties.load(Util.class.getResourceAsStream("/project.properties")); gitProperties.load(Util.class.getResourceAsStream("/git.properties")); } catch (IOException e) { - //Fail to read project.properties + // Fail to read project.properties } } @@ -50,8 +47,8 @@ public class Util { * @return Current Zeppelin version */ public static String getVersion() { - return StringUtils.defaultIfEmpty(projectProperties.getProperty(PROJECT_PROPERTIES_VERSION_KEY), - StringUtils.EMPTY); + return StringUtils.defaultIfEmpty( + projectProperties.getProperty(PROJECT_PROPERTIES_VERSION_KEY), StringUtils.EMPTY); } /** @@ -60,8 +57,8 @@ public class Util { * @return Latest Zeppelin commit id */ public static String getGitCommitId() { - return StringUtils.defaultIfEmpty(gitProperties.getProperty(GIT_PROPERTIES_COMMIT_ID_KEY), - StringUtils.EMPTY); + return StringUtils.defaultIfEmpty( + gitProperties.getProperty(GIT_PROPERTIES_COMMIT_ID_KEY), StringUtils.EMPTY); } /** @@ -70,7 +67,7 @@ public class Util { * @return Latest Zeppelin commit timestamp */ public static String getGitTimestamp() { - return StringUtils.defaultIfEmpty(gitProperties.getProperty(GIT_PROPERTIES_COMMIT_TS_KEY), - StringUtils.EMPTY); + return StringUtils.defaultIfEmpty( + gitProperties.getProperty(GIT_PROPERTIES_COMMIT_TS_KEY), StringUtils.EMPTY); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java index ffc3c8f..8d74d4c 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/BooterTest.java @@ -17,14 +17,13 @@ package org.apache.zeppelin.dep; -import org.junit.Test; - -import java.nio.file.Paths; - import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import java.nio.file.Paths; +import org.junit.Test; + public class BooterTest { @Test @@ -35,8 +34,7 @@ public class BooterTest { @Test public void should_not_change_absolute_path() { - String absolutePath - = Paths.get("first", "second").toAbsolutePath().toString(); + String absolutePath = Paths.get("first", "second").toAbsolutePath().toString(); String resolvedPath = Booter.resolveLocalRepoPath(absolutePath); assertThat(resolvedPath, equalTo(absolutePath)); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java index 7ccc7df..80ce490 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/dep/DependencyResolverTest.java @@ -17,6 +17,11 @@ package org.apache.zeppelin.dep; +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Collections; import org.apache.commons.io.FileUtils; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -25,25 +30,19 @@ import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonatype.aether.RepositoryException; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Collections; - -import static org.junit.Assert.assertEquals; - public class DependencyResolverTest { private static DependencyResolver resolver; private static String testPath; private static File testCopyPath; private static File tmpDir; - @Rule - public ExpectedException expectedException = ExpectedException.none(); + @Rule public ExpectedException expectedException = ExpectedException.none(); @BeforeClass public static void setUp() throws Exception { - tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + - System.currentTimeMillis()); + tmpDir = + new File( + System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis()); testPath = tmpDir.getAbsolutePath() + "/test-repo"; testCopyPath = new File(tmpDir, "test-copy-repo"); resolver = new DependencyResolver(testPath); @@ -54,8 +53,7 @@ public class DependencyResolverTest { FileUtils.deleteDirectory(tmpDir); } - @Rule - public final ExpectedException exception = ExpectedException.none(); + @Rule public final ExpectedException exception = ExpectedException.none(); @Test public void testAddRepo() { @@ -80,14 +78,16 @@ public class DependencyResolverTest { FileUtils.cleanDirectory(testCopyPath); // load with exclusions parameter - resolver.load("com.databricks:spark-csv_2.10:1.3.0", - Collections.singletonList("org.scala-lang:scala-library"), testCopyPath); + resolver.load( + "com.databricks:spark-csv_2.10:1.3.0", + Collections.singletonList("org.scala-lang:scala-library"), + testCopyPath); assertEquals(testCopyPath.list().length, 3); FileUtils.cleanDirectory(testCopyPath); // load from added repository - resolver.addRepo("sonatype", - "https://oss.sonatype.org/content/repositories/agimatec-releases/", false); + resolver.addRepo( + "sonatype", "https://oss.sonatype.org/content/repositories/agimatec-releases/", false); resolver.load("com.agimatec:agimatec-validation:0.9.3", testCopyPath); assertEquals(testCopyPath.list().length, 8); @@ -104,5 +104,4 @@ public class DependencyResolverTest { resolver.load("one.two:1.0", testCopyPath); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java index 529284f..5b2f6ae 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectRegistryTest.java @@ -17,14 +17,13 @@ package org.apache.zeppelin.display; -import org.apache.thrift.TException; -import org.junit.Test; - -import java.util.concurrent.atomic.AtomicInteger; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import java.util.concurrent.atomic.AtomicInteger; +import org.apache.thrift.TException; +import org.junit.Test; + public class AngularObjectRegistryTest { @Test @@ -33,27 +32,27 @@ public class AngularObjectRegistryTest { final AtomicInteger onUpdate = new AtomicInteger(0); final AtomicInteger onRemove = new AtomicInteger(0); - AngularObjectRegistry registry = new AngularObjectRegistry("intpId", - new AngularObjectRegistryListener() { + AngularObjectRegistry registry = + new AngularObjectRegistry( + "intpId", + new AngularObjectRegistryListener() { - @Override - public void onAdd(String interpreterGroupId, AngularObject object) { - onAdd.incrementAndGet(); - } + @Override + public void onAdd(String interpreterGroupId, AngularObject object) { + onAdd.incrementAndGet(); + } - @Override - public void onUpdate(String interpreterGroupId, AngularObject object) { - onUpdate.incrementAndGet(); - } + @Override + public void onUpdate(String interpreterGroupId, AngularObject object) { + onUpdate.incrementAndGet(); + } - @Override - public void onRemove(String interpreterGroupId, - String name, - String noteId, - String paragraphId) { - onRemove.incrementAndGet(); - } - }); + @Override + public void onRemove( + String interpreterGroupId, String name, String noteId, String paragraphId) { + onRemove.incrementAndGet(); + } + }); registry.add("name1", "value1", "note1", null); assertEquals(1, registry.getAll("note1", null).size()); @@ -88,7 +87,6 @@ public class AngularObjectRegistryTest { AngularObject ao4 = registry.add("name3", "o4", "noteId1", null); AngularObject ao5 = registry.add("name4", "o5", null, null); - assertNull(registry.get("name3", "noteId1", "paragraphId1")); assertNull(registry.get("name1", "noteId2", null)); assertEquals("o1", registry.get("name1", "noteId1", "paragraphId1").get()); @@ -113,5 +111,4 @@ public class AngularObjectRegistryTest { assertEquals(1, registry.getAll(null, null).size()); assertEquals(5, registry.getAllWithGlobal("noteId1").size()); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java index b30439a..80acea8 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/AngularObjectTest.java @@ -17,78 +17,71 @@ package org.apache.zeppelin.display; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; + +import java.util.concurrent.atomic.AtomicInteger; import org.apache.thrift.TException; import org.apache.zeppelin.interpreter.InterpreterContext; import org.junit.Test; -import java.util.concurrent.atomic.AtomicInteger; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; - public class AngularObjectTest { @Test public void testEquals() { assertEquals( new AngularObject("name", "value", "note1", null, null), - new AngularObject("name", "value", "note1", null, null) - ); + new AngularObject("name", "value", "note1", null, null)); assertEquals( new AngularObject("name", "value", "note1", "paragraph1", null), - new AngularObject("name", "value", "note1", "paragraph1", null) - ); + new AngularObject("name", "value", "note1", "paragraph1", null)); assertEquals( new AngularObject("name", "value", null, null, null), - new AngularObject("name", "value", null, null, null) - ); + new AngularObject("name", "value", null, null, null)); assertEquals( new AngularObject("name", "value1", null, null, null), - new AngularObject("name", "value2", null, null, null) - ); + new AngularObject("name", "value2", null, null, null)); assertNotSame( new AngularObject("name1", "value", null, null, null), - new AngularObject("name2", "value", null, null, null) - ); + new AngularObject("name2", "value", null, null, null)); assertNotSame( new AngularObject("name1", "value", "note1", null, null), - new AngularObject("name2", "value", "note2", null, null) - ); + new AngularObject("name2", "value", "note2", null, null)); assertNotSame( new AngularObject("name1", "value", "note", null, null), - new AngularObject("name2", "value", null, null, null) - ); + new AngularObject("name2", "value", null, null, null)); assertNotSame( new AngularObject("name", "value", "note", "paragraph1", null), - new AngularObject("name", "value", "note", "paragraph2", null) - ); + new AngularObject("name", "value", "note", "paragraph2", null)); assertNotSame( new AngularObject("name", "value", "note1", null, null), - new AngularObject("name", "value", "note1", "paragraph1", null) - ); - - + new AngularObject("name", "value", "note1", "paragraph1", null)); } @Test public void testListener() throws TException { final AtomicInteger updated = new AtomicInteger(0); - AngularObject ao = new AngularObject("name", "value", "note1", null, - new AngularObjectListener() { - - @Override - public void updated(AngularObject updatedObject) { - updated.incrementAndGet(); - } - }); + AngularObject ao = + new AngularObject( + "name", + "value", + "note1", + null, + new AngularObjectListener() { + + @Override + public void updated(AngularObject updatedObject) { + updated.incrementAndGet(); + } + }); assertEquals(0, updated.get()); ao.set("newValue"); @@ -107,21 +100,27 @@ public class AngularObjectTest { public void testWatcher() throws InterruptedException, TException { final AtomicInteger updated = new AtomicInteger(0); final AtomicInteger onWatch = new AtomicInteger(0); - AngularObject ao = new AngularObject("name", "value", "note1", null, - new AngularObjectListener() { + AngularObject ao = + new AngularObject( + "name", + "value", + "note1", + null, + new AngularObjectListener() { + @Override + public void updated(AngularObject updatedObject) { + updated.incrementAndGet(); + } + }); + + ao.addWatcher( + new AngularObjectWatcher(null) { @Override - public void updated(AngularObject updatedObject) { - updated.incrementAndGet(); + public void watch(Object oldObject, Object newObject, InterpreterContext context) { + onWatch.incrementAndGet(); } }); - ao.addWatcher(new AngularObjectWatcher(null) { - @Override - public void watch(Object oldObject, Object newObject, InterpreterContext context) { - onWatch.incrementAndGet(); - } - }); - assertEquals(0, onWatch.get()); ao.set("newValue"); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java index 211c379..3ab50a9 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/GUITest.java @@ -17,6 +17,12 @@ package org.apache.zeppelin.display; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import org.apache.zeppelin.display.ui.CheckBox; import org.apache.zeppelin.display.ui.OptionInput.ParamOption; import org.apache.zeppelin.display.ui.Select; @@ -24,19 +30,10 @@ import org.apache.zeppelin.display.ui.TextBox; import org.junit.Before; import org.junit.Test; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - public class GUITest { - private ParamOption[] options = new ParamOption[]{ - new ParamOption("1", "value_1"), - new ParamOption("2", "value_2") - }; + private ParamOption[] options = + new ParamOption[] {new ParamOption("1", "value_1"), new ParamOption("2", "value_2")}; private List<Object> checkedItems; @@ -86,8 +83,7 @@ public class GUITest { GUI gui = new GUI(); gui.forms.put("textbox_1", new OldInput.OldTextBox("textbox_1", "default_text_1")); gui.forms.put("select_1", new OldInput.OldSelect("select_1", "1", options)); - gui.forms.put("checkbox_1", - new OldInput.OldCheckBox("checkbox_1", checkedItems, options)); + gui.forms.put("checkbox_1", new OldInput.OldCheckBox("checkbox_1", checkedItems, options)); // convert to old json format. String json = gui.toJson(); @@ -111,8 +107,7 @@ public class GUITest { GUI gui = new GUI(); gui.forms.put("textbox_1", new OldInput("textbox_1", "default_text_1")); gui.forms.put("select_1", new OldInput("select_1", "1", options)); - gui.forms.put("checkbox_1", - new OldInput.OldCheckBox("checkbox_1", checkedItems, options)); + gui.forms.put("checkbox_1", new OldInput.OldCheckBox("checkbox_1", checkedItems, options)); // convert to old json format. String json = gui.toJson(); @@ -131,46 +126,48 @@ public class GUITest { // load old json file and will convert it into new forms of Input @Test public void testOldGson_3() throws IOException { - String oldJson = "{\n" + - " \"params\": {\n" + - " \"maxAge\": \"35\"\n" + - " },\n" + - " \"forms\": {\n" + - " \"maxAge\": {\n" + - " \"name\": \"maxAge\",\n" + - " \"defaultValue\": \"30\",\n" + - " \"hidden\": false\n" + - " }\n" + - " }\n" + - " }"; + String oldJson = + "{\n" + + " \"params\": {\n" + + " \"maxAge\": \"35\"\n" + + " },\n" + + " \"forms\": {\n" + + " \"maxAge\": {\n" + + " \"name\": \"maxAge\",\n" + + " \"defaultValue\": \"30\",\n" + + " \"hidden\": false\n" + + " }\n" + + " }\n" + + " }"; GUI gui = GUI.fromJson(oldJson); assertEquals(1, gui.forms.size()); assertTrue(gui.forms.get("maxAge") instanceof TextBox); assertEquals("30", gui.forms.get("maxAge").getDefaultValue()); - oldJson = "{\n" + - " \"params\": {\n" + - " \"marital\": \"single\"\n" + - " },\n" + - " \"forms\": {\n" + - " \"marital\": {\n" + - " \"name\": \"marital\",\n" + - " \"defaultValue\": \"single\",\n" + - " \"options\": [\n" + - " {\n" + - " \"value\": \"single\"\n" + - " },\n" + - " {\n" + - " \"value\": \"divorced\"\n" + - " },\n" + - " {\n" + - " \"value\": \"married\"\n" + - " }\n" + - " ],\n" + - " \"hidden\": false\n" + - " }\n" + - " }\n" + - " }"; + oldJson = + "{\n" + + " \"params\": {\n" + + " \"marital\": \"single\"\n" + + " },\n" + + " \"forms\": {\n" + + " \"marital\": {\n" + + " \"name\": \"marital\",\n" + + " \"defaultValue\": \"single\",\n" + + " \"options\": [\n" + + " {\n" + + " \"value\": \"single\"\n" + + " },\n" + + " {\n" + + " \"value\": \"divorced\"\n" + + " },\n" + + " {\n" + + " \"value\": \"married\"\n" + + " }\n" + + " ],\n" + + " \"hidden\": false\n" + + " }\n" + + " }\n" + + " }"; gui = GUI.fromJson(oldJson); assertEquals(1, gui.forms.size()); assertTrue(gui.forms.get("marital") instanceof Select); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java index abe2ac3..789ec49 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/display/InputTest.java @@ -17,6 +17,13 @@ package org.apache.zeppelin.display; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; import org.apache.zeppelin.display.ui.CheckBox; import org.apache.zeppelin.display.ui.OptionInput.ParamOption; import org.apache.zeppelin.display.ui.Password; @@ -24,14 +31,6 @@ import org.apache.zeppelin.display.ui.Select; import org.apache.zeppelin.display.ui.TextBox; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - public class InputTest { @Test @@ -68,10 +67,12 @@ public class InputTest { assertEquals("op1", form.defaultValue); assertEquals("Selection Form", form.getDisplayName()); assertTrue(form instanceof Select); - assertArrayEquals(new ParamOption[]{ - new ParamOption("op1", null), - new ParamOption("op2", "Option 2"), - new ParamOption("op3", null)}, + assertArrayEquals( + new ParamOption[] { + new ParamOption("op1", null), + new ParamOption("op2", "Option 2"), + new ParamOption("op3", null) + }, ((Select) form).getOptions()); // checkbox form @@ -80,11 +81,11 @@ public class InputTest { assertEquals("checkbox_form", form.name); assertTrue(form instanceof CheckBox); - assertArrayEquals(new Object[]{"op1"}, (Object[]) form.defaultValue); - assertArrayEquals(new ParamOption[]{ - new ParamOption("op1", null), - new ParamOption("op2", null), - new ParamOption("op3", null)}, + assertArrayEquals(new Object[] {"op1"}, (Object[]) form.defaultValue); + assertArrayEquals( + new ParamOption[] { + new ParamOption("op1", null), new ParamOption("op2", null), new ParamOption("op3", null) + }, ((CheckBox) form).getOptions()); // checkbox form with multiple default checks @@ -93,11 +94,13 @@ public class InputTest { assertEquals("checkbox_form", form.name); assertEquals("Checkbox Form", form.displayName); assertTrue(form instanceof CheckBox); - assertArrayEquals(new Object[]{"op1", "op3"}, (Object[]) form.defaultValue); - assertArrayEquals(new ParamOption[]{ - new ParamOption("op1", "Option 1"), - new ParamOption("op2", null), - new ParamOption("op3", null)}, + assertArrayEquals(new Object[] {"op1", "op3"}, (Object[]) form.defaultValue); + assertArrayEquals( + new ParamOption[] { + new ParamOption("op1", "Option 1"), + new ParamOption("op2", null), + new ParamOption("op3", null) + }, ((CheckBox) form).getOptions()); // checkbox form with no default check @@ -106,42 +109,46 @@ public class InputTest { assertEquals("checkbox_form", form.name); assertEquals("Checkbox Form", form.displayName); assertTrue(form instanceof CheckBox); - assertArrayEquals(new Object[]{}, (Object[]) form.defaultValue); - assertArrayEquals(new ParamOption[]{ - new ParamOption("op1", "Option 1"), - new ParamOption("op2", "Option 2"), - new ParamOption("op3", "Option 3")}, + assertArrayEquals(new Object[] {}, (Object[]) form.defaultValue); + assertArrayEquals( + new ParamOption[] { + new ParamOption("op1", "Option 1"), + new ParamOption("op2", "Option 2"), + new ParamOption("op3", "Option 3") + }, ((CheckBox) form).getOptions()); } - @Test public void testFormSubstitution() { // test form substitution without new forms - String script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=" + - ",s_op1|s_op2|s_op3}\nCHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}"; + String script = + "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=" + + ",s_op1|s_op2|s_op3}\nCHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}"; Map<String, Object> params = new HashMap<>(); params.put("input_form", "some_input"); params.put("select_form", "s_op2"); - params.put("checkbox_form", new String[]{"c_op1", "c_op3"}); + params.put("checkbox_form", new String[] {"c_op1", "c_op3"}); String replaced = Input.getSimpleQuery(params, script, false); assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3", replaced); // test form substitution with new forms - script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + - "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}\n" + - "NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}"; + script = + "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + + "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3}\n" + + "NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}"; replaced = Input.getSimpleQuery(params, script, false); - assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3\n" + - "NEW_CHECKED=nc_a and nc_c", replaced); + assertEquals( + "INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1,c_op3\n" + "NEW_CHECKED=nc_a and nc_c", + replaced); // test form substitution with obsoleted values - script = "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + - "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3_new}\n" + - "NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}"; + script = + "INPUT=${input_form=}SELECTED=${select_form(Selection Form)=,s_op1|s_op2|s_op3}\n" + + "CHECKED=${checkbox:checkbox_form=c_op1|c_op2,c_op1|c_op2|c_op3_new}\n" + + "NEW_CHECKED=${checkbox( and ):new_check=nc_a|nc_c,nc_a|nc_b|nc_c}"; replaced = Input.getSimpleQuery(params, script, false); - assertEquals("INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1\n" + - "NEW_CHECKED=nc_a and nc_c", replaced); + assertEquals( + "INPUT=some_inputSELECTED=s_op2\nCHECKED=c_op1\n" + "NEW_CHECKED=nc_a and nc_c", replaced); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java index 490c911..05896f4 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/ApplicationLoaderTest.java @@ -17,6 +17,12 @@ package org.apache.zeppelin.helium; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; import org.apache.commons.io.FileUtils; import org.apache.zeppelin.dep.DependencyResolver; import org.apache.zeppelin.interpreter.InterpreterOutput; @@ -25,20 +31,14 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.io.File; -import java.io.IOException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - public class ApplicationLoaderTest { private File tmpDir; @Before public void setUp() { - tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + - System.currentTimeMillis()); + tmpDir = + new File( + System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis()); tmpDir.mkdirs(); } @@ -58,8 +58,9 @@ public class ApplicationLoaderTest { ApplicationContext context1 = createContext("note1", "paragraph1", "app1"); // when load application - MockApplication1 app = (MockApplication1) ((ClassLoaderApplication) - appLoader.load(pkg1, context1)).getInnerApplication(); + MockApplication1 app = + (MockApplication1) + ((ClassLoaderApplication) appLoader.load(pkg1, context1)).getInnerApplication(); // then assertFalse(app.isUnloaded()); @@ -74,25 +75,23 @@ public class ApplicationLoaderTest { } public HeliumPackage createPackageInfo(String className, String artifact) { - HeliumPackage app1 = new HeliumPackage( - HeliumType.APPLICATION, - "name1", - "desc1", - artifact, - className, - new String[][]{{}}, - "license", - "icon"); + HeliumPackage app1 = + new HeliumPackage( + HeliumType.APPLICATION, + "name1", + "desc1", + artifact, + className, + new String[][] {{}}, + "license", + "icon"); return app1; } public ApplicationContext createContext(String noteId, String paragraphId, String appInstanceId) { - ApplicationContext context1 = new ApplicationContext( - noteId, - paragraphId, - appInstanceId, - null, - new InterpreterOutput(null)); + ApplicationContext context1 = + new ApplicationContext( + noteId, paragraphId, appInstanceId, null, new InterpreterOutput(null)); return context1; } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java index e810742..73fad6e 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/HeliumPackageTest.java @@ -17,28 +17,28 @@ package org.apache.zeppelin.helium; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.util.Map; - -import static org.junit.Assert.assertEquals; +import org.junit.Test; public class HeliumPackageTest { @Test public void parseSpellPackageInfo() { - String examplePackage = "{\n" + - " \"type\" : \"SPELL\",\n" + - " \"name\" : \"echo-spell\",\n" + - " \"description\" : \"'%echo' - return just what receive (example)\",\n" + - " \"artifact\" : \"./zeppelin-examples/zeppelin-example-spell-echo\",\n" + - " \"license\" : \"Apache-2.0\",\n" + - " \"icon\" : \"<i class='fa fa-repeat'></i>\",\n" + - " \"spell\": {\n" + - " \"magic\": \"%echo\",\n" + - " \"usage\": \"%echo <TEXT>\"\n" + - " }\n" + - "}"; + String examplePackage = + "{\n" + + " \"type\" : \"SPELL\",\n" + + " \"name\" : \"echo-spell\",\n" + + " \"description\" : \"'%echo' - return just what receive (example)\",\n" + + " \"artifact\" : \"./zeppelin-examples/zeppelin-example-spell-echo\",\n" + + " \"license\" : \"Apache-2.0\",\n" + + " \"icon\" : \"<i class='fa fa-repeat'></i>\",\n" + + " \"spell\": {\n" + + " \"magic\": \"%echo\",\n" + + " \"usage\": \"%echo <TEXT>\"\n" + + " }\n" + + "}"; HeliumPackage p = HeliumPackage.fromJson(examplePackage); assertEquals(p.getSpellInfo().getMagic(), "%echo"); @@ -47,34 +47,34 @@ public class HeliumPackageTest { @Test public void parseConfig() { - String examplePackage = "{\n" + - " \"type\" : \"SPELL\",\n" + - " \"name\" : \"translator-spell\",\n" + - " \"description\" : \"Translate langauges using Google API (examaple)\",\n" + - " \"artifact\" : \"./zeppelin-examples/zeppelin-example-spell-translator\",\n" + - " \"license\" : \"Apache-2.0\",\n" + - " \"icon\" : \"<i class='fa fa-globe '></i>\",\n" + - " \"config\": {\n" + - " \"access-token\": {\n" + - " \"type\": \"string\",\n" + - " \"description\": \"access token for Google Translation API\",\n" + - " \"defaultValue\": \"EXAMPLE-TOKEN\"\n" + - " }\n" + - " },\n" + - " \"spell\": {\n" + - " \"magic\": \"%translator\",\n" + - " \"usage\": \"%translator <source>-<target> <access-key> <TEXT>\"\n" + - " }\n" + - "}"; + String examplePackage = + "{\n" + + " \"type\" : \"SPELL\",\n" + + " \"name\" : \"translator-spell\",\n" + + " \"description\" : \"Translate langauges using Google API (examaple)\",\n" + + " \"artifact\" : \"./zeppelin-examples/zeppelin-example-spell-translator\",\n" + + " \"license\" : \"Apache-2.0\",\n" + + " \"icon\" : \"<i class='fa fa-globe '></i>\",\n" + + " \"config\": {\n" + + " \"access-token\": {\n" + + " \"type\": \"string\",\n" + + " \"description\": \"access token for Google Translation API\",\n" + + " \"defaultValue\": \"EXAMPLE-TOKEN\"\n" + + " }\n" + + " },\n" + + " \"spell\": {\n" + + " \"magic\": \"%translator\",\n" + + " \"usage\": \"%translator <source>-<target> <access-key> <TEXT>\"\n" + + " }\n" + + "}"; HeliumPackage p = HeliumPackage.fromJson(examplePackage); Map<String, Object> config = p.getConfig(); Map<String, Object> accessToken = (Map<String, Object>) config.get("access-token"); assertEquals((String) accessToken.get("type"), "string"); - assertEquals((String) accessToken.get("description"), - "access token for Google Translation API"); - assertEquals((String) accessToken.get("defaultValue"), - "EXAMPLE-TOKEN"); + assertEquals( + (String) accessToken.get("description"), "access token for Google Translation API"); + assertEquals((String) accessToken.get("defaultValue"), "EXAMPLE-TOKEN"); } } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java index c962d84..a581f1e 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/helium/MockApplication1.java @@ -18,9 +18,7 @@ package org.apache.zeppelin.helium; import org.apache.zeppelin.resource.ResourceSet; -/** - * Mock application - */ +/** Mock application */ public class MockApplication1 extends Application { boolean unloaded; int run; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/BaseZeppelinContextTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/BaseZeppelinContextTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/BaseZeppelinContextTest.java index 985ba4f..a227adf 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/BaseZeppelinContextTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/BaseZeppelinContextTest.java @@ -17,14 +17,12 @@ package org.apache.zeppelin.interpreter; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.util.HashMap; import java.util.List; import java.util.Map; - -import static org.junit.Assert.assertEquals; - +import org.junit.Test; public class BaseZeppelinContextTest { @@ -32,87 +30,118 @@ public class BaseZeppelinContextTest { public void testHooks() throws InvalidHookException { InterpreterHookRegistry hookRegistry = new InterpreterHookRegistry(); TestZeppelinContext z = new TestZeppelinContext(hookRegistry, 10); - InterpreterContext context = InterpreterContext.builder() - .setNoteId("note_1") - .setNoteName("note_name_1") - .setParagraphId("paragraph_1") - .setInterpreterClassName("Test1Interpreter") - .setReplName("test1") - .build(); + InterpreterContext context = + InterpreterContext.builder() + .setNoteId("note_1") + .setNoteName("note_name_1") + .setParagraphId("paragraph_1") + .setInterpreterClassName("Test1Interpreter") + .setReplName("test1") + .build(); z.setInterpreterContext(context); // get note name via InterpreterContext String note_name = z.getInterpreterContext().getNoteName(); assertEquals( - String.format("Actual note name: %s, but expected %s", note_name, "note_name_1"), - "note_name_1", - note_name - ); + String.format("Actual note name: %s, but expected %s", note_name, "note_name_1"), + "note_name_1", + note_name); // register global hook for current interpreter z.registerHook(InterpreterHookRegistry.HookType.PRE_EXEC.getName(), "pre_cmd"); z.registerHook(InterpreterHookRegistry.HookType.POST_EXEC.getName(), "post_cmd"); - assertEquals("pre_cmd", hookRegistry.get(null, "Test1Interpreter", - InterpreterHookRegistry.HookType.PRE_EXEC.getName())); - assertEquals("post_cmd", hookRegistry.get(null, "Test1Interpreter", - InterpreterHookRegistry.HookType.POST_EXEC.getName())); + assertEquals( + "pre_cmd", + hookRegistry.get( + null, "Test1Interpreter", InterpreterHookRegistry.HookType.PRE_EXEC.getName())); + assertEquals( + "post_cmd", + hookRegistry.get( + null, "Test1Interpreter", InterpreterHookRegistry.HookType.POST_EXEC.getName())); z.unregisterHook(InterpreterHookRegistry.HookType.PRE_EXEC.getName()); z.unregisterHook(InterpreterHookRegistry.HookType.POST_EXEC.getName()); - assertEquals(null, hookRegistry.get(null, "Test1Interpreter", - InterpreterHookRegistry.HookType.PRE_EXEC.getName())); - assertEquals(null, hookRegistry.get(null, "Test1Interpreter", - InterpreterHookRegistry.HookType.POST_EXEC.getName())); + assertEquals( + null, + hookRegistry.get( + null, "Test1Interpreter", InterpreterHookRegistry.HookType.PRE_EXEC.getName())); + assertEquals( + null, + hookRegistry.get( + null, "Test1Interpreter", InterpreterHookRegistry.HookType.POST_EXEC.getName())); // register global hook for interpreter test2 z.registerHook(InterpreterHookRegistry.HookType.PRE_EXEC.getName(), "pre_cmd2", "test2"); z.registerHook(InterpreterHookRegistry.HookType.POST_EXEC.getName(), "post_cmd2", "test2"); - assertEquals("pre_cmd2", hookRegistry.get(null, "Test2Interpreter", - InterpreterHookRegistry.HookType.PRE_EXEC.getName())); - assertEquals("post_cmd2", hookRegistry.get(null, "Test2Interpreter", - InterpreterHookRegistry.HookType.POST_EXEC.getName())); + assertEquals( + "pre_cmd2", + hookRegistry.get( + null, "Test2Interpreter", InterpreterHookRegistry.HookType.PRE_EXEC.getName())); + assertEquals( + "post_cmd2", + hookRegistry.get( + null, "Test2Interpreter", InterpreterHookRegistry.HookType.POST_EXEC.getName())); z.unregisterHook(InterpreterHookRegistry.HookType.PRE_EXEC.getName(), "test2"); z.unregisterHook(InterpreterHookRegistry.HookType.POST_EXEC.getName(), "test2"); - assertEquals(null, hookRegistry.get(null, "Test2Interpreter", - InterpreterHookRegistry.HookType.PRE_EXEC.getName())); - assertEquals(null, hookRegistry.get(null, "Test2Interpreter", - InterpreterHookRegistry.HookType.POST_EXEC.getName())); + assertEquals( + null, + hookRegistry.get( + null, "Test2Interpreter", InterpreterHookRegistry.HookType.PRE_EXEC.getName())); + assertEquals( + null, + hookRegistry.get( + null, "Test2Interpreter", InterpreterHookRegistry.HookType.POST_EXEC.getName())); // register hook for note_1 and current interpreter z.registerNoteHook(InterpreterHookRegistry.HookType.PRE_EXEC.getName(), "pre_cmd", "note_1"); z.registerNoteHook(InterpreterHookRegistry.HookType.POST_EXEC.getName(), "post_cmd", "note_1"); - assertEquals("pre_cmd", hookRegistry.get("note_1", "Test1Interpreter", - InterpreterHookRegistry.HookType.PRE_EXEC.getName())); - assertEquals("post_cmd", hookRegistry.get("note_1", "Test1Interpreter", - InterpreterHookRegistry.HookType.POST_EXEC.getName())); + assertEquals( + "pre_cmd", + hookRegistry.get( + "note_1", "Test1Interpreter", InterpreterHookRegistry.HookType.PRE_EXEC.getName())); + assertEquals( + "post_cmd", + hookRegistry.get( + "note_1", "Test1Interpreter", InterpreterHookRegistry.HookType.POST_EXEC.getName())); z.unregisterNoteHook("note_1", InterpreterHookRegistry.HookType.PRE_EXEC.getName(), "test1"); z.unregisterNoteHook("note_1", InterpreterHookRegistry.HookType.POST_EXEC.getName(), "test1"); - assertEquals(null, hookRegistry.get("note_1", "Test1Interpreter", - InterpreterHookRegistry.HookType.PRE_EXEC.getName())); - assertEquals(null, hookRegistry.get("note_1", "Test1Interpreter", - InterpreterHookRegistry.HookType.POST_EXEC.getName())); + assertEquals( + null, + hookRegistry.get( + "note_1", "Test1Interpreter", InterpreterHookRegistry.HookType.PRE_EXEC.getName())); + assertEquals( + null, + hookRegistry.get( + "note_1", "Test1Interpreter", InterpreterHookRegistry.HookType.POST_EXEC.getName())); // register hook for note_1 and interpreter test2 - z.registerNoteHook(InterpreterHookRegistry.HookType.PRE_EXEC.getName(), - "pre_cmd2", "note_1", "test2"); - z.registerNoteHook(InterpreterHookRegistry.HookType.POST_EXEC.getName(), - "post_cmd2", "note_1", "test2"); - assertEquals("pre_cmd2", hookRegistry.get("note_1", "Test2Interpreter", - InterpreterHookRegistry.HookType.PRE_EXEC.getName())); - assertEquals("post_cmd2", hookRegistry.get("note_1", "Test2Interpreter", - InterpreterHookRegistry.HookType.POST_EXEC.getName())); + z.registerNoteHook( + InterpreterHookRegistry.HookType.PRE_EXEC.getName(), "pre_cmd2", "note_1", "test2"); + z.registerNoteHook( + InterpreterHookRegistry.HookType.POST_EXEC.getName(), "post_cmd2", "note_1", "test2"); + assertEquals( + "pre_cmd2", + hookRegistry.get( + "note_1", "Test2Interpreter", InterpreterHookRegistry.HookType.PRE_EXEC.getName())); + assertEquals( + "post_cmd2", + hookRegistry.get( + "note_1", "Test2Interpreter", InterpreterHookRegistry.HookType.POST_EXEC.getName())); z.unregisterNoteHook("note_1", InterpreterHookRegistry.HookType.PRE_EXEC.getName(), "test2"); z.unregisterNoteHook("note_1", InterpreterHookRegistry.HookType.POST_EXEC.getName(), "test2"); - assertEquals(null, hookRegistry.get("note_1", "Test2Interpreter", - InterpreterHookRegistry.HookType.PRE_EXEC.getName())); - assertEquals(null, hookRegistry.get("note_1", "Test2Interpreter", - InterpreterHookRegistry.HookType.POST_EXEC.getName())); + assertEquals( + null, + hookRegistry.get( + "note_1", "Test2Interpreter", InterpreterHookRegistry.HookType.PRE_EXEC.getName())); + assertEquals( + null, + hookRegistry.get( + "note_1", "Test2Interpreter", InterpreterHookRegistry.HookType.POST_EXEC.getName())); } - public static class TestZeppelinContext extends BaseZeppelinContext { public TestZeppelinContext(InterpreterHookRegistry hooks, int maxResult) { @@ -137,6 +166,4 @@ public class BaseZeppelinContextTest { return null; } } - - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java index 62b4035..ac6a2eb 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterContextTest.java @@ -17,11 +17,11 @@ package org.apache.zeppelin.interpreter; -import org.junit.Test; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import org.junit.Test; + public class InterpreterContextTest { @Test @@ -29,12 +29,10 @@ public class InterpreterContextTest { InterpreterContext.remove(); assertNull(InterpreterContext.get()); - InterpreterContext.set(InterpreterContext.builder() - .build()); + InterpreterContext.set(InterpreterContext.builder().build()); assertNotNull(InterpreterContext.get()); InterpreterContext.remove(); assertNull(InterpreterContext.get()); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterHookRegistryTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterHookRegistryTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterHookRegistryTest.java index 2381dc3..52c37e1 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterHookRegistryTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterHookRegistryTest.java @@ -17,8 +17,6 @@ package org.apache.zeppelin.interpreter; -import org.junit.Test; - import static org.apache.zeppelin.interpreter.InterpreterHookRegistry.HookType.POST_EXEC; import static org.apache.zeppelin.interpreter.InterpreterHookRegistry.HookType.POST_EXEC_DEV; import static org.apache.zeppelin.interpreter.InterpreterHookRegistry.HookType.PRE_EXEC; @@ -26,6 +24,8 @@ import static org.apache.zeppelin.interpreter.InterpreterHookRegistry.HookType.P import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import org.junit.Test; + public class InterpreterHookRegistryTest { @Test @@ -71,5 +71,4 @@ public class InterpreterHookRegistryTest { // Test that only valid event codes ("pre_exec", "post_exec") are accepted registry.register("foo", "bar", "baz", "whatever"); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeWatcherTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeWatcherTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeWatcherTest.java index 2dbbbf8..52f1f1c 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeWatcherTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputChangeWatcherTest.java @@ -16,17 +16,16 @@ */ package org.apache.zeppelin.interpreter; -import org.junit.After; -import org.junit.Before; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.concurrent.atomic.AtomicInteger; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import org.junit.After; +import org.junit.Before; public class InterpreterOutputChangeWatcherTest implements InterpreterOutputChangeListener { private File tmpDir; @@ -39,8 +38,9 @@ public class InterpreterOutputChangeWatcherTest implements InterpreterOutputChan watcher = new InterpreterOutputChangeWatcher(this); watcher.start(); - tmpDir = new File(System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + - System.currentTimeMillis()); + tmpDir = + new File( + System.getProperty("java.io.tmpdir") + "/ZeppelinLTest_" + System.currentTimeMillis()); tmpDir.mkdirs(); fileChanged = null; numChanged = new AtomicInteger(0); @@ -66,7 +66,6 @@ public class InterpreterOutputChangeWatcherTest implements InterpreterOutputChan } } - // @Test public void test() throws IOException, InterruptedException { assertNull(fileChanged); @@ -99,7 +98,6 @@ public class InterpreterOutputChangeWatcherTest implements InterpreterOutputChan assertEquals(1, numChanged.get()); } - @Override public void fileChanged(File file) { fileChanged = file; @@ -109,5 +107,4 @@ public class InterpreterOutputChangeWatcherTest implements InterpreterOutputChan notify(); } } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java index 8158151..1d0ea7a 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterOutputTest.java @@ -16,15 +16,13 @@ */ package org.apache.zeppelin.interpreter; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.io.IOException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; public class InterpreterOutputTest implements InterpreterOutputListener { private InterpreterOutput out; @@ -79,7 +77,6 @@ public class InterpreterOutputTest implements InterpreterOutputListener { assertEquals("div", new String(out.getOutputAt(0).toByteArray())); } - @Test public void testType() throws IOException { // default output stream type is TEXT @@ -153,7 +150,6 @@ public class InterpreterOutputTest implements InterpreterOutputListener { assertEquals("<h3> This is a hack </h3>\t234\n", new String(out.getOutputAt(1).toByteArray())); } - @Test public void testTableCellFormatting() throws IOException { out.write("%table col1\tcol2\n\n%html val1\tval2\n".getBytes()); @@ -192,11 +188,8 @@ public class InterpreterOutputTest implements InterpreterOutputListener { InterpreterOutput.limit = Constants.ZEPPELIN_INTERPRETER_OUTPUT_LIMIT; } - @Override - public void onUpdateAll(InterpreterOutput out) { - - } + public void onUpdateAll(InterpreterOutput out) {} @Override public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterResultTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterResultTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterResultTest.java index a8ff1bf..db069fd 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterResultTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterResultTest.java @@ -17,18 +17,17 @@ package org.apache.zeppelin.interpreter; -import org.junit.Test; - import static org.junit.Assert.assertEquals; +import org.junit.Test; public class InterpreterResultTest { @Test public void testTextType() { - InterpreterResult result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "this is a TEXT type"); + InterpreterResult result = + new InterpreterResult(InterpreterResult.Code.SUCCESS, "this is a TEXT type"); assertEquals("No magic", InterpreterResult.Type.TEXT, result.message().get(0).getType()); result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "%this is a TEXT type"); assertEquals("No magic", InterpreterResult.Type.TEXT, result.message().get(0).getType()); @@ -40,14 +39,15 @@ public class InterpreterResultTest { public void testSimpleMagicType() { InterpreterResult result = null; - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%table col1\tcol2\naaa\t123\n"); + result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "%table col1\tcol2\naaa\t123\n"); assertEquals(InterpreterResult.Type.TABLE, result.message().get(0).getType()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%table\ncol1\tcol2\naaa\t123\n"); + result = + new InterpreterResult(InterpreterResult.Code.SUCCESS, "%table\ncol1\tcol2\naaa\t123\n"); assertEquals(InterpreterResult.Type.TABLE, result.message().get(0).getType()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "some text before magic word\n%table col1\tcol2\naaa\t123\n"); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "some text before magic word\n%table col1\tcol2\naaa\t123\n"); assertEquals(InterpreterResult.Type.TABLE, result.message().get(1).getType()); } @@ -55,29 +55,49 @@ public class InterpreterResultTest { public void testComplexMagicType() { InterpreterResult result = null; - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "some text before %table col1\tcol2\naaa\t123\n"); - assertEquals("some text before magic return magic", - InterpreterResult.Type.TEXT, result.message().get(0).getType()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "some text before\n%table col1\tcol2\naaa\t123\n"); - assertEquals("some text before magic return magic", - InterpreterResult.Type.TEXT, result.message().get(0).getType()); - assertEquals("some text before magic return magic", - InterpreterResult.Type.TABLE, result.message().get(1).getType()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%html <h3> This is a hack </h3> %table\n col1\tcol2\naaa\t123\n"); - assertEquals("magic A before magic B return magic A", - InterpreterResult.Type.HTML, result.message().get(0).getType()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "some text before magic word %table col1\tcol2\naaa\t123\n %html " + - "<h3> This is a hack </h3>"); - assertEquals("text & magic A before magic B return magic A", - InterpreterResult.Type.TEXT, result.message().get(0).getType()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%table col1\tcol2\naaa\t123\n %html <h3> This is a hack </h3> %table col1\naaa\n123\n"); - assertEquals("magic A, magic B, magic a' return magic A", - InterpreterResult.Type.TABLE, result.message().get(0).getType()); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, "some text before %table col1\tcol2\naaa\t123\n"); + assertEquals( + "some text before magic return magic", + InterpreterResult.Type.TEXT, + result.message().get(0).getType()); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, "some text before\n%table col1\tcol2\naaa\t123\n"); + assertEquals( + "some text before magic return magic", + InterpreterResult.Type.TEXT, + result.message().get(0).getType()); + assertEquals( + "some text before magic return magic", + InterpreterResult.Type.TABLE, + result.message().get(1).getType()); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "%html <h3> This is a hack </h3> %table\n col1\tcol2\naaa\t123\n"); + assertEquals( + "magic A before magic B return magic A", + InterpreterResult.Type.HTML, + result.message().get(0).getType()); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "some text before magic word %table col1\tcol2\naaa\t123\n %html " + + "<h3> This is a hack </h3>"); + assertEquals( + "text & magic A before magic B return magic A", + InterpreterResult.Type.TEXT, + result.message().get(0).getType()); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "%table col1\tcol2\naaa\t123\n %html <h3> This is a hack </h3> %table col1\naaa\n123\n"); + assertEquals( + "magic A, magic B, magic a' return magic A", + InterpreterResult.Type.TABLE, + result.message().get(0).getType()); } @Test @@ -85,17 +105,21 @@ public class InterpreterResultTest { InterpreterResult result = null; - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%table col1\tcol2\naaa\t123\n"); - assertEquals("%table col1\tcol2\naaa\t123\n", + result = new InterpreterResult(InterpreterResult.Code.SUCCESS, "%table col1\tcol2\naaa\t123\n"); + assertEquals( + "%table col1\tcol2\naaa\t123\n", "col1\tcol2\naaa\t123\n", result.message().get(0).getData()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%table\ncol1\tcol2\naaa\t123\n"); - assertEquals("%table\ncol1\tcol2\naaa\t123\n", + result = + new InterpreterResult(InterpreterResult.Code.SUCCESS, "%table\ncol1\tcol2\naaa\t123\n"); + assertEquals( + "%table\ncol1\tcol2\naaa\t123\n", "col1\tcol2\naaa\t123\n", result.message().get(0).getData()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "some text before magic word\n%table col1\tcol2\naaa\t123\n"); - assertEquals("some text before magic word\n%table col1\tcol2\naaa\t123\n", + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "some text before magic word\n%table col1\tcol2\naaa\t123\n"); + assertEquals( + "some text before magic word\n%table col1\tcol2\naaa\t123\n", "col1\tcol2\naaa\t123\n", result.message().get(1).getData()); } @@ -103,31 +127,40 @@ public class InterpreterResultTest { InterpreterResult result = null; - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "some text before\n%table col1\tcol2\naaa\t123\n"); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, "some text before\n%table col1\tcol2\naaa\t123\n"); assertEquals("text before %table", "some text before\n", result.message().get(0).getData()); assertEquals("text after %table", "col1\tcol2\naaa\t123\n", result.message().get(1).getData()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%html <h3> This is a hack </h3>\n%table\ncol1\tcol2\naaa\t123\n"); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "%html <h3> This is a hack </h3>\n%table\ncol1\tcol2\naaa\t123\n"); assertEquals(" <h3> This is a hack </h3>\n", result.message().get(0).getData()); assertEquals("col1\tcol2\naaa\t123\n", result.message().get(1).getData()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "some text before magic word\n%table col1\tcol2\naaa\t123\n\n%html " + - "<h3> This is a hack </h3>"); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "some text before magic word\n%table col1\tcol2\naaa\t123\n\n%html " + + "<h3> This is a hack </h3>"); assertEquals("<h3> This is a hack </h3>", result.message().get(2).getData()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%table col1\tcol2\naaa\t123\n\n%html <h3> This is a hack </h3>\n%table col1\naaa\n123\n"); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "%table col1\tcol2\naaa\t123\n\n%html <h3> This is a hack </h3>\n%table col1\naaa\n123\n"); assertEquals("col1\naaa\n123\n", result.message().get(2).getData()); - result = new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%table " + "col1\tcol2\naaa\t123\n\n%table col1\naaa\n123\n"); + result = + new InterpreterResult( + InterpreterResult.Code.SUCCESS, + "%table " + "col1\tcol2\naaa\t123\n\n%table col1\naaa\n123\n"); assertEquals("col1\tcol2\naaa\t123\n", result.message().get(0).getData()); assertEquals("col1\naaa\n123\n", result.message().get(1).getData()); } @Test public void testToString() { - assertEquals("%html hello", new InterpreterResult(InterpreterResult.Code.SUCCESS, - "%html hello").toString()); + assertEquals( + "%html hello", + new InterpreterResult(InterpreterResult.Code.SUCCESS, "%html hello").toString()); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java index 72b9f58..11e9750 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/InterpreterTest.java @@ -17,13 +17,12 @@ package org.apache.zeppelin.interpreter; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import java.util.Properties; +import org.junit.Test; -import static org.junit.Assert.assertEquals; - -//TODO(zjffdu) add more test for Interpreter which is a very important class +// TODO(zjffdu) add more test for Interpreter which is a very important class public class InterpreterTest { @Test @@ -67,20 +66,22 @@ public class InterpreterTest { .build()); Properties p = new Properties(); - p.put("p1", "replName #{noteId}, #{paragraphTitle}, #{paragraphId}, #{paragraphText}, " + - "#{replName}, #{noteId}, #{user}," + - " #{authenticationInfo}"); + p.put( + "p1", + "replName #{noteId}, #{paragraphTitle}, #{paragraphId}, #{paragraphText}, " + + "#{replName}, #{noteId}, #{user}," + + " #{authenticationInfo}"); Interpreter intp = new DummyInterpreter(p); intp.setUserName(user); String actual = intp.getProperty("p1"); InterpreterContext.remove(); assertEquals( - String.format("replName %s, #{paragraphTitle}, #{paragraphId}, #{paragraphText}, , " + - "%s, %s, #{authenticationInfo}", noteId, - noteId, user), - actual - ); + String.format( + "replName %s, #{paragraphTitle}, #{paragraphId}, #{paragraphText}, , " + + "%s, %s, #{authenticationInfo}", + noteId, noteId, user), + actual); } public static class DummyInterpreter extends Interpreter { @@ -90,14 +91,10 @@ public class InterpreterTest { } @Override - public void open() { - - } + public void open() {} @Override - public void close() { - - } + public void close() {} @Override public InterpreterResult interpret(String st, InterpreterContext context) { @@ -105,9 +102,7 @@ public class InterpreterTest { } @Override - public void cancel(InterpreterContext context) { - - } + public void cancel(InterpreterContext context) {} @Override public FormType getFormType() { @@ -119,5 +114,4 @@ public class InterpreterTest { return 0; } } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java index 417b72c..272e9ed 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/LazyOpenInterpreterTest.java @@ -17,14 +17,14 @@ package org.apache.zeppelin.interpreter; -import org.junit.Test; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import org.junit.Test; + public class LazyOpenInterpreterTest { Interpreter interpreter = mock(Interpreter.class); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/ZeppCtxtVariableTest.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/ZeppCtxtVariableTest.java b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/ZeppCtxtVariableTest.java index 14b4b6b..e517b46 100644 --- a/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/ZeppCtxtVariableTest.java +++ b/zeppelin-interpreter/src/test/java/org/apache/zeppelin/interpreter/ZeppCtxtVariableTest.java @@ -17,16 +17,15 @@ package org.apache.zeppelin.interpreter; +import static org.junit.Assert.assertTrue; + +import java.util.Properties; import org.apache.zeppelin.resource.LocalResourcePool; import org.apache.zeppelin.resource.ResourcePool; import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.util.Properties; - -import static org.junit.Assert.assertTrue; - public class ZeppCtxtVariableTest { public static class TestInterpreter extends Interpreter { @@ -36,12 +35,10 @@ public class ZeppCtxtVariableTest { } @Override - public void open() { - } + public void open() {} @Override - public void close() { - } + public void close() {} @Override public InterpreterResult interpret(String st, InterpreterContext context) { @@ -49,8 +46,7 @@ public class ZeppCtxtVariableTest { } @Override - public void cancel(InterpreterContext context) { - } + public void cancel(InterpreterContext context) {} @Override public FormType getFormType() { @@ -71,17 +67,17 @@ public class ZeppCtxtVariableTest { resourcePool = new LocalResourcePool("ZeppelinContextVariableInterpolationTest"); - InterpreterContext context = InterpreterContext.builder() - .setNoteId("noteId") - .setParagraphId("paragraphId") - .setResourcePool(resourcePool) - .build(); + InterpreterContext context = + InterpreterContext.builder() + .setNoteId("noteId") + .setParagraphId("paragraphId") + .setResourcePool(resourcePool) + .build(); InterpreterContext.set(context); interpreter = new TestInterpreter(new Properties()); resourcePool.put("PI", "3.1415"); - } @After @@ -113,28 +109,24 @@ public class ZeppCtxtVariableTest { assertTrue("multiLineSubstitutionSuccessful1", "{PI}\n3.1415\n{PI}\n3.1415".equals(result)); } - @Test public void multiLineSubstitutionSuccessful2() { String result = interpreter.interpolate("prefix {PI} {{PI\n}} suffix", resourcePool); assertTrue("multiLineSubstitutionSuccessful2", "prefix 3.1415 {PI\n} suffix".equals(result)); } - @Test public void multiLineSubstitutionSuccessful3() { String result = interpreter.interpolate("prefix {{\nPI}} {PI} suffix", resourcePool); assertTrue("multiLineSubstitutionSuccessful3", "prefix {\nPI} 3.1415 suffix".equals(result)); } - @Test public void multiLineSubstitutionFailure2() { String result = interpreter.interpolate("prefix {PI\n} suffix", resourcePool); assertTrue("multiLineSubstitutionFailure2", "prefix {PI\n} suffix".equals(result)); } - @Test public void multiLineSubstitutionFailure3() { String result = interpreter.interpolate("prefix {\nPI} suffix", resourcePool); @@ -200,5 +192,4 @@ public class ZeppCtxtVariableTest { String result = interpreter.interpolate("Paired } end an escaped sequence", resourcePool); assertTrue("Random braces - four", "Paired } end an escaped sequence".equals(result)); } - }
