mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Fix test
This commit is contained in:
parent
25f6215a27
commit
dbb8ebd98a
1 changed files with 10 additions and 8 deletions
|
|
@ -13,6 +13,7 @@ import org.apache.zeppelin.conf.ZeppelinConfiguration;
|
|||
import org.apache.zeppelin.notebook.Note;
|
||||
import org.apache.zeppelin.notebook.NoteInfo;
|
||||
import org.apache.zeppelin.notebook.repo.zeppelinhub.rest.ZeppelinhubRestApiHandler;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -20,8 +21,9 @@ import com.google.common.io.Files;
|
|||
|
||||
|
||||
public class ZeppelinHubRepoTest {
|
||||
final String TOKEN = "AAA-BBB-CCC-00";
|
||||
final String token = "AAA-BBB-CCC-00";
|
||||
final String testAddr = "http://zeppelinhub.ltd";
|
||||
final AuthenticationInfo auth = new AuthenticationInfo("anthony");
|
||||
|
||||
private ZeppelinHubRepo repo;
|
||||
private File pathOfNotebooks = new File(System.getProperty("user.dir") + "/src/test/resources/list_of_notes");
|
||||
|
|
@ -30,7 +32,7 @@ public class ZeppelinHubRepoTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_SERVER, testAddr);
|
||||
System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_TOKEN, "AAA-BBB-CCC-00");
|
||||
System.setProperty(ZeppelinHubRepo.ZEPPELIN_CONF_PROP_NAME_TOKEN, token);
|
||||
|
||||
ZeppelinConfiguration conf = new ZeppelinConfiguration();
|
||||
repo = new ZeppelinHubRepo(conf);
|
||||
|
|
@ -41,10 +43,10 @@ public class ZeppelinHubRepoTest {
|
|||
ZeppelinhubRestApiHandler mockedZeppelinhubHandler = mock(ZeppelinhubRestApiHandler.class);
|
||||
|
||||
byte[] response = Files.toByteArray(pathOfNotebooks);
|
||||
when(mockedZeppelinhubHandler.asyncGet("")).thenReturn(new String(response));
|
||||
when(mockedZeppelinhubHandler.asyncGet("", "")).thenReturn(new String(response));
|
||||
|
||||
response = Files.toByteArray(pathOfNotebook);
|
||||
when(mockedZeppelinhubHandler.asyncGet("AAAAA")).thenReturn(new String(response));
|
||||
when(mockedZeppelinhubHandler.asyncGet("", "AAAAA")).thenReturn(new String(response));
|
||||
|
||||
return mockedZeppelinhubHandler;
|
||||
}
|
||||
|
|
@ -123,14 +125,14 @@ public class ZeppelinHubRepoTest {
|
|||
|
||||
@Test
|
||||
public void testGetAllNotes() throws IOException {
|
||||
List<NoteInfo> notebooks = repo.list(null);
|
||||
List<NoteInfo> notebooks = repo.list(auth);
|
||||
assertThat(notebooks).isNotEmpty();
|
||||
assertThat(notebooks.size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNote() throws IOException {
|
||||
Note notebook = repo.get("AAAAA", null);
|
||||
Note notebook = repo.get("AAAAA", auth);
|
||||
assertThat(notebook).isNotNull();
|
||||
assertThat(notebook.getId()).isEqualTo("2A94M5J1Z");
|
||||
}
|
||||
|
|
@ -138,13 +140,13 @@ public class ZeppelinHubRepoTest {
|
|||
@Test
|
||||
public void testRemoveNote() throws IOException {
|
||||
// not suppose to throw
|
||||
repo.remove("AAAAA", null);
|
||||
repo.remove("AAAAA", auth);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveNoteError() throws IOException {
|
||||
// not suppose to throw
|
||||
repo.remove("BBBBB", null);
|
||||
repo.remove("BBBBB", auth);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue