Formatting for google style

This commit is contained in:
Ramaswamy Devarajan 2016-01-08 19:55:02 -08:00
parent 9b64a6603c
commit ecb8f1eaf5
2 changed files with 35 additions and 29 deletions

View file

@ -150,6 +150,7 @@ public class NotebookRestApi {
/**
* export note REST API
*
* @param
* @return note JSON with status.OK
* @throws IOException
@ -167,6 +168,7 @@ public class NotebookRestApi {
/**
* import new note REST API
*
* @param req - notebook Json
* @return JSON with new note ID
* @throws IOException
@ -195,7 +197,7 @@ public class NotebookRestApi {
}
notebookServer.broadcastNote(newNote);
notebookServer.broadcastNoteList();
return new JsonResponse<>(Status.CREATED, "", newNote.getId() ).build();
return new JsonResponse<>(Status.CREATED, "", newNote.getId()).build();
}
/**

View file

@ -337,23 +337,24 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi {
LOG.info("testNotebookExport \n" + get.getResponseBodyAsString());
assertThat("test notebook export method:", get, isAllowed());
Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String, Object>>() {
}.getType());
Map<String, Object> resp =
gson.fromJson(get.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>() {}.getType());
String exportJSON = (String) resp.get("body");
String exportJSON = (String) resp.get("body");
assertNotNull("Can not find new notejson", exportJSON);
LOG.info("export JSON:=" + exportJSON);
ZeppelinServer.notebook.removeNote(sourceNoteID);
get.releaseConnection();
}
@Test
public void testImportNotebook() throws IOException {
Map<String, Object> resp;
String noteName="source note for import";
Map<String, Object> resp;
String noteName = "source note for import";
LOG.info("testImortNotebook");
//create test notebook
// create test notebook
Note note = ZeppelinServer.notebook.createNote();
assertNotNull("can't create new note", note);
note.setName(noteName);
@ -366,36 +367,39 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi {
String sourceNoteID = note.getId();
// get note content as JSON
String oldJson = getNoteContent(sourceNoteID);
//call notebook put
PutMethod importPut = httpPut("/notebook/import/" , oldJson);
// call notebook put
PutMethod importPut = httpPut("/notebook/import/", oldJson);
assertThat(importPut, isCreated());
resp = gson.fromJson(importPut.getResponseBodyAsString(), new TypeToken<Map<String, Object>>(){}.getType());
resp =
gson.fromJson(importPut.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>() {}.getType());
String importId = (String) resp.get("body");
assertNotNull("Did not get back a notebook id in body", importId);
Note newNote=ZeppelinServer.notebook.getNote(importId);
Note newNote = ZeppelinServer.notebook.getNote(importId);
assertEquals("Compare note names", noteName, newNote.getName());
assertEquals("Compare paragraphs count", note.getParagraphs().size(), newNote.getParagraphs().size());
//cleanup
assertEquals("Compare paragraphs count", note.getParagraphs().size(), newNote.getParagraphs()
.size());
// cleanup
ZeppelinServer.notebook.removeNote(note.getId());
ZeppelinServer.notebook.removeNote(newNote.getId());
importPut.releaseConnection();
}
private String getNoteContent(String id) throws IOException {
GetMethod get = httpGet("/notebook/export/" + id);
assertThat(get, isAllowed());
get.addRequestHeader("Origin", "http://localhost");
Map<String, Object> resp = gson.fromJson(get.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>() {
}.getType());
assertEquals(200, get.getStatusCode());
String body = resp.get("body").toString();
// System.out.println("Body is " + body);
get.releaseConnection();
return body;
}
private String getNoteContent(String id) throws IOException {
GetMethod get = httpGet("/notebook/export/" + id);
assertThat(get, isAllowed());
get.addRequestHeader("Origin", "http://localhost");
Map<String, Object> resp =
gson.fromJson(get.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>() {}.getType());
assertEquals(200, get.getStatusCode());
String body = resp.get("body").toString();
// System.out.println("Body is " + body);
get.releaseConnection();
return body;
}
private void testDeleteNotebook(String notebookId) throws IOException {
DeleteMethod delete = httpDelete(("/notebook/" + notebookId));