GCSNotebookRepo implements NotebookRepo { @Override public Note get(String noteId, String notePath, AuthenticationInfo subject) throws IOException { BlobId blobId = makeBlobId(noteId, notePath); byte[] contents; try { contents = storage.readAllBytes(blobId); } catch (StorageException se) { throw new IOException("Could not read " + blobId.toString() + ": " + se.getMessage(), se); } try { return Note.fromJson(new String(contents, encoding)); } catch (JsonParseException jpe) { throw new IOException( "Could note parse as json " + blobId.toString() + jpe.getMessage(), jpe); } } GCSNotebookRepo(); @VisibleForTesting  GCSNotebookRepo(ZeppelinConfiguration zConf, Storage storage); @Override void init(ZeppelinConfiguration zConf); @Override Map<String, NoteInfo> list(AuthenticationInfo subject); @Override Note get(String noteId, String notePath, AuthenticationInfo subject); @Override void save(Note note, AuthenticationInfo subject); @Override void move(String noteId, String notePath, String newNotePath, AuthenticationInfo subject); @Override void move(String folderPath, String newFolderPath, AuthenticationInfo subject); @Override void remove(String noteId, String notePath, AuthenticationInfo subject); @Override void remove(String folderPath, AuthenticationInfo subject); @Override void close(); @Override List<NotebookRepoSettingsInfo> getSettings(AuthenticationInfo subject); @Override void updateSettings(Map<String, String> settings, AuthenticationInfo subject);  }
@Test public void testGet_nonexistent() throws Exception { try { notebookRepo.get("id", "", AUTH_INFO); fail(); } catch (IOException e) {} }
@Test public void testGet() throws Exception { create(runningNote); Note got = notebookRepo.get(runningNote.getId(), runningNote.getPath(), AUTH_INFO); assertThat(got.getLastParagraph().getStatus()).isEqualTo(Status.ABORT); got.getLastParagraph().setStatus(Status.RUNNING); assertThat(got).isEqualTo(runningNote); }
@Test public void testGet_malformed() throws Exception { createMalformed("id", "/name"); try { notebookRepo.get("id", "/name", AUTH_INFO); fail(); } catch (IOException e) {} }