Skip to content

Commit

Permalink
Remove unnecessary method.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwkang committed Aug 11, 2016
1 parent dd60d72 commit 6e91dfe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 29 deletions.
Expand Up @@ -1067,10 +1067,6 @@ private InterpreterSetting getDefaultInterpreterSetting(List<InterpreterSetting>
public InterpreterSetting getDefaultInterpreterSetting(String noteId) {
return getDefaultInterpreterSetting(getInterpreterSettings(noteId));
}

public boolean isBinded(String noteId, String replName) {
return getInterpreter(noteId, replName) != null;
}

private InterpreterSetting getInterpreterSettingByGroup(List<InterpreterSetting> settings,
String group) {
Expand Down
Expand Up @@ -282,7 +282,7 @@ private void addLastReplNameIfEmptyText(Paragraph p) {
}

public boolean isBinding(String replName) {
return factory.isBinded(getId(), replName);
return factory.getInterpreter(this.getId(), replName) != null;
}

private String getInterpreterName(String replName) {
Expand Down
Expand Up @@ -156,28 +156,4 @@ public void testInterpreterAliases() throws IOException, RepositoryException {

assertEquals("className1", factory.getInterpreter("note", "test-group1").getClassName());
}

@Test
public void testIsBindingForNotExistNoteId() throws Exception {
String notExistNoteId = "notExistNoteId";
List<String> interpreters = factory.getInterpreters(notExistNoteId);

System.out.println(interpreters);
assertTrue(interpreters.isEmpty());
assertFalse(factory.isBinded(notExistNoteId, "i1"));
}

@Test
public void testIsBindingForExistNoteId() throws Exception {
String existNoteId = "existNoteId";
factory.setInterpreters(existNoteId, factory.getDefaultInterpreterSettingList());

List<String> interpreters = factory.getInterpreters(existNoteId);
System.out.println(interpreters);
assertFalse(interpreters.isEmpty());

String groupId = factory.getInterpreterSettings(existNoteId).iterator().next().getGroup();
assertTrue(factory.isBinded(existNoteId, groupId));
assertFalse(factory.isBinded(existNoteId, "i1"));
}
}
Expand Up @@ -23,6 +23,7 @@
import org.apache.zeppelin.interpreter.Interpreter;
import org.apache.zeppelin.interpreter.InterpreterFactory;
import org.apache.zeppelin.interpreter.InterpreterSetting;
import org.apache.zeppelin.interpreter.mock.MockInterpreter2;
import org.apache.zeppelin.notebook.repo.NotebookRepo;
import org.apache.zeppelin.scheduler.Scheduler;
import org.apache.zeppelin.search.SearchService;
Expand Down Expand Up @@ -173,4 +174,20 @@ public void setLastReplName() {

assertEquals("spark", note.getLastReplName());
}

@Test
public void isBindingTest() {
Note note = spy(new Note());
when(note.getId()).thenReturn("test1");
InterpreterFactory mockInterpreterFactory = mock(InterpreterFactory.class);
note.setInterpreterFactory(mockInterpreterFactory);

//when is not binding
assertFalse(note.isBinding("spark"));

//when is binding
when(mockInterpreterFactory.getInterpreter("test1", "spark")).
thenReturn(new MockInterpreter2(null));
assertTrue(note.isBinding("spark"));
}
}

0 comments on commit 6e91dfe

Please sign in to comment.